Esempio n. 1
0
        private void SerializationHandler(PrimSerialization serialization)
        {
            if (serialization.Prim != null && serialization.Prim.Parent != null)
            {
                m_log.Debug("Skipping serialization for child prim " + serialization.Prim.ID);
                return;
            }

            SerializedData item = new SerializedData
            {
                ContentType = PRIM_CONTENT_TYPE,
                Name        = serialization.ID.ToString(),
                Section     = "llprimitives",
                StoreID     = m_scene.ID,
                Version     = 1
            };

            // Removes set item.Data = null, signaling a delete. Adds set item.Data to the serialized prim data
            if (serialization.Prim != null)
            {
                item.Data = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(LLPrimitive.SerializeLinkset(serialization.Prim)));
            }

            m_dataStore.BeginSerialize(item);
        }
Esempio n. 2
0
        public override SerializedData[] ProcessRead(string data)
        {
            var entries = GlobalMatcher.Matches(data);
            var retData = new SerializedData[entries.Count];

            for (var i = 0; i < entries.Count; i++)
            {
                var entry      = entries[i];
                var type       = entry.Groups[1].Value;
                var name       = entry.Groups[2].Value;
                var fields     = FieldsMatcher.Matches(entry.Groups[3].Value);
                var serialized = retData[i] = new SerializedData(fields.Count)
                {
                    Type = type,
                    Name = name
                };

                for (var j = 0; j < fields.Count; j++)
                {
                    var fieldMatch = fields[j];
                    serialized.Fields[j] = new SerializedData.Field(fieldMatch.Groups[1].Value, fieldMatch.Groups[2].Value);
                }
            }

            return(retData);
        }
        public static object LoadJsonTyped(string aFileName)
        {
            try
            {
                // 1. What class do we have
                // 2. Send data as JSON string and deserialize as intended object yes code yes

                SerializedData data      = LoadJson <SerializedData>(aFileName);
                string         className = data.typename;
                object         classData = data.data;

                string serialized = JsonConvert.SerializeObject(classData /*Data*/, Formatting.Indented);


                Type       type           = Type.GetType(className, false);
                var        JSONConvert    = typeof(JsonConvert);
                var        parameterTypes = new[] { typeof(string) };
                MethodInfo deserializer   = JSONConvert.GetMethods(BindingFlags.Public | BindingFlags.Static)
                                            .Where(i => i.Name.Equals("DeserializeObject", StringComparison.InvariantCulture))
                                            .Where(i => i.IsGenericMethod)
                                            .Where(i => i.GetParameters().Select(a => a.ParameterType).SequenceEqual(parameterTypes))
                                            .Single();
                deserializer = deserializer.MakeGenericMethod(type);
                return(deserializer.Invoke(null, new object[] { serialized }));
            }
            catch (Exception e)
            {
                Console.Write("We did wrong" + e.ToString());
                throw;
            }
        }
        private void AutoUploadDocument <T>(T document) where T : Document
        {
            using (var context = new ConnectContext())
            {
                var companyKey       = FetchClaimValue(ConnectConstants.ConnectCompanyKeyClaim);
                var existingDocument = FindDocuments <T>(context, document.RegistrationNumber, companyKey);

                bool hasExisting = existingDocument.Any();
                foreach (var item in existingDocument)
                {
                    if (item.Equals(document))
                    {
                        hasExisting = true;
                        break;
                    }
                }

                if (!hasExisting)
                {
                    document.UserId = GetUserId();
                    context.Set <T>().Add(document);

                    context.SaveChanges();

                    var serializedData = new SerializedData
                    {
                        DocumentType = typeof(T).FullName,
                        DocumentId   = document.Id,
                        Data         = document.SerializedData
                    };
                    context.Set <SerializedData>().Add(serializedData);
                    context.SaveChanges();
                }
            }
        }
