本文整理汇总了C#中RuntimeTypeHandle类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeTypeHandle类的具体用法?C# RuntimeTypeHandle怎么用?C# RuntimeTypeHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeTypeHandle类属于命名空间,在下文中一共展示了RuntimeTypeHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: EdmProperty
/// <summary>
/// Initializes a new OSpace instance of the property class
/// </summary>
/// <param name="name">name of the property</param>
/// <param name="typeUsage">TypeUsage object containing the property type and its facets</param>
/// <param name="propertyInfo">for the property</param>
/// <param name="entityDeclaringType">The declaring type of the entity containing the property</param>
internal EdmProperty(string name, TypeUsage typeUsage, PropertyInfo propertyInfo, RuntimeTypeHandle entityDeclaringType)
: this(name, typeUsage)
{
Debug.Assert(name == propertyInfo.Name, "different PropertyName");
if (null != propertyInfo)
{
MethodInfo method;
method = propertyInfo.GetGetMethod(true); // return public or non-public getter
PropertyGetterHandle = ((null != method) ? method.MethodHandle : default(RuntimeMethodHandle));
method = propertyInfo.GetSetMethod(true); // return public or non-public getter
PropertySetterHandle = ((null != method) ? method.MethodHandle : default(RuntimeMethodHandle));
EntityDeclaringType = entityDeclaringType;
}
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:24,代码来源:EdmProperty.cs
示例17: GetMethodFromHandle
//
// This overload of GetMethodHandle can handle all method handles.
//
public sealed override MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle)
{
ExecutionEnvironment executionEnvironment = ReflectionCoreExecution.ExecutionEnvironment;
MethodHandle methodHandle;
RuntimeTypeHandle[] genericMethodTypeArgumentHandles;
if (!executionEnvironment.TryGetMethodFromHandleAndType(runtimeMethodHandle, declaringTypeHandle, out methodHandle, out genericMethodTypeArgumentHandles))
{
// This may be a method declared on a non-generic type: this api accepts that too so try the other table.
RuntimeTypeHandle actualDeclaringTypeHandle;
if (!executionEnvironment.TryGetMethodFromHandle(runtimeMethodHandle, out actualDeclaringTypeHandle, out methodHandle, out genericMethodTypeArgumentHandles))
throw new ArgumentException(SR.Argument_InvalidHandle);
if (!actualDeclaringTypeHandle.Equals(declaringTypeHandle))
throw new ArgumentException(SR.Format(SR.Argument_ResolveMethodHandle,
ReflectionCoreNonPortable.GetTypeForRuntimeTypeHandle(declaringTypeHandle),
ReflectionCoreNonPortable.GetTypeForRuntimeTypeHandle(actualDeclaringTypeHandle)));
}
MethodBase methodBase = ReflectionCoreExecution.ExecutionDomain.GetMethod(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles);
return methodBase;
}
开发者ID:noahfalk,项目名称:corert,代码行数:23,代码来源:ReflectionCoreCallbacksImplementation.cs
示例18: TryGetDiagnosticStringForNamedType
// Get the diagnostic name string for a type. This attempts to reformat the string into something that is essentially human readable.
// Returns true if the function is successful.
// runtimeTypeHandle represents the type to get a name for
// diagnosticName is the name that is returned
//
// the genericParameterOffsets list is an optional parameter that contains the list of the locations of where generic parameters may be inserted
// to make the string represent an instantiated generic.
//
// For example for Dictionary<K,V>, metadata names the type Dictionary`2, but this function will return Dictionary<,>
// For consumers of this function that will be inserting generic arguments, the genericParameterOffsets list is used to find where to insert the generic parameter name.
//
// That isn't all that interesting for Dictionary, but it becomes substantially more interesting for nested generic types, or types which are compiler named as
// those may contain embedded <> pairs and such.
public static bool TryGetDiagnosticStringForNamedType(RuntimeTypeHandle runtimeTypeHandle, out String diagnosticName, List<int> genericParameterOffsets)
{
diagnosticName = null;
ExecutionEnvironmentImplementation executionEnvironment = ReflectionExecution.ExecutionEnvironment;
MetadataReader reader;
TypeReferenceHandle typeReferenceHandle;
if (executionEnvironment.TryGetTypeReferenceForNamedType(runtimeTypeHandle, out reader, out typeReferenceHandle))
{
diagnosticName = GetTypeFullNameFromTypeRef(typeReferenceHandle, reader, genericParameterOffsets);
return true;
}
TypeDefinitionHandle typeDefinitionHandle;
if (executionEnvironment.TryGetMetadataForNamedType(runtimeTypeHandle, out reader, out typeDefinitionHandle))
{
diagnosticName = GetTypeFullNameFromTypeDef(typeDefinitionHandle, reader, genericParameterOffsets);
return true;
}
return false;
}
开发者ID:noahfalk,项目名称:corert,代码行数:34,代码来源:DiagnosticMappingTables.cs
示例19: 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 Object supports ICastable interface and the declaringType is interface
// try to call ICastable.IsInstanceOfInterface to determine whether object suppport declaringType interface
if (RuntimeAugments.IsInterface(declaringTypeHandle))
{
ICastable castable = thisObject as ICastable;
Exception castError;
// ICastable.IsInstanceOfInterface isn't supposed to throw exception
if (castable != null && castable.IsInstanceOfInterface(declaringTypeHandle, out castError))
return;
}
throw new TargetException(SR.RFLCT_Targ_ITargMismatch);
}
开发者ID:tijoytom,项目名称:corert,代码行数:22,代码来源:MethodInvokerUtils.cs
示例20: Main
public static int Main(String[] args)
{
Type t = typeof(int);
Type t2 = typeof(long);
RuntimeTypeHandle th = t.TypeHandle;
RuntimeTypeHandle th2 = t2.TypeHandle;
Console.WriteLine(th.Equals(th2));
Console.WriteLine(th.Equals(th));
RuntimeTypeHandle[] arr = new RuntimeTypeHandle[2];
arr[0] = t.TypeHandle;
arr[1] = t2.TypeHandle;
if (arr[0].Equals(arr[1]))
{
Console.WriteLine("ERR");
return 0;
}
return 100;
}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:22,代码来源:b11553.cs
注:本文中的RuntimeTypeHandle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论