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


C# MethodBase.GetType方法代码示例

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


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

示例1: NetFunction

 /// <summary>
 /// Initializes a new instance of the <see cref="axScript3.NetFunction"/> class.
 /// </summary>
 /// <param name='function'>
 /// Function.
 /// </param>
 /// <param name='target'>
 /// Owner of function, leave null if static function.
 /// </param>
 public NetFunction(MethodBase function, object target = null)
 {
     Method = function;
     Inputs = function.GetParameters();
     Output = function.GetType();
     Target = target;
     HasParamArray = Inputs.Length > 0 && Inputs[Inputs.Length - 1].GetCustomAttributes(typeof (ParamArrayAttribute), false).Length > 0;
 }
开发者ID:elliotharris,项目名称:AxScript,代码行数:17,代码来源:NetFunction.cs

示例2: EmitFunction

        private static Function EmitFunction(Module module, MethodBase method)
        {
            var methodInfo = method as MethodInfo;
            var methodConstructor = method as ConstructorInfo;
            var declaringType = method.DeclaringType;
            if (methodInfo == null && methodConstructor == null)
                throw new CudaSharpException("Unknown MethodBase type " + method.GetType().FullName);
            if (declaringType == null)
                throw new CudaSharpException("Could not find the declaring type of " + method.Name.StripNameToValidPtx());

            var parameters = method.GetParameters().Select(p => p.ParameterType);
            if (methodConstructor != null)
                parameters = new[] { declaringType.MakeByRefType() }.Concat(parameters);
            if (methodInfo != null && methodInfo.IsStatic == false)
            {
                if (declaringType.IsValueType == false)
                    throw new CudaSharpException("Cannot compile object instance methods (did you forget to mark the method as static?)");
                parameters = new[] { declaringType.MakeByRefType() }.Concat(parameters);
            }
            var llvmParameters =
                parameters.Select(t => ConvertType(module, t)).ToArray();
            var funcType = new FunctionType(ConvertType(module, methodInfo == null ? typeof(void) : methodInfo.ReturnType), llvmParameters);

            var intrinsic = method.GetCustomAttribute<Gpu.BuiltinAttribute>();
            if (intrinsic != null)
            {
                var name = intrinsic.Intrinsic;
                var preExisting = module.GetFunction(name);
                if (preExisting != null)
                    return preExisting;
                return module.CreateFunction(name, funcType);
            }

            var function = module.CreateFunction(methodConstructor == null ? method.Name.StripNameToValidPtx() : declaringType.Name.StripNameToValidPtx() + "_ctor", funcType);

            var block = new Block("entry", module.Context, function);
            var writer = new InstructionBuilder(module.Context, block);

            var opcodes = method.Disassemble().ToList();
            FindBranchTargets(opcodes, module.Context, function);

            var body = method.GetMethodBody();
            var efo = new EmitFuncObj(module, function, body, writer, null, new Stack<Value>(),
                body == null ? null : new Value[body.LocalVariables.Count], new Value[llvmParameters.Length]);

            PrintHeader(efo);
            foreach (var opcode in opcodes)
            {
                if (EmitFunctions.ContainsKey(opcode.Opcode) == false)
                    throw new CudaSharpException("Unsupported CIL instruction " + opcode.Opcode);
                var func = EmitFunctions[opcode.Opcode];
                efo.Argument = opcode.Parameter;
                func(efo);
            }

            return function;
        }
开发者ID:rabbitsmith,项目名称:CudaSharp,代码行数:57,代码来源:Translator.cs

