Esempio n. 1
0
        private IDictionary <string, object> StrongTypeParameters(IDictionary <string, object> rawParams)
        {
            IDictionary <string, WebServiceParameterData> parameterDataDictionary = this.ParameterDataDictionary;
            IDictionary <string, object> dictionary2 = new Dictionary <string, object>(rawParams.Count);

            foreach (KeyValuePair <string, object> pair in rawParams)
            {
                string key = pair.Key;
                if (parameterDataDictionary.ContainsKey(key))
                {
                    Type parameterType = parameterDataDictionary[key].ParameterInfo.ParameterType;
                    dictionary2[key] = ObjectConverter.ConvertObjectToType(pair.Value, parameterType, this.Owner.Serializer);
                }
            }
            return(dictionary2);
        }
Esempio n. 2
0
        private object DeserializeInternal(int depth)
        {
            if (++depth > this._depthLimit)
            {
                throw new ArgumentException(this._s.GetDebugString("JSON_DepthLimitExceeded"));
            }
            char?nextNonEmptyChar = this._s.GetNextNonEmptyChar();
            char?nullable2        = nextNonEmptyChar;
            int? nullable4        = nullable2.HasValue ? new int?(nullable2.GetValueOrDefault()) : null;

            if (!nullable4.HasValue)
            {
                return(null);
            }
            this._s.MovePrev();
            if (this.IsNextElementDateTime())
            {
                return(this.DeserializeStringIntoDateTime());
            }
            if (IsNextElementObject(nextNonEmptyChar))
            {
                IDictionary <string, object> o = this.DeserializeDictionary(depth);
                if (o.ContainsKey("__type"))
                {
                    return(ObjectConverter.ConvertObjectToType(o, null, this._serializer));
                }
                return(o);
            }
            if (IsNextElementArray(nextNonEmptyChar))
            {
                return(this.DeserializeList(depth));
            }
            if (IsNextElementString(nextNonEmptyChar))
            {
                return(this.DeserializeString());
            }
            return(this.DeserializePrimitiveObject());
        }
Esempio n. 3
0
 public T ConvertToType <T>(object obj)
 {
     return((T)ObjectConverter.ConvertObjectToType(obj, typeof(T), this));
 }
Esempio n. 4
0
 private void ProcessIncludeAttributes(GenerateScriptTypeAttribute[] attributes)
 {
     foreach (GenerateScriptTypeAttribute attribute in attributes)
     {
         if (!string.IsNullOrEmpty(attribute.ScriptTypeId))
         {
             this._typeResolverSpecials[attribute.Type.FullName] = attribute.ScriptTypeId;
         }
         Type c = attribute.Type;
         if (((((c.IsPrimitive || (c == typeof(object))) || ((c == typeof(string)) || (c == typeof(DateTime)))) || (((c == typeof(Guid)) || typeof(IEnumerable).IsAssignableFrom(c)) || typeof(IDictionary).IsAssignableFrom(c))) || (c.IsGenericType && (c.GetGenericArguments().Length > 1))) || !ObjectConverter.IsClientInstantiatableType(c, this._serializer))
         {
             throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "InvalidGenerateScriptType", new object[] { c.FullName }));
         }
         this.ProcessClientType(c, true);
     }
 }
Esempio n. 5
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;
             }
         }
     }
 }