private void InitSiWrite(ObjectWriter objectWriter)
 {
     if (this.si.FullTypeName.Equals("FormatterWrapper"))
     {
         this.obj = this.si.GetValue("__WrappedObject", Converter.typeofObject);
         this.InitSerialize(this.obj, this.surrogateSelector, this.context, this.serObjectInfoInit, this.converter, null, objectWriter);
     }
     else
     {
         SerializationInfoEnumerator enumerator = null;
         this.isSi  = true;
         enumerator = this.si.GetEnumerator();
         int memberCount = this.si.MemberCount;
         this.cache                = new SerObjectInfoCache();
         this.cache.memberNames    = new string[memberCount];
         this.cache.memberTypes    = new Type[memberCount];
         this.memberData           = new object[memberCount];
         this.cache.fullTypeName   = this.si.FullTypeName;
         this.cache.assemblyString = this.si.AssemblyName;
         enumerator                = this.si.GetEnumerator();
         for (int i = 0; enumerator.MoveNext(); i++)
         {
             this.cache.memberNames[i] = enumerator.Name;
             this.cache.memberTypes[i] = enumerator.ObjectType;
             this.memberData[i]        = enumerator.Value;
         }
         this.isNamed = true;
         this.isTyped = false;
     }
 }
Пример #2
0
        /**
         * Constructor used in deserialization
         */
        internal Cursor(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator sie = info.GetEnumerator();

            if (sie == null)
            {
                return;
            }
            for (; sie.MoveNext();)
            {
                // Dont catch any exceptions while Deserialising objects from stream.
                if (string.Equals(sie.Name, "CursorData", StringComparison.OrdinalIgnoreCase))
                {
                    cursorData = (byte[])sie.Value;
                    if (cursorData != null)
                    {
                        LoadPicture(new UnsafeNativeMethods.ComStreamFromDataStream(new MemoryStream(cursorData)));
                    }
                }
                else if (string.Compare(sie.Name, "CursorResourceId", true, CultureInfo.InvariantCulture) == 0)
                {
                    LoadFromResourceId((int)sie.Value);
                }
            }
        }
        protected OwnerDrawPropertyBag(SerializationInfo info, StreamingContext context)
        {
            this.foreColor = Color.Empty;
            this.backColor = Color.Empty;
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                SerializationEntry current = enumerator.Current;
                if (current.Name == "Font")
                {
                    this.font = (System.Drawing.Font)current.Value;
                }
                else
                {
                    if (current.Name == "ForeColor")
                    {
                        this.foreColor = (Color)current.Value;
                        continue;
                    }
                    if (current.Name == "BackColor")
                    {
                        this.backColor = (Color)current.Value;
                    }
                }
            }
        }
Пример #4
0
        internal SoapFault(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator siEnum = info.GetEnumerator();

            while (siEnum.MoveNext())
            {
                String name  = siEnum.Name;
                Object value = siEnum.Value;
                SerTrace.Log(this, "SetObjectData enum ", name, " value ", value);
                if (String.Compare(name, "faultCode", true, CultureInfo.InvariantCulture) == 0)
                {
                    int index = ((String)value).IndexOf(':');
                    if (index > -1)
                    {
                        faultCode = ((String)value).Substring(++index);
                    }
                    else
                    {
                        faultCode = (String)value;
                    }
                }
                else if (String.Compare(name, "faultString", true, CultureInfo.InvariantCulture) == 0)
                {
                    faultString = (String)value;
                }
                else if (String.Compare(name, "faultActor", true, CultureInfo.InvariantCulture) == 0)
                {
                    faultActor = (String)value;
                }
                else if (String.Compare(name, "detail", true, CultureInfo.InvariantCulture) == 0)
                {
                    detail = value;
                }
            }
        }