Esempio n. 5
0
        private void _PreParse(string xmlContent, string filename, XMLSerializerParams parameters, List <SerializedData> result, Dictionary <SerializedData, string> filenameMappings, List <SerializerError> errors)
        {
            var xElement = XElement.Parse(xmlContent);

            // Validity checks
            if (!SerializerValidation.ContainerElementName(parameters, xElement, filename, errors))
            {
                return;
            }

            // Iterate over nodes
            foreach (var xNode in xElement.Nodes())
            {
                var nodeXElement = xNode as XElement;

                // Validity checks
                if (!SerializerValidation.NodeIsElement(parameters, xNode, filename, errors))
                {
                    continue;
                }

                var elementType = SerializerCache.GetSerializableTypeCacheFor(nodeXElement.Name.LocalName, parameters.standardNamespace);
                if (!SerializerValidation.RootTypeFound(parameters, nodeXElement.Name.LocalName, nodeXElement, elementType, filename, errors))
                {
                    continue;
                }

                // Prepare
                var data = new SerializedData(elementType, nodeXElement);
                result.Add(data);
                filenameMappings.Set(data, filename);
            }
        }
Esempio n. 6
0
        protected virtual void OnEnable()
        {
            SerializedData entry;

            if (!data.ContainsKey(target))
            {
                entry = new SerializedData();
                data.Add(target, entry);

                entry._nonSerializedFields = ReflectionUtility.GetAllFields(
                    target, f => f.GetCustomAttributes(typeof(ShowNonSerializedFieldAttribute), true).Length > 0).ToList();
                entry._nativeProperties = ReflectionUtility.GetAllProperties(
                    target, p => p.GetCustomAttributes(typeof(ShowNativePropertyAttribute), true).Length > 0).ToList();
                entry._methods = ReflectionUtility.GetAllMethods(
                    target, m => m.GetCustomAttributes(typeof(ButtonAttribute), true).Length > 0).ToList();
                GetSerializedProperties(ref _serializedProperties);
                entry._serializedProperties = _serializedProperties;
                entry._anyNaughtyAttribute  = _serializedProperties.Any(p => PropertyUtility.GetAttribute <INaughtyAttribute>(p) != null);

                entry._anyNativeProperties = entry._nativeProperties.Any();
                entry._anyMethods          = entry._methods.Any();
            }


            entry = data[target];
            _serializedProperties = entry._serializedProperties;
            _nonSerializedFields  = entry._nonSerializedFields;
            _nativeProperties     = entry._nativeProperties;
            _anyNativeProperties  = entry._anyNativeProperties;
            _methods             = entry._methods;
            _anyMethods          = entry._anyMethods;
            _anyNaughtyAttribute = entry._anyNaughtyAttribute;
        }
        public void OnAfterDeserialize()
        {
            SerializedData val = SerializationUtility.DeserializeValue <SerializedData>(bytes, DataFormat.Binary, _unityReferences);

            _delegate        = val.Delegate;
            _parameterValues = val.ParameterValues;
        }
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            var data = new SerializedData {
                SpecKeys = specs.Keys.ToList(), SpecValues = specs.Values.ToList(), MenuValues = mainMenus.ToList()
            };

            info.AddValue <SerializedData>("data", data);
        }
 public PackScheduleEntityObjectMother(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, Action <CallbackParameters> loggingCallback)
     : base(oldContext, loggingCallback)
 {
     _newContextHelper = new NewContextHelper(newContext);
     _packagingHelper  = new PackSchedulePackagingHelper(oldContext.CreateObjectSet <tblPackaging>().ToList());
     _notebookFactory  = NotebookFactory.Create(newContext);
     _serializedData   = new SerializedData(oldContext);
 }
 public virtual void InitializeFile(IStorableAdapter <T> storableAdapter)
 {
     this.data = new SerializedData();
     this.data.storableAdapter = storableAdapter;
     this.data.objects         = new List <T>();
     writeBuffer();
     InitComponents();
 }
 public void OnBeforeSerialize()
 {
     VariableValues.Clear();
     for (int i = 0; i < Variables.Count; i++)
     {
         VariableValues.Add(SerializedData.Serialize(Variables[i]));
     }
 }
 public void OnAfterDeserialize()
 {
     Variables.Clear();
     for (int i = 0; i < VariableValues.Count; i++)
     {
         Variables.Add(SerializedData.Deserialize(VariableValues[i]) as Variable);
     }
 }
