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


C# RuntimeTypeHandle类代码示例

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


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

示例1: RunClassConstructor

		public static void RunClassConstructor (RuntimeTypeHandle type)
		{
			if (type.Value == IntPtr.Zero)
				throw new ArgumentException ("Handle is not initialized.", "type");

			RunClassConstructor (type.Value);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:RuntimeHelpers.Original.cs

示例2: TryGetGenericVirtualTargetForTypeAndSlot

        public unsafe override sealed bool TryGetGenericVirtualTargetForTypeAndSlot(RuntimeTypeHandle targetHandle, ref RuntimeTypeHandle declaringType, RuntimeTypeHandle[] genericArguments, ref string methodName, ref IntPtr methodSignature, out IntPtr methodPointer, out IntPtr dictionaryPointer, out bool slotUpdated)
        {
            MethodNameAndSignature methodNameAndSignature = new MethodNameAndSignature(methodName, methodSignature);

            #if REFLECTION_EXECUTION_TRACE
            ReflectionExecutionLogger.WriteLine("GVM resolution starting for " + GetTypeNameDebug(declaringType) + "." + methodNameAndSignature.Name + "(...)  on a target of type " + GetTypeNameDebug(targetHandle) + " ...");
            #endif

            if (RuntimeAugments.IsInterface(declaringType))
            {
                methodPointer = IntPtr.Zero;
                dictionaryPointer = IntPtr.Zero;

                slotUpdated = ResolveInterfaceGenericVirtualMethodSlot(targetHandle, ref declaringType, ref methodNameAndSignature);

                methodName = methodNameAndSignature.Name;
                methodSignature = methodNameAndSignature.Signature;
                return slotUpdated;
            }
            else
            {
                slotUpdated = false;
                return ResolveGenericVirtualMethodTarget(targetHandle, declaringType, genericArguments, methodNameAndSignature, out methodPointer, out dictionaryPointer);
            }
        }
开发者ID:tijoytom,项目名称:corert,代码行数:25,代码来源:ExecutionEnvironmentImplementation.GVMResolution.cs

示例3: FindMatchingInterfaceSlot

        private bool FindMatchingInterfaceSlot(IntPtr moduleHandle, NativeReader nativeLayoutReader, ref NativeParser entryParser, ref ExternalReferencesTable extRefs, ref RuntimeTypeHandle declaringType, ref MethodNameAndSignature methodNameAndSignature, RuntimeTypeHandle openTargetTypeHandle, RuntimeTypeHandle[] targetTypeInstantiation, bool variantDispatch)
        {
            uint numTargetImplementations = entryParser.GetUnsigned();

            for (uint j = 0; j < numTargetImplementations; j++)
            {
                uint nameAndSigToken = extRefs.GetRvaFromIndex(entryParser.GetUnsigned());
                MethodNameAndSignature targetMethodNameAndSignature = GetMethodNameAndSignatureFromNativeReader(nativeLayoutReader, nameAndSigToken);
                RuntimeTypeHandle targetTypeHandle = extRefs.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());

            #if REFLECTION_EXECUTION_TRACE
                ReflectionExecutionLogger.WriteLine("    Searching for GVM implementation on targe type = " + GetTypeNameDebug(targetTypeHandle));
            #endif

                uint numIfaceImpls = entryParser.GetUnsigned();

                for (uint k = 0; k < numIfaceImpls; k++)
                {
                    RuntimeTypeHandle implementingTypeHandle = extRefs.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());

                    uint numIfaceSigs = entryParser.GetUnsigned();

                    if (!openTargetTypeHandle.Equals(implementingTypeHandle))
                    {
                        // Skip over signatures data
                        for (uint l = 0; l < numIfaceSigs; l++)
                            entryParser.GetUnsigned();

                        continue;
                    }

                    for (uint l = 0; l < numIfaceSigs; l++)
                    {
                        RuntimeTypeHandle currentIfaceTypeHandle = default(RuntimeTypeHandle);

                        NativeParser ifaceSigParser = new NativeParser(nativeLayoutReader, extRefs.GetRvaFromIndex(entryParser.GetUnsigned()));
                        IntPtr currentIfaceSigPtr = ifaceSigParser.Reader.OffsetToAddress(ifaceSigParser.Offset);

                        if (TypeLoaderEnvironment.Instance.GetTypeFromSignatureAndContext(currentIfaceSigPtr, targetTypeInstantiation, null, out currentIfaceTypeHandle, out currentIfaceSigPtr))
                        {
                            Debug.Assert(!currentIfaceTypeHandle.IsNull());

                            if ((!variantDispatch && declaringType.Equals(currentIfaceTypeHandle)) ||
                                (variantDispatch && RuntimeAugments.IsAssignableFrom(declaringType, currentIfaceTypeHandle)))
                            {
            #if REFLECTION_EXECUTION_TRACE
                                ReflectionExecutionLogger.WriteLine("    " + (declaringType.Equals(currentIfaceTypeHandle) ? "Exact" : "Variant-compatible") + " match found on this target type!");
            #endif
                                // We found the GVM slot target for the input interface GVM call, so let's update the interface GVM slot and return success to the caller
                                declaringType = targetTypeHandle;
                                methodNameAndSignature = targetMethodNameAndSignature;
                                return true;
                            }
                        }
                    }
                }
            }

            return false;
        }