Пример #5
0
        /**
         * Constructor used in deserialization
         */
        internal Image(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator sie = info.GetEnumerator();

            if (sie == null)
            {
                return;
            }
            for (; sie.MoveNext();)
            {
                if (String.Compare(sie.Name, "Data", true, CultureInfo.InvariantCulture) == 0)
                {
                    try {
                        byte[] dat = (byte[])sie.Value;
                        if (dat != null)
                        {
                            InitializeFromStream(new MemoryStream(dat));
                        }
                    }
                    catch (Exception e) {
                        Debug.Fail("failure: " + e.ToString());
                    }
                }
            }
        }
 internal void SetObjectData(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     if (this.fSoap)
     {
         this.SetObjectFromSoapData(info);
     }
     else
     {
         SerializationInfoEnumerator enumerator = info.GetEnumerator();
         while (enumerator.MoveNext())
         {
             this.FillHeader(enumerator.Name, enumerator.Value);
         }
         if ((context.State == StreamingContextStates.Remoting) && (context.Context != null))
         {
             Header[] headerArray = context.Context as Header[];
             if (headerArray != null)
             {
                 for (int i = 0; i < headerArray.Length; i++)
                 {
                     this.FillHeader(headerArray[i].Name, headerArray[i].Value);
                 }
             }
         }
     }
 }
Пример #7
0
        private DayofWeekArray(SerializationInfo info, StreamingContext context)
            : this()
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            SerializationInfoEnumerator enumerator = info.GetEnumerator();
            bool flag = false;
            byte bits = 0;

            while (enumerator.MoveNext())
            {
                string name = enumerator.Name;
                if (name != null)
                {
                    if (name == "bits")
                    {
                        bits = Convert.ToByte(enumerator.Value, CultureInfo.InvariantCulture);
                        flag = true;
                    }
                }
            }
            if (!flag)
            {
                throw new SerializationException("Serialization Error: Missing DayOfWeekArray Data");
            }
            _DaysofWeek = bits;
        }
        protected XmlSchemaException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            this.res          = (string)info.GetValue("res", typeof(string));
            this.args         = (string[])info.GetValue("args", typeof(string[]));
            this.sourceUri    = (string)info.GetValue("sourceUri", typeof(string));
            this.lineNumber   = (int)info.GetValue("lineNumber", typeof(int));
            this.linePosition = (int)info.GetValue("linePosition", typeof(int));
            string str = null;
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                SerializationEntry current = enumerator.Current;
                if (current.Name == "version")
                {
                    str = (string)current.Value;
                }
            }
            if (str == null)
            {
                this.message = CreateMessage(this.res, this.args);
            }
            else
            {
                this.message = null;
            }
        }
Пример #9
0
        internal Cursor(SerializationInfo info, StreamingContext context)
        {
            this.handle    = IntPtr.Zero;
            this.ownHandle = true;
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            if (enumerator != null)
            {
                while (enumerator.MoveNext())
                {
                    if (string.Equals(enumerator.Name, "CursorData", StringComparison.OrdinalIgnoreCase))
                    {
                        this.cursorData = (byte[])enumerator.Value;
                        if (this.cursorData != null)
                        {
                            this.LoadPicture(new System.Windows.Forms.UnsafeNativeMethods.ComStreamFromDataStream(new MemoryStream(this.cursorData)));
                        }
                    }
                    else if (string.Compare(enumerator.Name, "CursorResourceId", true, CultureInfo.InvariantCulture) == 0)
                    {
                        this.LoadFromResourceId((int)enumerator.Value);
                    }
                }
            }
        }
Пример #10
0
        public TOCList(SerializationInfo info, StreamingContext context)
        {
            TOCNode[] tocNodes = null;

            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                switch (enumerator.Name)
                {
                case "TOCNodes":
                    tocNodes = (TOCNode[])info.GetValue("TOCNodes", typeof(TOCNode[]));
                    break;
                }
            }

            if (tocNodes == null)
            {
                throw new SerializationException();
            }

            arrayList.Clear();
            hashTable.Clear();

            for (int i = 0; i < tocNodes.Length; i++)
            {
                arrayList.Add(tocNodes[i]);
                hashTable.Add(tocNodes[i].Identifier, tocNodes[i]);
            }
        }