Esempio n. 13
0
        private void Deserialize()
        {
            IList <SerializedData> items = m_dataStore.Deserialize(m_scene.ID, "llprimitives");

            int linksetCount = 0;
            int primCount    = 0;

            for (int i = 0; i < items.Count; i++)
            {
                SerializedData item = items[i];

                using (MemoryStream stream = new MemoryStream(item.Data))
                {
                    OSDMap linksetMap = OSDParser.DeserializeJson(stream) as OSDMap;

                    if (linksetMap != null)
                    {
                        IList <LLPrimitive> linkset = LLPrimitive.DeserializeLinkset(linksetMap, m_scene, m_primMesher, false);

                        // Rez the parent(s) first
                        for (int j = 0; j < linkset.Count; j++)
                        {
                            LLPrimitive prim = linkset[j];
                            if (prim.Parent == null)
                            {
                                m_scene.EntityAddOrUpdate(this, prim, UpdateFlags.FullUpdate, 0);
                            }
                        }

                        // Rez the children
                        for (int j = 0; j < linkset.Count; j++)
                        {
                            LLPrimitive prim = linkset[j];
                            if (prim.Parent != null)
                            {
                                m_scene.EntityAddOrUpdate(this, prim, UpdateFlags.FullUpdate, 0);
                            }
                        }

                        // Start any scripts
                        for (int j = 0; j < linkset.Count; j++)
                        {
                            StartScripts(linkset[j]);
                        }

                        ++linksetCount;
                        primCount += linkset.Count;
                    }
                    else
                    {
                        m_log.WarnFormat("Failed to deserialize store object {0} ({1} bytes), Content-Type={2}, Version={3}",
                                         item.Name, item.Data.Length, item.ContentType, item.Version);
                    }
                }
            }

            m_log.DebugFormat("Deserialized and loaded {0} LLPrimitives in {1} linksets", primCount, linksetCount);
        }
        public void OnBeforeSerialize()
        {
            SerializedData val = new SerializedData()
            {
                Delegate = _delegate, ParameterValues = _parameterValues
            };

            bytes = SerializationUtility.SerializeValue(val, DataFormat.Binary, out _unityReferences);
        }
Esempio n. 15
0
 public DeleteTblLotHelper(RioAccessSQLEntities oldContext)
 {
     if (oldContext == null)
     {
         throw new ArgumentNullException("oldContext");
     }
     _oldContext     = oldContext;
     _serializedData = new SerializedData(_oldContext);
 }
Esempio n. 16
0
        public void Serialize(Dictionary <string, string> serializeData)
        {
            var serializedData = new SerializedData()
            {
                fieldStatuses = new SerializableDictionary <int, string>(fieldStatues.ToDictionary(x => x.Key, x => x.Value.ToJson()))
            };

            serializeData.Add(SerializedData.Key, JsonUtility.ToJson(serializedData));
        }
Esempio n. 17
0
 public void Serialize(string file, IFormatter formatter)
 {
     using (FileStream fs = File.Open(file, FileMode.OpenOrCreate)) {
         var data = new SerializedData {
             SpecKeys = specs.Keys.ToList(), SpecValues = specs.Values.ToList(), MenuValues = mainMenus.ToList()
         };
         formatter.Serialize(fs, data);
     }
 }
Esempio n. 18
0
        public string Serialize()
        {
            SerializedData         data       = new SerializedData(this);
            DataContractSerializer serializer = new DataContractSerializer(typeof(SerializedData));

            System.IO.MemoryStream s = new System.IO.MemoryStream();
            serializer.WriteObject(s, data);
            return(Convert.ToBase64String(s.ToArray()));
        }
Esempio n. 19
0
        public void Serialize(Dictionary <string, string> serializeData)
        {
            var serializedData = new SerializedData()
            {
                itemNumbers = new SerializableDictionary <int, int>(itemNumbers)
            };

            serializeData.Add(SerializedData.Key, JsonUtility.ToJson(serializedData));
        }
Esempio n. 20
0
 public object Deserialize(SerializedData source)
 {
     foreach (var field in source.Fields)
     {
         LoadField(field);
     }
     Validate();
     return(this);
 }
Esempio n. 21
0
        static void SetDataForComponent(ECSComponent comp, SerializedData data)
        {
            Type t     = comp.GetType();
            var  field = findDataField(t);

            if (field != null)
            {
                field.SetValue(comp, data);
            }
        }
Esempio n. 22
0
        public SerializedDataField(SerializedProperty property, T value)
        {
            _value              = value;
            _data               = new SerializedData();
            _contentProperty    = property.FindPropertyRelative(_contentPropertyName);
            _referencesProperty = property.FindPropertyRelative(_referencesPropertyName);

            style.display = DisplayStyle.Flex;

            Watch(_contentProperty);
        }
Esempio n. 23
0
        private static string DataToString(SerializedData data)
        {
            string fields = "";

            foreach (var item in data)
            {
                fields += $"  {item.Key}: {item.Value}\n";
            }

            return(fields.Length == 0 ? " {}" : "\n{\n" + fields + "}");
        }
Esempio n. 24
0
        public ActionResult saveUdatedData([FromBody] SerializedData data)
        {
            string jsonString;

            jsonString = JsonSerializer.Serialize(data);
            if (FileManager.saveJson(jsonString, data.version))
            {
                return(Content("ok"));
            }
            return(Content("error"));
        }
Esempio n. 25
0
        static void Deserialize(HostingServicesManager m, SerializedData data)
        {
            FieldInfo infosField = typeof(HostingServicesManager).GetField("m_HostingServiceInfos", BindingFlags.NonPublic | BindingFlags.Instance);

            Assert.NotNull(infosField);
            FieldInfo typeRefField = typeof(HostingServicesManager).GetField("m_RegisteredServiceTypeRefs", BindingFlags.NonPublic | BindingFlags.Instance);

            Assert.NotNull(typeRefField);

            infosField.SetValue(m, data.Infos);
            typeRefField.SetValue(m, data.TypeRefs);
        }
Esempio n. 26
0
        public SerializedData[] Serialize()
        {
            var data = ToArray();
            var ret  = new SerializedData[data.Length];

            for (var i = 0; i < data.Length; i++)
            {
                ret[i] = data[i].Serialize();
            }

            return(ret);
        }
Esempio n. 27
0
        public static Door Deserialize(string name, string sdata, Map map)
        {
            byte[] bdata = Convert.FromBase64String(sdata);
            Door   Door  = new Door();
            DataContractSerializer serializer = new DataContractSerializer(typeof(SerializedData));

            System.IO.MemoryStream s    = new System.IO.MemoryStream(bdata);
            SerializedData         data = ( SerializedData )serializer.ReadObject(s);

            data.UpdateDoor(Door);
            return(Door);
        }
Esempio n. 28
0
        public static MessageBlock Deserialize(string name, string sdata, Map map)
        {
            byte[]                 bdata        = Convert.FromBase64String(sdata);
            MessageBlock           MessageBlock = new MessageBlock();
            DataContractSerializer serializer   = new DataContractSerializer(typeof(SerializedData));

            System.IO.MemoryStream s    = new System.IO.MemoryStream(bdata);
            SerializedData         data = ( SerializedData )serializer.ReadObject(s);

            data.UpdateMessageBlock(MessageBlock);
            return(MessageBlock);
        }
Esempio n. 29
0
        public static Life2DZone Deserialize(string name, string sdata, Map map)
        {
            Life2DZone life = new Life2DZone(name, map);

            byte[] bdata = Convert.FromBase64String(sdata);
            DataContractSerializer serializer = new DataContractSerializer(typeof(SerializedData));
            MemoryStream           s          = new MemoryStream(bdata);
            SerializedData         data       = ( SerializedData )serializer.ReadObject(s);

            data.UpdateLife2DZone(life);
            return(life);
        }
Esempio n. 30
0
        public void Save()
        {
            var saveDara = new Dictionary <string, string>();

            FieldData.Serialize(saveDara);
            Item.Serialize(saveDara);
            var serializedData = new SerializedData()
            {
                saveData = saveDara.ToSerializable()
            };

            PlayerPrefs.SetString(SerializedData.Key, JsonUtility.ToJson(serializedData));
        }
Esempio n. 31
0
        private void SerializeInventory(UUID ownerID, Dictionary<UUID, InventoryBase> inventory)
        {
            if (m_fileDataStore != null)
            {
                OSDMap map = new OSDMap(inventory.Count);

                foreach (KeyValuePair<UUID, InventoryBase> kvp in inventory)
                    map[kvp.Key.ToString()] = SerializeInventoryNode(kvp.Value);

                SerializedData data = new SerializedData
                {
                    StoreID = UUID.Zero,
                    Section = "Inventory",
                    ContentType = "application/llsd+json",
                    Name = ownerID.ToString(),
                    Data = System.Text.Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(map)),
                    Version = 1
                };

                m_fileDataStore.BeginSerialize(data);
            }
        }
Esempio n. 32
0
        private void SerializeUser(User user)
        {
            if (m_fileDataStore != null)
            {
                SerializedData data = new SerializedData
                {
                    StoreID = UUID.Zero,
                    Section = "Users",
                    ContentType = "application/llsd+json",
                    Name = user.ID.ToString(),
                    Data = System.Text.Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(user.GetOSD())),
                    Version = 1
                };

                m_fileDataStore.BeginSerialize(data);
            }
        }
Esempio n. 33
0
        private void SerializeIdentities()
        {
            if (m_fileDataStore != null)
            {
                OSDMap map = new OSDMap(m_identities.Count);

                foreach (KeyValuePair<string, Identity> kvp in m_identities)
                    map[kvp.Key] = SerializeIdentity(kvp.Value);

                SerializedData data = new SerializedData
                {
                    StoreID = UUID.Zero,
                    Section = "Users",
                    ContentType = "application/llsd+json",
                    Name = "identities",
                    Data = System.Text.Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(map)),
                    Version = 1
                };

                m_fileDataStore.BeginSerialize(data);
            }
        }
Esempio n. 34
0
 public string Serialize()
 {
     SerializedData data = new SerializedData( this );
     DataContractSerializer serializer = new DataContractSerializer( typeof( SerializedData ) );
     System.IO.MemoryStream s = new System.IO.MemoryStream();
     serializer.WriteObject( s, data );
     return Convert.ToBase64String( s.ToArray() );
 }
Esempio n. 35
0
        private void SerializationHandler(PrimSerialization serialization)
        {
            if (serialization.Prim != null && serialization.Prim.Parent != null)
            {
                m_log.Debug("Skipping serialization for child prim " + serialization.Prim.ID);
                return;
            }

            SerializedData item = new SerializedData
            {
                ContentType = PRIM_CONTENT_TYPE,
                Name = serialization.ID.ToString(),
                Section = "llprimitives",
                StoreID = m_scene.ID,
                Version = 1
            };

            // Removes set item.Data = null, signaling a delete. Adds set item.Data to the serialized prim data
            if (serialization.Prim != null)
                item.Data = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(LLPrimitive.SerializeLinkset(serialization.Prim)));

            m_dataStore.BeginSerialize(item);
        }