Esempio n. 1
0
        public override Type ResolveType(string id)
        {
            WebServiceTypeData data = null;

            if (this.ClientTypeDictionary.TryGetValue(id, out data) && (data != null))
            {
                return(data.Type);
            }
            return(null);
        }
Esempio n. 2
0
        internal string GetTypeStringRepresentation(WebServiceTypeData typeData)
        {
            string stringRepresentation = typeData.StringRepresentation;

            if (stringRepresentation == null)
            {
                stringRepresentation = this.GetTypeStringRepresentation(typeData.TypeName, true);
            }
            return(stringRepresentation);
        }
Esempio n. 3
0
 private WebServiceData(WebServiceTypeData typeData)
 {
     this._typeResolverSpecials = new Dictionary <string, string>();
     this._typeData             = typeData;
     this._serializer           = new JavaScriptSerializer(this);
     //ScriptingJsonSerializationSection.ApplicationSettings settings = new ScriptingJsonSerializationSection.ApplicationSettings();
     this._serializer.MaxJsonLength  = 12000; // settings.MaxJsonLimit;
     this._serializer.RecursionLimit = 100;   // settings.RecursionLimit;
     //this._serializer.RegisterConverters(settings.Converters);
 }
Esempio n. 4
0
 private void ProcessClientType(Type t, bool force, bool isWCF)
 {
     if (force || !this._processedTypes.Contains(t))
     {
         this._processedTypes[t] = null;
         if (t.IsEnum)
         {
             WebServiceEnumData webServiceTypeData = null;
             if (isWCF)
             {
                 webServiceTypeData = (WebServiceEnumData)WebServiceTypeData.GetWebServiceTypeData(t);
             }
             else
             {
                 webServiceTypeData = new WebServiceEnumData(t.Name, t.Namespace, t, Enum.GetNames(t), Enum.GetValues(t), Enum.GetUnderlyingType(t) == typeof(ulong));
             }
             this._enumTypesDictionary[this.GetTypeStringRepresentation(webServiceTypeData.TypeName, false)] = webServiceTypeData;
         }
         else if (t.IsGenericType)
         {
             if (isWCF)
             {
                 this.ProcessKnownTypes(t);
             }
             else
             {
                 Type[] genericArguments = t.GetGenericArguments();
                 if (genericArguments.Length <= 1)
                 {
                     this.ProcessClientType(genericArguments[0], false, isWCF);
                 }
             }
         }
         else if (t.IsArray)
         {
             this.ProcessClientType(t.GetElementType(), false, isWCF);
         }
         else if (((!t.IsPrimitive && (t != typeof(object))) && ((t != typeof(string)) && (t != typeof(DateTime)))) && ((((t != typeof(void)) && (t != typeof(decimal))) && ((t != typeof(Guid)) && !typeof(IEnumerable).IsAssignableFrom(t))) && (!typeof(IDictionary).IsAssignableFrom(t) && (isWCF || ObjectConverter.IsClientInstantiatableType(t, this._serializer)))))
         {
             if (isWCF)
             {
                 this.ProcessKnownTypes(t);
             }
             else
             {
                 string typeStringRepresentation = this.GetTypeStringRepresentation(t.FullName, false);
                 this._clientTypesDictionary[typeStringRepresentation] = new WebServiceTypeData(t.Name, t.Namespace, t);
                 this._clientTypeNameDictionary[t] = typeStringRepresentation;
             }
         }
     }
 }
Esempio n. 5
0
        internal static WebServiceTypeData GetWebServiceTypeData(Type type)
        {
            WebServiceTypeData data           = null;
            XmlQualifiedName   schemaTypeName = new XsdDataContractExporter().GetSchemaTypeName(type);

            if (schemaTypeName.IsEmpty)
            {
                return(data);
            }
            if (type.IsEnum)
            {
                return(new WebServiceEnumData(XmlConvert.DecodeName(schemaTypeName.Name), XmlConvert.DecodeName(schemaTypeName.Namespace), Enum.GetNames(type), Enum.GetValues(type), Enum.GetUnderlyingType(type) == typeof(ulong)));
            }
            return(new WebServiceTypeData(XmlConvert.DecodeName(schemaTypeName.Name), XmlConvert.DecodeName(schemaTypeName.Namespace)));
        }
Esempio n. 6
0
        internal static List <WebServiceTypeData> GetKnownTypes(Type type, WebServiceTypeData typeData)
        {
            List <WebServiceTypeData> list     = new List <WebServiceTypeData>();
            XsdDataContractExporter   exporter = new XsdDataContractExporter();

            exporter.Export(type);
            foreach (XmlSchema schema in exporter.Schemas.Schemas())
            {
                if (schema.TargetNamespace != "http://schemas.microsoft.com/2003/10/Serialization/")
                {
                    foreach (XmlSchemaType type2 in schema.Items)
                    {
                        string typeNamespace = XmlConvert.DecodeName(schema.TargetNamespace);
                        if (((type2 != null) && ((type2.Name != typeData.TypeName) || (typeNamespace != typeData.TypeNamespace))) && !string.IsNullOrEmpty(type2.Name))
                        {
                            XmlSchemaSimpleTypeRestriction restriction;
                            WebServiceTypeData             item = null;
                            if (CheckIfEnum(type2 as XmlSchemaSimpleType, out restriction))
                            {
                                item = ImportEnum(XmlConvert.DecodeName(type2.Name), typeNamespace, type2.QualifiedName, restriction, type2.Annotation);
                            }
                            else
                            {
                                if (CheckIfCollection(type2 as XmlSchemaComplexType))
                                {
                                    continue;
                                }
                                if (!(type2 is XmlSchemaSimpleType))
                                {
                                    item = new WebServiceTypeData(XmlConvert.DecodeName(type2.Name), typeNamespace);
                                }
                            }
                            if (item != null)
                            {
                                list.Add(item);
                            }
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 7
0
        private bool ProcessTypeData(WebServiceTypeData typeData)
        {
            string typeStringRepresentation = this.GetTypeStringRepresentation(typeData.TypeName);
            bool   flag = true;

            if (typeData is WebServiceEnumData)
            {
                if (!this._enumTypesDictionary.ContainsKey(typeStringRepresentation))
                {
                    this._enumTypesDictionary[typeStringRepresentation] = (WebServiceEnumData)typeData;
                    flag = false;
                }
                return(flag);
            }
            if (!this._clientTypesDictionary.ContainsKey(typeStringRepresentation))
            {
                this._clientTypesDictionary[typeStringRepresentation] = typeData;
                flag = false;
            }
            return(flag);
        }
Esempio n. 8
0
        private void ProcessKnownTypes(Type t)
        {
            WebServiceTypeData webServiceTypeData = WebServiceTypeData.GetWebServiceTypeData(t);
            bool flag = false;

            if (webServiceTypeData != null)
            {
                if (!typeof(IEnumerable).IsAssignableFrom(t) && !typeof(IDictionary).IsAssignableFrom(t))
                {
                    this._clientTypeNameDictionary[t] = this.GetTypeStringRepresentation(webServiceTypeData.TypeName);
                    flag = this.ProcessTypeData(webServiceTypeData);
                }
                if (!flag)
                {
                    foreach (WebServiceTypeData data2 in WebServiceTypeData.GetKnownTypes(t, webServiceTypeData))
                    {
                        this.ProcessTypeData(data2);
                    }
                }
            }
        }
Esempio n. 9
0
 internal WebServiceData(WebServiceTypeData typeData, Dictionary <string, WebServiceMethodData> methods)
     : this(typeData)
 {
     this._methods = methods;
 }