Пример #1
0
        public void MarshalObject(object value, Stream stream)
        {
            DynamicSettings settings = (DynamicSettings)value;

            Int32Marshaler.Marshal(settings.Count(), stream);
            foreach (KeyValuePair <Guid, DynamicSettingsValue> pair in settings)
            {
                GuidMarshaler.Marshal(pair.Key, stream);
                ByteArrayMarshaler.Marshal(pair.Value.Serialize(), stream);
            }
        }
Пример #2
0
        public object DemarshalObject(Stream stream)
        {
            Dictionary <Guid, DynamicSettingsValue> collection = new Dictionary <Guid, DynamicSettingsValue>();
            int count = Int32Marshaler.Demarshal(stream);

            for (int i = 0; i < count; i++)
            {
                Guid   key  = GuidMarshaler.Demarshal(stream);
                byte[] data = ByteArrayMarshaler.Demarshal(stream);
                DynamicSettingsValue entry = new DynamicSettingsValue();
                entry.Deserialize(data);
                collection.Add(key, entry);
            }
            DynamicSettings settings = (DynamicSettings)Activator.CreateInstance(ManagedType, collection);

            return(settings);
        }