Пример #11
0
 internal void SetObjectData(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException(nameof(info));
     }
     if (this.fSoap)
     {
         this.SetObjectFromSoapData(info);
     }
     else
     {
         SerializationInfoEnumerator enumerator = info.GetEnumerator();
         while (enumerator.MoveNext())
         {
             this.FillHeader(enumerator.Name, enumerator.Value);
         }
         if (context.State != StreamingContextStates.Remoting || context.Context == null || !(context.Context is Header[] context3))
         {
             return;
         }
         for (int index = 0; index < context3.Length; ++index)
         {
             this.FillHeader(context3[index].Name, context3[index].Value);
         }
     }
 }
        internal void SetObjectData(SerializationInfo info, StreamingContext ctx)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            if (this.fSoap)
            {
                this.SetObjectFromSoapData(info);
                return;
            }
            SerializationInfoEnumerator enumerator = info.GetEnumerator();
            bool flag  = false;
            bool flag2 = false;

            while (enumerator.MoveNext())
            {
                if (enumerator.Name.Equals("__return"))
                {
                    flag = true;
                    break;
                }
                if (enumerator.Name.Equals("__fault"))
                {
                    flag2      = true;
                    this.fault = (Exception)enumerator.Value;
                    break;
                }
                this.FillHeader(enumerator.Name, enumerator.Value);
            }
            if (flag2 && flag)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Message_BadSerialization"));
            }
        }
Пример #13
0
        private void method_30(JsonWriter jsonWriter_0, ISerializable iserializable_0, JsonISerializableContract jsonISerializableContract_0, JsonProperty jsonProperty_0, JsonContainerContract jsonContainerContract_0, JsonProperty jsonProperty_1)
        {
            if (!Class139.Boolean_1)
            {
                throw JsonSerializationException.smethod_3(null, jsonWriter_0.String_0, "Type '{0}' implements ISerializable but cannot be serialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data.\r\nTo fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true.".smethod_0(CultureInfo.InvariantCulture, iserializable_0.GetType()), null);
            }
            this.method_15(jsonWriter_0, jsonISerializableContract_0, iserializable_0);
            this.list_0.Add(iserializable_0);
            this.method_19(jsonWriter_0, iserializable_0, jsonISerializableContract_0, jsonProperty_0, jsonContainerContract_0, jsonProperty_1);
            SerializationInfo info = new SerializationInfo(jsonISerializableContract_0.UnderlyingType, new FormatterConverter());

            iserializable_0.GetObjectData(info, base.jsonSerializer_0.streamingContext_0);
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                SerializationEntry current  = enumerator.Current;
                JsonContract       contract = this.method_5(current.Value);
                if (this.method_11(jsonWriter_0, current.Value, null, contract, jsonISerializableContract_0, jsonProperty_0))
                {
                    jsonWriter_0.WritePropertyName(current.Name);
                    this.method_7(jsonWriter_0, current.Value, contract, null, jsonISerializableContract_0, jsonProperty_0);
                }
            }
            jsonWriter_0.WriteEndObject();
            this.list_0.RemoveAt(this.list_0.Count - 1);
            this.method_16(jsonWriter_0, jsonISerializableContract_0, iserializable_0);
        }
Пример #14
0
        /// <summary>
        /// Determine if serialized information has corresponding field
        /// </summary>
        /// <remarks>
        /// Namespaces and subclassing change the name of the info field compared
        /// to the name of the corresponding field in the class file. This will
        /// attempt to find the match.
        /// </remarks>
        /// <param name="fieldName">Serialized field name</param>
        /// <param name="info">All serialization information</param>
        /// <returns>Field name corrected to match class definition</returns>
        private string FixFieldName(string fieldName, SerializationInfo info)
        {
            SerializationInfoEnumerator infoEnum = info.GetEnumerator();
            Regex re;

            if (_convert && fieldName.IndexOf('+') > 0)
            {
                re = new Regex(string.Format("({0}|{1})$", fieldName, fieldName.Split('+')[1]),
                               RegexOptions.IgnoreCase);
            }
            else
            {
                re = new Regex(string.Format("{0}$", fieldName), RegexOptions.IgnoreCase);
            }

            while (infoEnum.MoveNext())
            {
                if (re.IsMatch(infoEnum.Name))
                {
                    return(infoEnum.Name);
                }
            }
            //BugOut("No serialization data for field {0}", fieldName)
            return(null);
        }
Пример #15
0
        internal LogicalCallContext(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Name.Equals("__RemotingData"))
                {
                    this.m_RemotingData = (CallContextRemotingData)enumerator.Value;
                }
                else if (enumerator.Name.Equals("__SecurityData"))
                {
                    if (context.State == StreamingContextStates.CrossAppDomain)
                    {
                        this.m_SecurityData = (CallContextSecurityData)enumerator.Value;
                    }
                }
                else if (enumerator.Name.Equals("__HostContext"))
                {
                    this.m_HostContext = enumerator.Value;
                }
                else if (enumerator.Name.Equals("__CorrelationMgrSlotPresent"))
                {
                    this.m_IsCorrelationMgr = (bool)enumerator.Value;
                }
                else
                {
                    this.Datastore[enumerator.Name] = enumerator.Value;
                }
            }
        }
