• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IInvocationInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IInvocationInfo的典型用法代码示例。如果您正苦于以下问题:C# IInvocationInfo类的具体用法?C# IInvocationInfo怎么用?C# IInvocationInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IInvocationInfo类属于命名空间,在下文中一共展示了IInvocationInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AfterInvoke

 public void AfterInvoke(IInvocationInfo context, object returnValue)
 {
     foreach (IAroundInvoke invoke in _aroundInvokeList)
     {
         invoke.AfterInvoke(context, returnValue);
     }
 }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:7,代码来源:CompositeAroundInvoke.cs


示例2: Intercept

        public override object Intercept(IInvocationInfo info)
        {
            //typeof(LobbyMenu).GetField ("_hoverButtonInside", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance).SetValue (info.Target, false);
            try {
                Type lobbyMenu = typeof(LobbyMenu);

                if (first) {

                    GUISkin gUISkin7 = ScriptableObject.CreateInstance<GUISkin> ();

                    text = new Texture2D(87, 39); //115, 39
                    text.LoadImage(System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream ("ScrollsModLoader.Mods.png").ReadToEnd ());

                    gUISkin7.button.normal.background = text;
                    gUISkin7.button.hover.background = text;
                    gUISkin7.button.active.background = text;

                    //info.Target.GUISkins.Add (gUISkin5);
                    FieldInfo GUISkins = lobbyMenu.GetField("GUISkins", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
                    if (GUISkins == null)
                        Console.WriteLine ("GuiSkins == null");
                    ((List<GUISkin>)(GUISkins.GetValue(info.Target))).Add(gUISkin7);
                    first = false;
                }

                MethodInfo drawHeader = lobbyMenu.GetMethod ("drawHeaderButton", BindingFlags.NonPublic | BindingFlags.Instance);
                drawHeader.Invoke(info.Target, new object[] {6, "_Settings"});

            } catch (Exception exp) {
                Console.WriteLine (exp);
            }
            return info.TargetMethod.Invoke(info.Target, info.Arguments);
        }
开发者ID:kevinskyba,项目名称:ScrollsModLoader,代码行数:33,代码来源:PatchHeaderMenu.cs


示例3: ShouldReplace

        /// <summary>
        /// Determines whether or not a particular method body should be replaced at runtime.
        /// </summary>
        /// <param name="host">The host instance that contains the target method.</param>
        /// <param name="context">The context surrounding the method call.</param>
        /// <returns>Returns <c>true</c> if the method body should be swapped; otherwise, it will return <c>false</c>.</returns>
        protected override bool ShouldReplace(object host, IInvocationInfo context)
        {
            if (MethodReplacementPredicate == null)
                return true;

            return MethodReplacementPredicate(context);
        }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:13,代码来源:SimpleMethodReplacementProvider.cs


示例4: Intercept

        /// <summary>
        /// A method that redirects the method calls to 
        /// the functor instance.
        /// </summary>
        /// <param name="info">The <see cref="IInvocationInfo"/> instance that describes the context of the method call.</param>
        /// <returns>The return value from the target method.</returns>
        public object Intercept(IInvocationInfo info)
        {
            if (_doIntercept == null)
                throw new NotImplementedException();

            return _doIntercept(info);
        }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:13,代码来源:FunctorAsInterceptor.cs


示例5: GetProvider

        /// <summary>
        /// Returns the provider that is currently attached to the registry.
        /// </summary>
        /// <param name="host">The type that is currently being intercepted.</param>
        /// <param name="info">The <see cref="IInvocationInfo"/> object that describes the invocation context.</param>
        /// <returns>A <see cref="IMethodReplacementProvider"/> that will determine the code that will be executed once a target method is called.</returns>
        public static IMethodReplacementProvider GetProvider(object host, IInvocationInfo info)
        {
            if (_provider == null)
                return null;

            return _provider.CanReplace(host, info) ? _provider : null;
        }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:13,代码来源:MethodBodyReplacementProviderRegistry.cs


示例6: InvocationInfoInterceptor

 /// <summary>
 /// Initializes the class with a functor that can provide the actual target instance.
 /// </summary>
 /// <param name="getActualTarget">The <see cref="Func{TResult}"/> that will provide the target instance that will be used for the method invocation.</param>
 /// <param name="methodInvoke">The method invoker.</param>
 /// <param name="realInfo">The <see cref="IInvocationInfo"/> instance that describes the current execution context.</param>
 internal InvocationInfoInterceptor(IInvocationInfo realInfo, Func<object> getActualTarget,
                                    IMethodInvoke<MethodInfo> methodInvoke)
     : base(methodInvoke)
 {
     _getActualTarget = getActualTarget;
     _realInfo = realInfo;
 }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:13,代码来源:InvocationInfoInterceptor.cs


示例7: GetSurroundingImplementation

        public IAroundInvoke GetSurroundingImplementation(IInvocationInfo context)
        {
            if (Predicate == null)
                return _around;

            return Predicate(context) ? _around : null;
        }
开发者ID:thlorenz,项目名称:WPFLinFu,代码行数:7,代码来源:SimpleAroundInvokeProvider.cs


示例8: Intercept

        public object Intercept(IInvocationInfo info)
        {
            var args = string.Join(", ", info.Arguments.Select(x => (x ?? string.Empty).ToString()));
            Debug.WriteLine(string.Format("Linfu: {0}({1})", info.TargetMethod.Name, args));

            return info.TargetMethod.Invoke(info.Target, info.Arguments);
        }
开发者ID:CodeDux,项目名称:IocPerformance,代码行数:7,代码来源:LinfuInterceptionLogger.cs


示例9: Invoke

 public object Invoke(IInvocationInfo invocationInfo)
 {
     if (session.InTransaction)
     {
         return invocationInfo.Proceed();
     }
     using (var transaction = session.Connection.BeginTransaction())
     {
         session.InTransaction = true;
         try
         {
             var result = invocationInfo.Proceed();
             transaction.Commit();
             return result;
         }
         catch (Exception)
         {
             transaction.Rollback();
             throw;
         }
         finally
         {
             session.InTransaction = false;
         }
     }
 }
开发者ID:sunloving,项目名称:rooms-and-furniture,代码行数:26,代码来源:TransactionInterceptor.cs


示例10: BeforeInvoke

 public void BeforeInvoke(IInvocationInfo context)
 {
     foreach (IAroundInvoke invoke in _aroundInvokeList)
     {
         invoke.BeforeInvoke(context);
     }
 }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:7,代码来源:CompositeAroundInvoke.cs


示例11: Intercept

        /// <summary>
        /// Intercepts a method call using the given
        /// <see cref="IInvocationInfo"/> instance.
        /// </summary>
        /// <param name="info">The <see cref="IInvocationInfo"/> instance that will 
        /// contain all the necessary information associated with a 
        /// particular method call.</param>
        /// <returns>The return value of the target method. If the return type of the target
        /// method is <see cref="void"/>, then the return value will be ignored.</returns>
        public virtual object Intercept(IInvocationInfo info)
        {
            object target = GetTarget(info);
            MethodBase method = info.TargetMethod;
            object[] arguments = info.Arguments;

            return _methodInvoke.Invoke(target, (MethodInfo) method, arguments);
        }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:17,代码来源:BaseInterceptor.cs


示例12: Intercept

        /// <summary>
        /// Intercepts a method call using the given
        /// <see cref="IInvocationInfo"/> instance.
        /// </summary>
        /// <param name="info">The <see cref="IInvocationInfo"/> instance that will 
        /// contain all the necessary information associated with a 
        /// particular method call.</param>
        /// <returns>The return value of the target method. If the return type of the target
        /// method is <see cref="Void"/>, then the return value will be ignored.</returns>
        public virtual object Intercept(IInvocationInfo info)
        {
            var target = GetTarget(info);
            var method = info.TargetMethod;
            var arguments = info.Arguments;

            return _methodInvoke.Invoke(target, (MethodInfo)method, arguments);
        }
开发者ID:sdether,项目名称:LinFu,代码行数:17,代码来源:BaseInterceptor.cs


示例13: Intercept

        public object Intercept(IInvocationInfo info)
        {
            var methodName = info.TargetMethod.Name;

            Console.WriteLine("method '{0}' called", methodName);

            return info.TargetMethod;
        }
开发者ID:thlorenz,项目名称:WPFLinFu,代码行数:8,代码来源:MethodInterceptor.cs


示例14: GetPendingCalls

        public int GetPendingCalls(IInvocationInfo context)
        {
            int threadId = Thread.CurrentThread.ManagedThreadId;
            if (!_counts.ContainsKey(threadId))
                return 0;

            return _counts[threadId].GetPendingCalls(context);
        }
开发者ID:svgorbunov,项目名称:ScrollsModLoader,代码行数:8,代码来源:CallCounter.cs


示例15: CanReplace

        /// <summary>
        /// Determines whether or not the current method implementation can be replaced.
        /// </summary>
        /// <param name="host">The target instance of the method call.</param>
        /// <param name="context">The <see cref="IInvocationInfo"/> that describes the context of the method call.</param>
        /// <returns><c>true</c> if the method can be intercepted; otherwise, it will return <c>false</c>.</returns>
        public bool CanReplace(object host, IInvocationInfo context)
        {
            var pendingCalls = _counter.GetPendingCalls(context);

            if (pendingCalls > 0)
                return false;

            return ShouldReplace(host, context);
        }
开发者ID:jam231,项目名称:LinFu,代码行数:15,代码来源:BaseMethodReplacementProvider.cs


示例16: GetSurroundingImplementation

 /// <summary>
 /// Gets the surrounding implemetation for a given <see cref="IInvocationInfo">invocation context</see>.
 /// </summary>
 /// <param name="context">The context surrounding the method call.</param>
 /// <returns>The interceptor that will invoke around the method at runtime.</returns>
 public IAroundInvoke GetSurroundingImplementation(IInvocationInfo context)
 {
     var invokes = new HashSet<IAroundInvoke>();
     foreach (var invokePredicate in MethodInvokesAndPredicates.Where(x => x.Value != null && x.Value(context)))
     {
         invokes.Add(invokePredicate.Key);
     }
     return (invokes.Count > 0) ? new CompositeAroundInvoke(invokes) : null;
 }
开发者ID:Stoom,项目名称:LinFu,代码行数:14,代码来源:CompositeAroundInvokeProvider.cs


示例17: Intercept

 public object Intercept(IInvocationInfo info)
 {
     var methodName = info.TargetMethod.Name;
     Trace.WriteLine(String.Format("before: {0}", methodName));
     var result = info.TargetMethod.Invoke(info.Target, info.Arguments);
     result = (int)result * 2;
     Trace.WriteLine(String.Format("after: {0}", methodName));
     return result;
 }
开发者ID:KenVanGilbergen,项目名称:ken.Spikes.Aspects,代码行数:9,代码来源:MyInterceptor.cs


示例18: InvocationInfo

 public InvocationInfo(IInvocationInfo info)
 {
     target = info.Target;
     targetMethod = info.TargetMethod.Name;
     stackTrace = info.StackTrace;
     returnType = info.ReturnType;
     parameterTypes = info.ParameterTypes;
     typeArguments = info.TypeArguments;
     arguments = info.Arguments;
 }
开发者ID:kevinskyba,项目名称:ScrollsModLoader,代码行数:10,代码来源:BaseMod.cs


示例19: GetMethodReplacement

        /// <summary>
        /// Obtains the <see cref="IInterceptor"/> instance that will be used to replace the current method call.
        /// </summary>
        /// <param name="host">The target instance of the method call.</param>
        /// <param name="context">The <see cref="IInvocationInfo"/> that describes the context of the method call.</param>
        /// <returns>The interceptor that will intercept the method call itself.</returns>
        public IInterceptor GetMethodReplacement(object host, IInvocationInfo context)
        {
            var pendingCalls = _counter.GetPendingCalls(context);

            if (pendingCalls > 0)
                return null;

            var methodReplacement = GetReplacement(host, context);
            return new CountingInterceptor(_counter, methodReplacement);
        }
开发者ID:jam231,项目名称:LinFu,代码行数:16,代码来源:BaseMethodReplacementProvider.cs


示例20: Intercept

        public object Intercept(IInvocationInfo info)
        {
            var methodName = info.TargetMethod.Name;
            Console.WriteLine("method '{0}' called", methodName);

            // Replace the input parameter with 42
            var result = info.TargetMethod.Invoke(info.Target, new object[]{42});

            return result;
        }
开发者ID:jam231,项目名称:LinFu,代码行数:10,代码来源:Program.cs



注:本文中的IInvocationInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IInvoice类代码示例发布时间:2022-05-24
下一篇:
C# IInvocation类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap