Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 public ControlDataWrapper(string name, string type, PropertyDataWrapper[] properties)
 {
     this.name = name;
     this.type = type;
     this.Properties = properties;
 }