当前位置: 首页>>代码示例>>C#>>正文


C# ISerializer.UnSerialize方法代码示例

本文整理汇总了C#中ISerializer.UnSerialize方法的典型用法代码示例。如果您正苦于以下问题:C# ISerializer.UnSerialize方法的具体用法?C# ISerializer.UnSerialize怎么用?C# ISerializer.UnSerialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISerializer的用法示例。


在下文中一共展示了ISerializer.UnSerialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

        /// <summary>
        /// Charge le fichier donné grâce au sérialiseur passé en paramètre
        /// </summary>
        /// <param name="filename">le fichier à ouvrir</param>
        /// <param name="serializer">le sérialiseur utilisé</param>
        /// <returns>les données du document</returns>
        public static IDocumentData Load(string filename, ISerializer serializer)
        {
            if (filename == null)
                throw new ArgumentNullException();

            string loaded = LoadFile(filename);
            //char[] separators = { '\n' };
            //string[] serializedControls = loaded.Split(separators);

            //IControlData[] controls = new IControlData[serializedControls.Count()];
            string extension = Path.GetExtension(filename);

            ControlDataWrapper[] controlwrappers = (ControlDataWrapper[]) serializer.UnSerialize(loaded);
            IDocumentData model = new DocumentModel();

            foreach (ControlDataWrapper wrapper in controlwrappers)
            {
                ControlData control = new ControlData(wrapper.name, wrapper.type);
                PropertyDataWrapper[] datawrappers = wrapper.Properties;
                foreach (PropertyDataWrapper datawrapper in datawrappers)
                    control.Properties.Add(datawrapper.Property, datawrapper.Value);
                model.ControlsDictionary.Add(control.Name, control);
            }
            
            return model;
        }
开发者ID:NicolasR,项目名称:Composants,代码行数:32,代码来源:FileSerializer.cs

示例2: Save

        /// <summary>
        /// Sauvegarde le modèle dans le fichier spécifié avec le sérialiseur donné
        /// </summary>
        /// <param name="model">modèle à sauvegarder</param>
        /// <param name="filename">nom du fichier de destination</param>
        /// <param name="serializer">sérialiseur utilisé</param>
        public static void Save(IDocumentData model, string filename, ISerializer serializer)
        {            
            /*IControlData[] controls = new IControlData[model.ControlsDictionary.Count()];

            for(int i=0; i<model.ControlsDictionary.Count(); i++)
            {
                string key = model.ControlsDictionary.Keys[i];
                IControlData control = model.ControlsDictionary[key];
                controls[i] = control;
            }
            string serialization = serializer.Serialize(controls);*/
            string[][] test = new string[model.ControlsDictionary.Count][];
            ControlDataWrapper[] controls = new ControlDataWrapper[model.ControlsDictionary.Count];
            for(int indexControl=0; indexControl<model.ControlsDictionary.Count; indexControl++)
            {
                string key = model.ControlsDictionary.Keys[indexControl];
                SortedList<string, string> properties = model.ControlsDictionary[key].Properties;
                PropertyDataWrapper[] listproperties = new PropertyDataWrapper[properties.Count];
                test[indexControl] = new string[properties.Count];
                for(int indexProperty=0; indexProperty<properties.Count(); indexProperty++)
                {
                    string property = properties.Keys[indexProperty];
                    string value = properties[property];
                    listproperties[indexProperty] = new PropertyDataWrapper(property, value);
                }
                string controlName = model.ControlsDictionary[key].Name;
                string controlType = model.ControlsDictionary[key].Type;
                controls[indexControl] = new ControlDataWrapper(controlName, controlType, listproperties);
            }

            string serialization = serializer.Serialize(controls);
            ControlDataWrapper[] final = serializer.UnSerialize(serialization);

            SaveFile(filename, serialization);
        }
开发者ID:NicolasR,项目名称:Composants,代码行数:41,代码来源:FileSerializer.cs


注:本文中的ISerializer.UnSerialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。