本文整理汇总了C#中IReflect.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IReflect.GetType方法的具体用法?C# IReflect.GetType怎么用?C# IReflect.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReflect
的用法示例。
在下文中一共展示了IReflect.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToType
internal static Type ToType(IReflect ir){
if (ir is Type)
return (Type)ir;
if (ir is ClassScope)
return ((ClassScope)ir).GetTypeBuilderOrEnumBuilder();
if (ir is TypedArray){
return ((TypedArray)ir).ToType();
}
if (ir is ScriptFunction)
return Typeob.ScriptFunction;
return ir.GetType();
}
示例2: ToType
internal static Type ToType(TypeReferences typeRefs, IReflect ir){
if (ir is Type)
return (Type)ir;
if (ir is ClassScope)
return ((ClassScope)ir).GetTypeBuilderOrEnumBuilder();
if (ir is TypedArray){
return typeRefs.ToReferenceContext(((TypedArray)ir).ToType());
}
if (ir is ScriptFunction)
return typeRefs.ScriptFunction;
return typeRefs.ToReferenceContext(ir.GetType());
}
示例3: IsPromotableTo
internal static bool IsPromotableTo(IReflect source_ir, IReflect target_ir){
Type target_type;
if (source_ir is TypedArray || target_ir is TypedArray ||
source_ir is ArrayObject || target_ir is ArrayObject ||
source_ir == Typeob.ArrayObject || target_ir == Typeob.ArrayObject)
return Convert.IsPromotableToArray(source_ir, target_ir);
if (target_ir is ClassScope){
if (((ClassScope)target_ir).owner is EnumDeclaration){
if (Convert.IsPrimitiveNumericType(source_ir))
return IsPromotableTo(source_ir, ((EnumDeclaration)((ClassScope)target_ir).owner).baseType.ToType());
else if (source_ir == Typeob.String) return true;
else if (source_ir == target_ir) return true;
return false;
}
if (source_ir is ClassScope)
return (((ClassScope)source_ir).IsSameOrDerivedFrom((ClassScope)target_ir));
return false; //The source is not in the same compilation unit. Thus it can only extend the target type if there is a circular dependency and separate compilation. Can't handle that.
}else if (target_ir is Type){
if (target_ir == Typeob.Object) return !(source_ir is Type) || !((Type)source_ir).IsByRef;
target_type = (Type)target_ir;
}else if (target_ir is ScriptFunction)
target_type = Typeob.ScriptFunction;
else
//assert that target_ir is JSObject
target_type = target_ir.GetType();
if (source_ir is ClassScope)
return ((ClassScope)source_ir).IsPromotableTo(target_type);
else
return IsPromotableTo(source_ir is Type ? (Type)source_ir : source_ir.GetType(), target_type);
}
示例4: IsPromotableTo
internal static bool IsPromotableTo(IReflect source_ir, IReflect target_ir)
{
Type scriptFunction;
if ((((source_ir is TypedArray) || (target_ir is TypedArray)) || ((source_ir is ArrayObject) || (target_ir is ArrayObject))) || ((source_ir == Typeob.ArrayObject) || (target_ir == Typeob.ArrayObject)))
{
return IsPromotableToArray(source_ir, target_ir);
}
if (target_ir is ClassScope)
{
if (((ClassScope) target_ir).owner is EnumDeclaration)
{
if (IsPrimitiveNumericType(source_ir))
{
return IsPromotableTo(source_ir, ((EnumDeclaration) ((ClassScope) target_ir).owner).baseType.ToType());
}
return ((source_ir == Typeob.String) || (source_ir == target_ir));
}
return ((source_ir is ClassScope) && ((ClassScope) source_ir).IsSameOrDerivedFrom((ClassScope) target_ir));
}
if (target_ir is Type)
{
if (target_ir == Typeob.Object)
{
if (source_ir is Type)
{
return !((Type) source_ir).IsByRef;
}
return true;
}
scriptFunction = (Type) target_ir;
}
else if (target_ir is ScriptFunction)
{
scriptFunction = Typeob.ScriptFunction;
}
else
{
scriptFunction = Globals.TypeRefs.ToReferenceContext(target_ir.GetType());
}
if (source_ir is ClassScope)
{
return ((ClassScope) source_ir).IsPromotableTo(scriptFunction);
}
return IsPromotableTo((source_ir is Type) ? ((Type) source_ir) : Globals.TypeRefs.ToReferenceContext(source_ir.GetType()), scriptFunction);
}