Пример #16
0
        public bool StoreCacheInfo(object obj, SerializationInfo info)
        {
            Type t      = obj.GetType();
            var  objmap = this._infoTypeCache[t] as Hashtable;

            if (objmap == null)
            {
                objmap = new Hashtable();
                this._infoTypeCache[t] = objmap;
            }

            var data = objmap[obj] as SerializationInfoCacheList;

            if (data == null)
            {
                data        = new SerializationInfoCacheList(info.MemberCount);
                objmap[obj] = data;
            }

            SerializationInfoEnumerator itr = info.GetEnumerator();

            while (itr.MoveNext())
            {
                data.Add(new SerializationInfoCache(itr.Name, itr.Value, itr.ObjectType));
            }

            return(true);
        }
        private void SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            if (!JsonTypeReflector.FullyTrusted)
            {
                throw JsonSerializationException.Create(null, writer.ContainerPath, "Type '{0}' implements ISerializable but cannot be serialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data.\r\nTo fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true.".FormatWith(CultureInfo.InvariantCulture, value.GetType()), null);
            }
            this.OnSerializing(writer, contract, value);
            this._serializeStack.Add(value);
            this.WriteObjectStart(writer, value, contract, member, collectionContract, containerProperty);
            SerializationInfo serializationInfo = new SerializationInfo(contract.UnderlyingType, new FormatterConverter());

            value.GetObjectData(serializationInfo, this.Serializer._context);
            SerializationInfoEnumerator enumerator = serializationInfo.GetEnumerator();

            while (enumerator.MoveNext())
            {
                SerializationEntry current      = enumerator.Current;
                JsonContract       contractSafe = this.GetContractSafe(current.Value);
                if (this.CheckForCircularReference(writer, current.Value, null, contractSafe, contract, member))
                {
                    writer.WritePropertyName(current.Name);
                    this.SerializeValue(writer, current.Value, contractSafe, null, contract, member);
                }
            }
            writer.WriteEndObject();
            this._serializeStack.RemoveAt(this._serializeStack.Count - 1);
            this.OnSerialized(writer, contract, value);
        }
Пример #18
0
        public ComObjRef(SerializationInfo info, StreamingContext ctx)
        {
            byte[] buffer = null;
            IntPtr pUnk   = IntPtr.Zero;

            SerializationInfoEnumerator e = info.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Name.Equals("buffer"))
                {
                    buffer = (byte[])e.Value;
                }
            }

            DBG.Assert(buffer != null, "Buffer in ComObjRef is null!");

            try
            {
                pUnk     = Thunk.Proxy.UnmarshalObject(buffer);
                _realobj = Marshal.GetObjectForIUnknown(pUnk);
            }
            finally
            {
                if (pUnk != IntPtr.Zero)
                {
                    Marshal.Release(pUnk);
                }
            }

            if (_realobj == null)
            {
                throw new NotSupportedException();
            }
        }
Пример #19
0
        [System.Security.SecurityCritical]  // auto-generated
        internal LogicalCallContext(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator e = info.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Name.Equals("__RemotingData"))
                {
                    m_RemotingData = (CallContextRemotingData)e.Value;
                }
                else if (e.Name.Equals("__SecurityData"))
                {
                    if (context.State == StreamingContextStates.CrossAppDomain)
                    {
                        m_SecurityData = (CallContextSecurityData)e.Value;
                    }
                    else
                    {
                        BCLDebug.Assert(false, "Security data should only be serialized in cross appdomain case.");
                    }
                }
                else if (e.Name.Equals("__HostContext"))
                {
                    m_HostContext = e.Value;
                }
                else if (e.Name.Equals("__CorrelationMgrSlotPresent"))
                {
                    m_IsCorrelationMgr = (bool)e.Value;
                }
                else
                {
                    Datastore[e.Name] = e.Value;
                }
            }
        }