示例3: IsInternalFrame

        public static bool IsInternalFrame(MethodBase mb) {
            //All the dynamic methods created for DLR rules have a special name.
            //We also check if the method has a different type than the known
            //non-static method. If it does, it is a dynamic method.
            //This could be improved if the CLR provides a way to attach some information
            //to the dynamic method we create, like CustomAttributes.
            if (mb.Name == "CallSite.Target" && mb.GetType() != _knownNonDynamicMethodType) {
                return true;
            }

            //Filter out the helper methods.
            if (mb.DeclaringType == typeof(System.Dynamic.UpdateDelegates)) {
                return true;
            }

            return false;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:17,代码来源:CallSiteHelpers.cs

示例4: Create

        public static MethodBodyInfo Create(MethodBase method)
        {
            MethodBodyInfo mbi = new MethodBodyInfo();

            mbi.Identity = method.GetHashCode();
            mbi.TypeName = method.GetType().Name;
            mbi.MethodToString = ".method " + method.ToIL();

            ILReader reader = ILReaderFactory.Create(method);
            mbi.Exceptions = reader.ILProvider.GetExceptionInfos();

            ReadableILStringVisitor visitor = new ReadableILStringVisitor(
                new MethodBodyInfoBuilder(mbi),
                DefaultFormatProvider.Instance);

            reader.Accept(visitor);

            return mbi;
        }
开发者ID:taolin123,项目名称:ExpressionFutures,代码行数:19,代码来源:MethodBodyInfo.cs

示例5: CreateMethod

 private void CreateMethod(Type aType, Classifier aCls, MethodBase aMethod, PdOOM.BasePackage aPckg, Operation anOper, InfluenceTable anInfTable)
 {
     Operation operation;
     if (anOper != null)
     {
         operation = anOper;
     }
     else
     {
         operation = (Operation) aCls.CreateObject(0x18112066, "", -1, true);
     }
     operation.Static = aMethod.IsStatic;
     operation.Visibility = GetMethodVisibility(aMethod);
     operation.Final = aMethod.IsFinal;
     if (aMethod.IsGenericMethod)
     {
         operation.Generic = true;
         foreach (TypeParameter parameter in operation.TypeParameters)
         {
             parameter.delete();
         }
         foreach (Type type in aMethod.GetGenericArguments())
         {
             TypeParameter parameter2 = (TypeParameter) operation.CreateObject(0x1811207d, "", -1, true);
             this.ProcessType(type, false);
             TypeMapping mapping = TypeMapping.Retrieve(type);
             parameter2.Name = parameter2.Code = mapping.Name;
             operation.TypeParameters.Add(parameter2);
         }
     }
     if (aMethod.IsVirtual)
     {
         if (LZ.Reverse.Info._bVBNet)
         {
             operation.SetExtendedAttribute("VB.NET.Overridable", "true");
         }
         else
         {
             operation.SetExtendedAttribute("C#.virtual", "true");
         }
     }
     if (aMethod.IsAbstract)
     {
         operation.Abstract = true;
     }
     new CustomHandlerMethod(aMethod, operation).Convert();
     if (anOper == null)
     {
         foreach (ParameterInfo info in aMethod.GetParameters())
         {
             this.AddParameter(operation, info, aPckg);
         }
     }
     bool flag = aMethod.IsConstructor || aMethod.GetType().IsSubclassOf(typeof(ConstructorInfo));
     if (!flag)
     {
         MethodInfo info2 = (MethodInfo) aMethod;
         Type returnType = info2.ReturnType;
         if (returnType.IsArray)
         {
             operation.Array = true;
             returnType = returnType.GetElementType();
         }
         this.ProcessType(returnType, false);
         TypeMapping mapping2 = TypeMapping.Retrieve(returnType);
         if (mapping2.HasClassifier())
         {
             PdOOM.BaseObject obj2 = ProperRef.Link(NamespaceMapping.Retrieve(aPckg), mapping2);
             operation.UseQualifiedDataType = false;
             operation.ReturnTypeObject = obj2;
         }
         else
         {
             operation.ReturnType = mapping2.Name;
         }
         if ((anInfTable != null) && anInfTable.Contains(info2))
         {
             anInfTable.Impact(info2, operation);
         }
         if (LZ.Reverse.Info._bVBNet)
         {
             new CustomHandlerReturn(info2, anOper).Convert();
         }
         bool flag2 = false;
         if (!info2.IsHideBySig && info2.GetBaseDefinition().Equals(info2))
         {
             string name = info2.Name;
             if (!aType.BaseType.Equals(aType))
             {
                 BindingFlags bindingAttr = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly;
                 bool flag3 = false;
                 foreach (MethodInfo info3 in aType.GetMethods(bindingAttr))
                 {
                     if (info3.Name == name)
                     {
                         flag3 = true;
                         break;
                     }
                 }
                 if (flag3)
//.........这里部分代码省略.........
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:101,代码来源:Reverser.cs

示例6: GetMethodReturnType

 // Return the type of the returned value of the method:
 private static Type GetMethodReturnType(MethodBase method)
 {
     MethodInfo info = method as MethodInfo;
     if (info == null)
     {
         throw new ArgumentException("Unsupported MethodBase : " + method.GetType().Name, "method");
     }
     return info.ReturnType;
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:10,代码来源:MyReflectionMethod.cs

示例7: GetMethodBaseChildren

		private void GetMethodBaseChildren (NodeInfoCollection c, NodeInfo parent, MethodBase mb)
		{
			AddSubnodes (c, parent, mb.GetType(), mb);
		}
开发者ID:emtees,项目名称:old-code,代码行数:4,代码来源:ReflectionNodeFinder.cs

示例8: GetMethodReturnType

 private static Type GetMethodReturnType(MethodBase method)
 {
     var methodInfo = method as MethodInfo;
     if (methodInfo == null)
     {
         // Constructor info.
         throw new ArgumentException("Unsupported MethodBase : " + method.GetType().Name, "method");
     }
     return methodInfo.ReturnType;
 }
开发者ID:castroev,项目名称:StardriveBlackBox-verRadicalElements-,代码行数:10,代码来源:MethodUtil.cs

示例9: ReadInstructions

        public List<IlInstruction> ReadInstructions(MethodBase method)
        {
            ilInstructions = new List<IlInstruction>();
            this.currentMethod = method;

            var body = method.GetMethodBody();
            parameters = method.GetParameters();
            if (body == null)
                return ilInstructions;
            locals = body.LocalVariables;
            instructions = method.GetMethodBody().GetILAsByteArray();
            var str = new ByteStream(instructions, instructions.Length);
            stream = new BinaryReader(str);

            if (!(typeof(ConstructorInfo).IsAssignableFrom(method.GetType())))
                methodArgs = method.GetGenericArguments();

            if (method.DeclaringType != null)
                typeArgs = method.DeclaringType.GetGenericArguments();

            IlInstruction instruction = null;

            while (stream.BaseStream.Position < stream.BaseStream.Length)
            {
                instruction = new IlInstruction();
                bool isDoubleByte = false;
                OpCode code = ReadOpCode(ref isDoubleByte);
                instruction.OpCode = code;
                instruction.Offset = stream.BaseStream.Position-1;
                if (isDoubleByte)
                {
                    instruction.Offset--;
                }
                instruction.Operand = ReadOperand(code, method.Module,ref instruction.LocalVariableIndex);
                ilInstructions.Add(instruction);
            }

            return ilInstructions;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:39,代码来源:IlReader.cs

示例10: GetMethod

        private static void GetMethod(MethodDescription md,MethodBase mi, string NickName,string returnName)
        {
            md.Method = mi;
            md.InputArgs = new List<MethodFieldDescription>();
            md.Output = null;
            md.RawType = mi.GetType();
            md.TypeName = GeneratorHelper.GetTypeName(md.RawType);
            md.Name = mi.Name;
            md.NickName = string.IsNullOrEmpty(NickName) ? md.Name : NickName;
            md.IsStatic = mi.IsStatic;

            foreach (ParameterInfo pi in md.Method.GetParameters())
            {
                MethodFieldDescription mfd = new MethodFieldDescription();
                mfd.Name = pi.Name;
                mfd.RawType = pi.ParameterType;
                mfd.TypeName = GeneratorHelper.GetTypeName(mfd.RawType);
                mfd.IsStatic = false;
                mfd.Type = GetMessageFieldType(mfd.RawType);
                md.InputArgs.Add(mfd);
            }

            MethodInfo mii = md.Method as MethodInfo;
            if (null != mii)
            {
                if (!string.Equals(mii.ReturnType.FullName, "System.Void"))
                {
                    MethodFieldDescription mfd = new MethodFieldDescription();
                    mfd.Name = returnName;
                    mfd.RawType = mii.ReturnType;
                    mfd.TypeName = GeneratorHelper.GetTypeName(mfd.RawType);
                    mfd.IsStatic = false;
                    mfd.Type = GetMessageFieldType(mfd.RawType);
                    md.Output = mfd;
                }
            }
        }
开发者ID:huiguochen,项目名称:Lua4Net,代码行数:37,代码来源:DescriptionGenerator.cs

示例11: IsDynamicOrRTDynamicMethod

 public static bool IsDynamicOrRTDynamicMethod(MethodBase method)
 {
     Type type = method.GetType();
     return rtDynamicMethodType.Equals(type) || dynamicMethodType.Equals(type);
 }
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:5,代码来源:DynamicMethodHelper.cs

示例12: IsRTDynamicMethod

 public static bool IsRTDynamicMethod(MethodBase method)
 {
     return rtDynamicMethodType.Equals(method.GetType());
 }
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:4,代码来源:DynamicMethodHelper.cs

示例13: ILReader

            public ILReader(MethodBase method)
            {
                if (method == null)
                {
                    throw new ArgumentNullException("method");
                }

                Type rtType = method.GetType();
                if (rtType != s_runtimeMethodInfoType && rtType != s_runtimeConstructorInfoType)
                {
                    throw new ArgumentException("method must be RuntimeMethodInfo or RuntimeConstructorInfo for this constructor.");
                }

                m_ilProvider = new MethodBaseILProvider(method);
                m_resolver = new ModuleScopeTokenResolver(method);
                InstructionBytes = m_ilProvider.GetByteArray();
                m_position = 0;
            }
开发者ID:kthompson,项目名称:CoffeeScript,代码行数:18,代码来源:MethodDumper.cs

示例14: Create

 public static MethodBodyInfo Create(MethodBase method)
 {
     MethodBodyInfo mbi = new MethodBodyInfo();
       mbi.Identity = method.GetHashCode();
       mbi.TypeName = method.GetType().Name;
       mbi.MethodToString = method.ToString();
       ReadableILStringVisitor readableIlStringVisitor = new ReadableILStringVisitor((IILStringCollector) new MethodBodyInfo.MethodBodyInfoBuilder(mbi), (IFormatProvider) DefaultFormatProvider.Instance);
       new ILReader(method).Accept((ILInstructionVisitor) readableIlStringVisitor);
       return mbi;
 }
开发者ID:jklipp,项目名称:codegravity,代码行数:10,代码来源:MethodBodyInfo.cs


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