开发者ID:tijoytom,项目名称:corert,代码行数:60,代码来源:ExecutionEnvironmentImplementation.GVMResolution.cs

示例4: GetTypeFromHandle

        public static RuntimeType GetTypeFromHandle(RuntimeTypeHandle handle)
        {
            // handle is really a vtable
            VTable vtable = var.Cast<RuntimeTypeHandle>(handle).Cast<VTable>();

            return GetTypeFromClass(vtable.Class);
        }
开发者ID:sidecut,项目名称:xaeios,代码行数:7,代码来源:ReflectionHelpers.cs

示例5: SyntheticMethodInvoker

 public SyntheticMethodInvoker(RuntimeTypeHandle thisType, RuntimeTypeHandle[] parameterTypes, InvokerOptions options, Func<Object, Object[], Object> invoker)
 {
     _invoker = invoker;
     _options = options;
     _thisType = thisType;
     _parameterTypes = parameterTypes;
 }
开发者ID:noahfalk,项目名称:corert,代码行数:7,代码来源:SyntheticMethodInvoker.cs

示例6: CreateDelegate

 public override Delegate CreateDelegate(RuntimeTypeHandle delegateType, Object target, bool isStatic, bool isVirtual, bool isOpen)
 {
     return RuntimeAugments.CreateDelegate(
         delegateType,
         MethodInvokeInfo.LdFtnResult,
         target,
         isStatic: isStatic,
         isOpen: isOpen);
 }
开发者ID:noahfalk,项目名称:corert,代码行数:9,代码来源:MethodInvokerWithMethodInvokeInfo.cs