Пример #20
0
        private ImageListStreamer(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator sie = info.GetEnumerator();

            if (sie is null)
            {
                return;
            }

            while (sie.MoveNext())
            {
                if (string.Equals(sie.Name, "Data", StringComparison.OrdinalIgnoreCase))
                {
#if DEBUG
                    try
                    {
#endif
                    byte[] data = (byte[])sie.Value;
                    if (data is not null)
                    {
                        Deserialize(data);
                    }
#if DEBUG
                }
                catch (Exception e)
                {
                    Debug.Fail("ImageList serialization failure: " + e.ToString());
                    throw;
                }
#endif
                }
            }
        }
Пример #21
0
        public VenueList(SerializationInfo info, StreamingContext context)
        {
            Venue[] venues = null;

            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                switch (enumerator.Name)
                {
                case "Venues":
                    venues = (Venue[])info.GetValue("Venues", typeof(Venue[]));
                    break;
                }
            }

            if (venues == null)
            {
                throw new SerializationException();
            }

            arrayList.Clear();
            hashTable.Clear();

            for (int i = 0; i < venues.Length; i++)
            {
                arrayList.Add(venues[i]);
                hashTable.Add(venues[i].Name, venues[i]);
            }
        }
        public CustomMenuStructure(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                switch (enumerator.Name)
                {
                case "Text": Text = enumerator.Current.Value as string; break;

                case "Tooltip": Tooltip = enumerator.Current.Value as string; break;

                case "ID": ID = (uint)enumerator.Current.Value; break;

                case "Command": Command = enumerator.Current.Value as string; break;

                case "Checked": Checked = (bool)enumerator.Current.Value; break;

                case "Items": Items = enumerator.Current.Value as List <CustomMenuStructure>; break;

                case "Icon": Icon = enumerator.Current.Value as Bitmap; break;
                }
            }
            //Text = info.GetString("Text");
            //Tooltip = info.GetString("Tooltip");
            //ID = info.GetUInt32("ID");
            //Command = info.GetString("Command");
            //Checked = info.GetBoolean("Checked");
            //Items = (List<CustomMenuStructure>)info.GetValue("Items", typeof(List<CustomMenuStructure>));
        }
Пример #23
0
        void Deserialize(SerializationInfo info, StreamingContext context)
        {
            if (null == info)
            {
                throw new ArgumentNullException("info");
            }

            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                switch (enumerator.Name)
                {
                case IdentitiesKey:
                    DeserializeIdentities(info.GetString(IdentitiesKey));
                    break;

                case VersionKey:
                    m_version = info.GetString(VersionKey);
                    break;

                default:
                    // Ignore other fields for forward compatability.
                    break;
                }
            }
        }
Пример #24
0
        private OperatingSystem(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string name = enumerator.Name;
                if (!(name == "_version"))
                {
                    if (!(name == "_platform"))
                    {
                        if (name == "_servicePack")
                        {
                            this._servicePack = info.GetString("_servicePack");
                        }
                    }
                    else
                    {
                        this._platform = (PlatformID)info.GetValue("_platform", typeof(PlatformID));
                    }
                }
                else
                {
                    this._version = (Version)info.GetValue("_version", typeof(Version));
                }
            }
            if (this._version == (Version)null)
            {
                throw new SerializationException(Environment.GetResourceString("Serialization_MissField", (object)"_version"));
            }
        }
Пример #25
0
        private Font(SerializationInfo info, StreamingContext context)
        {
            string                      familyName      = null;
            float                       emSize          = -1f;
            FontStyle                   style           = FontStyle.Regular;
            GraphicsUnit                unit            = GraphicsUnit.Point;
            SingleConverter             singleConverter = new SingleConverter();
            SerializationInfoEnumerator enumerator      = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (string.Equals(enumerator.Name, "Name", StringComparison.OrdinalIgnoreCase))
                {
                    familyName = (string)enumerator.Value;
                }
                else if (string.Equals(enumerator.Name, "Size", StringComparison.OrdinalIgnoreCase))
                {
                    emSize = ((!(enumerator.Value is string)) ? ((float)enumerator.Value) : ((float)singleConverter.ConvertFrom(enumerator.Value)));
                }
                else if (string.Compare(enumerator.Name, "Style", ignoreCase: true, CultureInfo.InvariantCulture) == 0)
                {
                    style = (FontStyle)enumerator.Value;
                }
                else if (string.Compare(enumerator.Name, "Unit", ignoreCase: true, CultureInfo.InvariantCulture) == 0)
                {
                    unit = (GraphicsUnit)enumerator.Value;
                }
            }
            Initialize(familyName, emSize, style, unit, 1, IsVerticalName(familyName));
        }
