Beispiel #1
0
 private static string generateGenericArguments(string typeString)
 {
     string[] separator = new string[1] {
         ", "
     };
     typeString = Regex.Replace(typeString, "<(?<arg>.*)>", (MatchEvaluator)(m =>
     {
         string typeString1 = SerializationTypeExtension.generateTypeString(m.Groups["arg"].Value);
         return("`" + (object)typeString1.Split(separator, StringSplitOptions.None).Length + "[" + typeString1 + "]");
     }));
     return(typeString);
 }
Beispiel #2
0
        private static string generateTypeString(string typeString)
        {
            if (SerializationTypeExtension._builtInTypeStrings.ContainsKey(typeString))
            {
                typeString = SerializationTypeExtension._builtInTypeStrings[typeString];
            }
            else
            {
                typeString = SerializationTypeExtension.generateGenericArguments(typeString);
                typeString = SerializationTypeExtension.generateArray(typeString);
            }

            return(typeString);
        }
Beispiel #3
0
        public static Type ToType(this string typeString)
        {
            string typeString1 = SerializationTypeExtension.generateTypeString(typeString);
            Type   type1       = Type.GetType(typeString1);

            if (type1 != null)
            {
                return(type1);
            }
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                Type type2 = assembly.GetType(typeString1);
                if (type2 != null)
                {
                    return(type2);
                }
            }

            return((Type)null);
        }
Beispiel #4
0
 private static string generateArray(string typeString)
 {
     typeString = Regex.Replace(typeString, "(?<type>[^\\[]*)(?<rank>\\[,*\\])",
                                (MatchEvaluator)(m => SerializationTypeExtension.generateTypeString(m.Groups["type"].Value) + m.Groups["rank"].Value));
     return(typeString);
 }