示例7: WriteJsonValueCore

        public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
        {
            DataContractSerializer dataContractSerializer = new DataContractSerializer(Type.GetTypeFromHandle(declaredTypeHandle),
                GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false); //  maxItemsInObjectGraph //  ignoreExtensionDataObject //  preserveObjectReferences

            MemoryStream memoryStream = new MemoryStream();
            dataContractSerializer.WriteObject(memoryStream, obj);
            memoryStream.Position = 0;
            string serialized = new StreamReader(memoryStream).ReadToEnd();
            jsonWriter.WriteString(serialized);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:11,代码来源:JsonXmlDataContract.cs

示例8: WriteJsonValueCore

 public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
 {
     if (IsULong)
     {
         jsonWriter.WriteUnsignedLong(((IConvertible)obj).ToUInt64(null));
     }
     else
     {
         jsonWriter.WriteLong(((IConvertible)obj).ToInt64(null));
     }
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:JsonEnumDataContract.cs

示例9: CreateMethodInvoker

 //
 // Creates the appropriate flavor of Invoker depending on the calling convention "shape" (static, instance or virtual.)
 //
 internal static MethodInvoker CreateMethodInvoker(MetadataReader reader, RuntimeTypeHandle declaringTypeHandle, MethodHandle methodHandle, MethodInvokeInfo methodInvokeInfo)
 {
     Method method = methodHandle.GetMethod(reader);
     MethodAttributes methodAttributes = method.Flags;
     if (0 != (methodAttributes & MethodAttributes.Static))
         return new StaticMethodInvoker(methodInvokeInfo);
     else if (methodInvokeInfo.VirtualResolveData != IntPtr.Zero)
         return new VirtualMethodInvoker(methodInvokeInfo, declaringTypeHandle);
     else
         return new InstanceMethodInvoker(methodInvokeInfo, declaringTypeHandle);
 }
开发者ID:noahfalk,项目名称:corert,代码行数:14,代码来源:MethodInvokerWithMethodInvokeInfo.cs

示例10: NullableInstanceMethodInvoker

        public NullableInstanceMethodInvoker(MetadataReader reader, MethodHandle methodHandle, RuntimeTypeHandle nullableTypeHandle, MethodInvokeInfo methodInvokeInfo)
        {
            _id = NullableMethodId.None;
            _nullableTypeHandle = nullableTypeHandle;
            Method method = methodHandle.GetMethod(reader);
            if (MethodAttributes.Public == (method.Flags & MethodAttributes.MemberAccessMask))
            {
                // Note: Since we control the definition of Nullable<>, we're not checking signatures here.
                String name = method.Name.GetConstantStringValue(reader).Value;
                switch (name)
                {
                    case "GetType":
                        _id = NullableMethodId.GetType;
                        break;

                    case "ToString":
                        _id = NullableMethodId.ToString;
                        break;

                    case "Equals":
                        _id = NullableMethodId.Equals;
                        break;

                    case "GetHashCode":
                        _id = NullableMethodId.GetHashCode;
                        break;

                    case ".ctor":
                        _id = NullableMethodId.Ctor;
                        break;

                    case "get_HasValue":
                        _id = NullableMethodId.get_HasValue;
                        break;

                    case "get_Value":
                        _id = NullableMethodId.get_Value;
                        break;

                    case "GetValueOrDefault":
                        IEnumerator<ParameterTypeSignatureHandle> parameters = method.Signature.GetMethodSignature(reader).Parameters.GetEnumerator();
                        if (parameters.MoveNext())
                            _id = NullableMethodId.GetValueOrDefault_1;
                        else
                            _id = NullableMethodId.GetValueOrDefault_0;
                        break;

                    default:
                        break;
                }
            }
        }
开发者ID:noahfalk,项目名称:corert,代码行数:52,代码来源:NullableInstanceMethodInvoker.cs

示例11: RunClassConstructor

        public static void RunClassConstructor(RuntimeTypeHandle type)
        {
            if (type.IsNull)
                throw new ArgumentException(SR.InvalidOperation_HandleIsNotInitialized);

            IntPtr pStaticClassConstructionContext = RuntimeAugments.Callbacks.TryGetStaticClassConstructionContext(type);
            if (pStaticClassConstructionContext == IntPtr.Zero)
                return;

            unsafe
            {
                ClassConstructorRunner.EnsureClassConstructorRun((StaticClassConstructionContext*)pStaticClassConstructionContext);
            }
        }
开发者ID:tijoytom,项目名称:corert,代码行数:14,代码来源:RuntimeHelpers.cs

示例12: InternalDeserialize

 internal override object InternalDeserialize(XmlReaderDelegator xmlReader, int declaredTypeID, RuntimeTypeHandle declaredTypeHandle, string name, string ns)
 {
     if (_mode == SerializationMode.SharedContract)
     {
         if (_serializationSurrogateProvider == null)
             return base.InternalDeserialize(xmlReader, declaredTypeID, declaredTypeHandle, name, ns);
         else
             return InternalDeserializeWithSurrogate(xmlReader, Type.GetTypeFromHandle(declaredTypeHandle), null /*surrogateDataContract*/, name, ns);
     }
     else
     {
         return InternalDeserializeInSharedTypeMode(xmlReader, declaredTypeID, Type.GetTypeFromHandle(declaredTypeHandle), name, ns);
     }
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:14,代码来源:XmlObjectSerializerReadContextComplex.cs

示例13: TryGetConstructedGenericTypeComponents

        public static bool TryGetConstructedGenericTypeComponents(RuntimeTypeHandle runtimeTypeHandle, out RuntimeTypeHandle genericTypeDefinitionHandle, out RuntimeTypeHandle[] genericTypeArgumentHandles)
        {
            genericTypeDefinitionHandle = default(RuntimeTypeHandle);
            genericTypeArgumentHandles = null;

            // Check the regular tables first.
            if (ReflectionExecution.ExecutionEnvironment.TryGetConstructedGenericTypeComponents(runtimeTypeHandle, out genericTypeDefinitionHandle, out genericTypeArgumentHandles))
                return true;

            // Now check the diagnostic tables.
            if (ReflectionExecution.ExecutionEnvironment.TryGetConstructedGenericTypeComponentsDiag(runtimeTypeHandle, out genericTypeDefinitionHandle, out genericTypeArgumentHandles))
                return true;

            return false;
        }
开发者ID:tijoytom,项目名称:corert,代码行数:15,代码来源:DiagnosticMappingTables.cs

示例14: CreateDelegate

 public override sealed Delegate CreateDelegate(RuntimeTypeHandle delegateType, Object target, bool isStatic, bool isVirtual, bool isOpen)
 {
     if (isOpen)
     {
         return RuntimeAugments.CreateDelegate(
             delegateType,
             new OpenMethodResolver(_declaringTypeHandle, MethodInvokeInfo.LdFtnResult, 0).ToIntPtr(),
             target,
             isStatic: isStatic,
             isOpen: isOpen);
     }
     else
     {
         return base.CreateDelegate(delegateType, target, isStatic, isVirtual, isOpen);
     }
 }
开发者ID:tijoytom,项目名称:corert,代码行数:16,代码来源:InstanceMethodInvoker.cs

示例15: ValidateThis

        public static void ValidateThis(Object thisObject, RuntimeTypeHandle declaringTypeHandle)
        {
            if (thisObject == null)
                throw new TargetException(SR.RFLCT_Targ_StatMethReqTarg);
            RuntimeTypeHandle srcTypeHandle = thisObject.GetType().TypeHandle;
            if (RuntimeAugments.IsAssignableFrom(declaringTypeHandle, srcTypeHandle))
                return;

            if (RuntimeAugments.IsInterface(declaringTypeHandle))
            {
                if (RuntimeAugments.IsInstanceOfInterface(thisObject, declaringTypeHandle))
                    return;
            }

            throw new TargetException(SR.RFLCT_Targ_ITargMismatch);
        }
开发者ID:krytarowski,项目名称:corert,代码行数:16,代码来源:MethodInvokerUtils.cs


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