Пример #26
0
        public static JObject ToJObject <T>(this T exception) where T : Exception
        {
            if (exception == null)
            {
                return(null);
            }

            var serializationInfo = new SerializationInfo(typeof(T), new FormatterConverter());

            exception.GetObjectData(serializationInfo, new StreamingContext(StreamingContextStates.All));
            var dict = new Dictionary <string, object>();
            SerializationInfoEnumerator enumerator = serializationInfo.GetEnumerator();

            while (enumerator.MoveNext())
            {
                object value = enumerator.Current.Value;
                if (value != null && typeof(Exception).IsAssignableFrom(enumerator.Current.ObjectType))
                {
                    value = ((Exception)value).ToJObject();
                }

                dict[enumerator.Current.Name] = value;
            }

            return(JObject.FromObject(dict));
        }
Пример #27
0
        private OperatingSystem(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                switch (enumerator.Name)
                {
                case "_version":
                    _version = (Version)info.GetValue("_version", typeof(Version));
                    break;

                case "_platform":
                    _platform = (PlatformID)info.GetValue("_platform", typeof(PlatformID));
                    break;

                case "_servicePack":
                    _servicePack = info.GetString("_servicePack");
                    break;
                }
            }

            if (_version == null)
            {
                throw new SerializationException(Environment.GetResourceString("Serialization_MissField", "_version"));
            }
        }
Пример #28
0
        // Token: 0x06005204 RID: 20996 RVA: 0x0011F2C8 File Offset: 0x0011D4C8
        internal SoapFault(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator enumerator = info.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string name  = enumerator.Name;
                object value = enumerator.Value;
                if (string.Compare(name, "faultCode", true, CultureInfo.InvariantCulture) == 0)
                {
                    int num = ((string)value).IndexOf(':');
                    if (num > -1)
                    {
                        this.faultCode = ((string)value).Substring(num + 1);
                    }
                    else
                    {
                        this.faultCode = (string)value;
                    }
                }
                else if (string.Compare(name, "faultString", true, CultureInfo.InvariantCulture) == 0)
                {
                    this.faultString = (string)value;
                }
                else if (string.Compare(name, "faultActor", true, CultureInfo.InvariantCulture) == 0)
                {
                    this.faultActor = (string)value;
                }
                else if (string.Compare(name, "detail", true, CultureInfo.InvariantCulture) == 0)
                {
                    this.detail = value;
                }
            }
        }
Пример #29
0
        /// <summary>
        /// Deserializes a field on a object using PersistableAttribute attributes.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="info">
        /// </param>
        /// <param name="context">
        /// </param>
        /// <returns>
        /// The System.Object.
        /// </returns>
        public static object DeserializeValue(string name, SerializationInfo info, StreamingContext context)
        {
            try
            {
                object value = null;
                Type   type  = null;

                // Use enum to avoid exceptions
                SerializationInfoEnumerator siEnum = info.GetEnumerator();
                while (siEnum.MoveNext())
                {
                    if (siEnum.Name == name)
                    {
                        value = siEnum.Value;
                        type  = siEnum.ObjectType;
                    }
                }

                return(value);
            }
            catch
            {
            }

            return(null);
        }
Пример #30
0
        /**
         * Constructor used in deserialization
         */
        internal Cursor(SerializationInfo info, StreamingContext context)
        {
            SerializationInfoEnumerator sie = info.GetEnumerator();

            if (sie == null)
            {
                return;
            }
            for (; sie.MoveNext();)
            {
                if (String.Compare(sie.Name, "CursorData", true, CultureInfo.InvariantCulture) == 0)
                {
                    try {
                        byte[] dat = (byte[])sie.Value;
                        if (dat != null)
                        {
                            Initialize(LoadPicture(new UnsafeNativeMethods.ComStreamFromDataStream(new MemoryStream(dat))));
                        }
                    }
                    catch (Exception e) {
                        Debug.Fail("failure: " + e.ToString());
                    }
                }
                else if (String.Compare(sie.Name, "CursorResourceId", true, CultureInfo.InvariantCulture) == 0)
                {
                    LoadFromResourceId((int)sie.Value);
                }
            }
        }