private void ProcessKnownTypes(Type t) { WebServiceTypeData typeData = WebServiceTypeData.GetWebServiceTypeData(t); bool alreadyProcessed = false; if (typeData == null) { // indicates a type was used that is a built-in type return; } // if T implments IEnumerable or IDictionary, do not include type proxy for it // but still continue to get known types. I.e List<MyType> should ignore List<MyType> // but process MyType if (!(typeof(IEnumerable).IsAssignableFrom(t) || typeof(IDictionary).IsAssignableFrom(t))) { _clientTypeNameDictionary[t] = GetTypeStringRepresentation(typeData.TypeName); alreadyProcessed = ProcessTypeData(typeData); } if (!alreadyProcessed) { IList <WebServiceTypeData> knownTypes = WebServiceTypeData.GetKnownTypes(t, typeData); foreach (WebServiceTypeData knownType in knownTypes) { ProcessTypeData(knownType); } } }
internal void ProcessClientType(Type t, bool force, bool isWCF) { if (!force && _processedTypes.Contains(t)) { return; } _processedTypes[t] = null; // Keep track of all enum Types if (t.IsEnum) { WebServiceEnumData enumData = null; if (isWCF) { enumData = (WebServiceEnumData)WebServiceTypeData.GetWebServiceTypeData(t); } else { enumData = new WebServiceEnumData(t.Name, t.Namespace, t, Enum.GetNames(t), Enum.GetValues(t), Enum.GetUnderlyingType(t) == typeof(ulong)); } _enumTypesDictionary[GetTypeStringRepresentation(enumData.TypeName, false)] = enumData; return; } // For generics, we only allow generic types with one parameter, which we will try to process if (t.IsGenericType) { if (isWCF) { ProcessKnownTypes(t); } else { Type[] genericArgs = t.GetGenericArguments(); if (genericArgs.Length > 1) { return; } ProcessClientType(genericArgs[0], false, isWCF); } } // Support arrays explicitly else if (t.IsArray) { ProcessClientType(t.GetElementType(), false, isWCF); } else { // Ignore primitive types // Ignore DateTime, since we have special serialization handling for it in the JavaScriptSerializer // Ignore IDctionary and IEnumerables as well if (t.IsPrimitive || t == typeof(object) || t == typeof(string) || t == typeof(DateTime) || t == typeof(void) || t == typeof(System.Decimal) || t == typeof(Guid) || typeof(IEnumerable).IsAssignableFrom(t) || typeof(IDictionary).IsAssignableFrom(t) || (!isWCF && !ObjectConverter.IsClientInstantiatableType(t, _serializer))) { return; } // Only add it to the list of client types if it can be instantiated. // pass false to skip the lock if (isWCF) { ProcessKnownTypes(t); } else { string typeStringRepresentation = GetTypeStringRepresentation(t.FullName, false); _clientTypesDictionary[typeStringRepresentation] = new WebServiceTypeData(t.Name, t.Namespace, t); _clientTypeNameDictionary[t] = typeStringRepresentation; } } }