예제 #1
0
 public static ProtoTypeCode GetTypeCode(IKVM.Reflection.Type type)
 {
     TypeCode code = IKVM.Reflection.Type.GetTypeCode(type);
     switch (code)
     {
         case TypeCode.Empty:
         case TypeCode.Boolean:
         case TypeCode.Char:
         case TypeCode.SByte:
         case TypeCode.Byte:
         case TypeCode.Int16:
         case TypeCode.UInt16:
         case TypeCode.Int32:
         case TypeCode.UInt32:
         case TypeCode.Int64:
         case TypeCode.UInt64:
         case TypeCode.Single:
         case TypeCode.Double:
         case TypeCode.Decimal:
         case TypeCode.DateTime:
         case TypeCode.String:
             return (ProtoTypeCode)code;
     }
     switch(type.FullName)
     {
         case "System.TimeSpan": return ProtoTypeCode.TimeSpan;
         case "System.Guid": return ProtoTypeCode.Guid;
         case "System.Uri": return ProtoTypeCode.Uri;
         case "System.Byte[]": return ProtoTypeCode.ByteArray;
         case "System.Type": return ProtoTypeCode.Type;
     }
     return ProtoTypeCode.Unknown;
 }
예제 #2
0
 internal static IKVM.Reflection.Type GetUnderlyingType(IKVM.Reflection.Type type)
 {
     if (type.IsValueType && type.IsGenericType && type.GetGenericTypeDefinition().FullName == "System.Nullable`1")
     {
         return type.GetGenericArguments()[0];
     }
     return null;
 }
예제 #3
0
        public static IEnumerable <Type> GetTypeChain(this IKVM.Reflection.Type node)
        {
            while (node != null)
            {
                yield return(node);

                node = node.BaseType;
            }
        }
예제 #4
0
 public static ProtoTypeCode GetTypeCode(IKVM.Reflection.Type type)
 {
     return(Helpers.GetTypeCode(type));
 }