当前位置: 首页>>代码示例>>C#>>正文


C# TypeDefinition.Is方法代码示例

本文整理汇总了C#中Mono.Cecil.TypeDefinition.Is方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition.Is方法的具体用法?C# TypeDefinition.Is怎么用?C# TypeDefinition.Is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.TypeDefinition的用法示例。


在下文中一共展示了TypeDefinition.Is方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessType

        public override void ProcessType(TypeDefinition type)
        {
            if (!type.Is (Namespaces.ObjCRuntime, "Runtime"))
                return;

            foreach (MethodDefinition m in type.Methods) {
                if (!m.IsStatic || m.Name != "CreateRegistrar" || !m.HasParameters || m.Parameters.Count != 1)
                    continue;
                OptimizeRegistrar (m);
            }
        }
开发者ID:yudhitech,项目名称:xamarin-macios,代码行数:11,代码来源:RemoveExtraRegistrar.cs

示例2: ProcessType

        public override void ProcessType(TypeDefinition type)
        {
            if (!type.Is ("ObjCRuntime", "RuntimeOptions"))
                return;

            MethodDefinition method = type.Methods.First (x => x.Name == "GetHttpMessageHandler" && !x.HasParameters);

            AssemblyDefinition systemNetHTTPAssembly = context.GetAssemblies ().First (x => x.Name.Name == "System.Net.Http");
            TypeDefinition handler = RuntimeOptions.GetHttpMessageHandler (Options.RuntimeOptions, systemNetHTTPAssembly.MainModule, type.Module);
            MethodReference handler_ctor = handler.Methods.First (x => x.IsConstructor && !x.HasParameters && !x.IsStatic);

            // HttpClientHandler is defined not in Xamarin.Mac.dll so we need to import
            if (handler.Name.Contains ("HttpClientHandler"))
                handler_ctor = type.Module.Import (handler_ctor);

            var body = new MethodBody (method);
            var il = body.GetILProcessor ();
            il.Emit (OpCodes.Newobj, handler_ctor);
            il.Emit (OpCodes.Ret);
            method.Body = body;
        }
开发者ID:yudhitech,项目名称:xamarin-macios,代码行数:21,代码来源:CoreHttpMessageHandler.cs

示例3: ProcessType

        public override void ProcessType(TypeDefinition type)
        {
            #if XAMARIN_NO_TLS
            return;
            #else
            if (!type.Is (Namespaces.ObjCRuntime, "Runtime"))
                return;

            MethodDefinition callbackMethod = null;

            foreach (var m in type.Methods) {
                if (!m.IsStatic || m.HasParameters)
                    continue;
                if (m.Name.Equals ("TlsProviderFactoryCallback", StringComparison.Ordinal)) {
                    callbackMethod = m;
                    break;
                }
            }

            if (callbackMethod == null)
                throw new Exception ("Could not set the default TlsProvider");

            var providerCtor = FindProviderConstructor (type.Module);
            if (providerCtor == null)
                return;

            // re-write TlsProviderFactoryCallback()
            var body = new MethodBody (callbackMethod);
            var il = body.GetILProcessor ();
            if (providerCtor != null)
                il.Emit (OpCodes.Newobj, providerCtor);
            else
                il.Emit (OpCodes.Ldnull);
            il.Emit (OpCodes.Ret);
            callbackMethod.Body = body;
            #endif
        }
开发者ID:yudhitech,项目名称:xamarin-macios,代码行数:37,代码来源:CoreTlsProviderStep.cs

示例4: ProcessType

        public override void ProcessType(TypeDefinition type)
        {
            // no code to remove in interfaces, skip processing
            if (type.IsInterface)
                return;

            // [MonoTouch.]ObjCRuntime.Runtime.RegisterEntryAssembly is needed only for the simulator
            // and does not have to be preserved on devices
            if (product) {
                if (Device && type.Is (Namespaces.ObjCRuntime, "Runtime")) {
                    foreach (var m in type.Methods) {
                        if (m.Name == "RegisterEntryAssembly") {
                            ProcessMethod (m);
                            type.Module.Import (get_nse);
                        }
                    }
                }
                // Remove the warning that we show (console) if someone subclass UIButton using the UIButtonType ctor
                // https://trello.com/c/Nf2B8mIM/484-remove-debug-code-in-the-linker
                if (!Debug && type.Is (Namespaces.UIKit, "UIButton")) {
                    foreach (var m in type.Methods) {
                        if (m.IsConstructor && m.HasParameters && m.Parameters [0].ParameterType.Is (Namespaces.UIKit, "UIButtonType"))
                            ProcessUIButtonCtor (m);
                    }
                }
                // all other candidates are in mscorlib.dll (not the product .dll)
                return;
            }

            if (!IsCandidate (type))
                return;

            ProcessMethods (type);
            if (type.HasNestedTypes) {
                foreach (TypeDefinition nested in type.NestedTypes)
                    ProcessMethods (nested);
            }
        }
开发者ID:yudhitech,项目名称:xamarin-macios,代码行数:38,代码来源:RemoveCode.cs


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