Example #1
0
        public static string ToSharpXml(this object o)
        {
#if VS2013
            // create the settings
            //var settings = new SharpSerializerBinarySettings(); // for binary mode
            var settings = new SharpSerializerXmlSettings();     // for xml mode

            // configure the type serialization
            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludeCultureInTypeName         = false;
            settings.IncludePublicKeyTokenInTypeName  = false;

            // instantiate sharpSerializer

            using (var ms = new MemoryStream())
            {
                var serializer = new SharpSerializer(settings);
                serializer.Serialize(o, ms);
                ms.Flush();
                ms.Position = 0;
                var sr = new StreamReader(ms);
                return(sr.ReadToEnd());
            }
#else
            throw new NotImplementedException();
#endif
        }
Example #2
0
        public static object DeserializeObject(string xmlOfAnObject)
        {
            if (xmlOfAnObject.StartsWith("?"))
            {
                xmlOfAnObject = xmlOfAnObject.Remove(0, 1);
            }

            if (xmlOfAnObject.Equals("<null/>"))
            {
                return(null);
            }

            //return JsonConvert.DeserializeObject(xmlOfAnObject);


            var settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludeCultureInTypeName         = false;
            settings.IncludePublicKeyTokenInTypeName  = false;

            var serializer = new SharpSerializer(settings);

            serializer.PropertyProvider.AttributesToIgnore.Clear();
            // remove default ExcludeFromSerializationAttribute for performance gain
            //serializer.PropertyProvider.AttributesToIgnore.Add(typeof(XmlIgnoreAttribute));
            byte[] bajty = Encoding.UTF8.GetBytes(xmlOfAnObject);
            using (var ms = new MemoryStream(bajty))
            {
                object obiekt = serializer.Deserialize(ms);

                return(obiekt);
            }
        }
Example #3
0
        public static string ToXml(this object obj)
        {
            var settings = new SharpSerializerXmlSettings
            {
                AdvancedSettings = new AdvancedSharpSerializerXmlSettings
                {
                    TypeNameConverter = new TypeNameConverter()
                },

                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false,
            };

            var serializer = new SharpSerializer()
            {
                RootName = obj.GetType().Name
            };

            using (var stream = new MemoryStream())
            {
                var    text = string.Empty;
                string xml;

                serializer.Serialize(obj, stream);

                stream.Seek(0, SeekOrigin.Begin);

                xml = stream.ToText();

                return(xml);
            }
        }
Example #4
0
        public static string ToXml(this object obj, Func <Type, PropertyInfo, bool> propertyHandlerCallback, Func <Type, bool> collectionItemHandlerCallback)
        {
            var settings = new SharpSerializerXmlSettings
            {
                AdvancedSettings = new AdvancedSharpSerializerXmlSettings
                {
                    TypeNameConverter = new TypeNameConverter()
                },

                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false,
            };

            var propertySerializer = new PropertySerializer(obj, propertyHandlerCallback, collectionItemHandlerCallback);
            var serializer         = new SharpSerializer()
            {
                PropertyProvider = propertySerializer, RootName = obj.GetType().Name
            };

            using (var stream = new MemoryStream())
            {
                var    text = string.Empty;
                string xml;

                serializer.Serialize(obj, stream);

                stream.Seek(0, SeekOrigin.Begin);

                xml = stream.ToText();

                return(xml);
            }
        }
        public IList <IListField> GetFields(int listId)
        {
            return(cacheManager.Get("Fields_GetFields_" + listId, ctx =>
            {
                ctx.Monitor(signals.When("FieldsOfList_Changed"));
                var records = Repository.Table.Where(x => x.ListId == listId).OrderBy(x => x.Position).ToList();
                var result = new List <IListField>();

                var settings = new SharpSerializerXmlSettings
                {
                    IncludeAssemblyVersionInTypeName = false,
                    IncludeCultureInTypeName = false,
                    IncludePublicKeyTokenInTypeName = false
                };

                var sharpSerializer = new SharpSerializer(settings);

                foreach (var record in records)
                {
                    if (string.IsNullOrEmpty(record.FieldProperties))
                    {
                        continue;
                    }

                    var field = (IListField)sharpSerializer.DeserializeFromString(record.FieldProperties);
                    field.Id = record.Id;
                    result.Add(field);
                }

                return result;
            }));
        }
        public static byte[] SharpSerializer_XML_serialize_WithExclusion_ToByteArray(object myobj, List <KeyValuePair <Type, List <String> > > excludedProperties)
        {
            var settings = new SharpSerializerXmlSettings();

            settings.Encoding = System.Text.Encoding.ASCII;
            settings.AdvancedSettings.RootName = "r"; // to keep it short
            SharpSerializer serializer = new SharpSerializer(settings);

            using (var memoryStream = new MemoryStream())
            {
                if (excludedProperties != null)
                {
                    foreach (KeyValuePair <Type, List <String> > excKVP in excludedProperties)
                    {
                        foreach (string excPropertyName in excKVP.Value)
                        {
                            serializer.PropertyProvider.PropertiesToIgnore.Add(excKVP.Key, excPropertyName);
                        }
                    }
                }

                serializer.Serialize(myobj, memoryStream);
                return(memoryStream.ToArray());
            }
        }
Example #7
0
 public static void Serialize(SyncHistory history, string path)
 {
     SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
     settings.IncludeAssemblyVersionInTypeName = false;
     settings.IncludePublicKeyTokenInTypeName = false;
     SharpSerializer serializer = new SharpSerializer(settings);
     serializer.Serialize(history, path);
 }
Example #8
0
        private SharpSerializer CreateSerializer(IContainer container)
        {
            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();

            settings.InstanceCreator = new AutofacInstanceCreator(container);

            return(new SharpSerializer(settings));
        }
        private static void TextEncoding(SharpSerializerXmlSettings settings)
        {
            // Encoding
            // Default Encoding is UTF8. Encoding impacts the format in which the whole Xml file is stored.
            settings.Encoding = System.Text.Encoding.ASCII;

            return;
        }
        private static void TextEncoding(SharpSerializerXmlSettings settings)
        {
            // Encoding
            // Default Encoding is UTF8. Encoding impacts the format in which the whole Xml file is stored.
            settings.Encoding = System.Text.Encoding.ASCII;

            return;
        }
Example #11
0
        public static void Serialize(SyncHistory history, string path)
        {
            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName  = false;
            SharpSerializer serializer = new SharpSerializer(settings);

            serializer.Serialize(history, path);
        }
Example #12
0
        public static T Deserialize <T>(string path)
        {
            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName  = false;
            SharpSerializer serializer = new SharpSerializer(settings);

            return((T)serializer.Deserialize(path));
        }
Example #13
0
        public static void Serialize <T>(Stream stream, T value)
        {
            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName  = false;
            SharpSerializer serializer = new SharpSerializer(settings);

            serializer.Serialize(value, stream);
        }
Example #14
0
        public static void Serialize <T>(string path, T value)
        {
            var settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName  = false;
            var serializer = new SharpSerializer(settings);

            serializer.Serialize(value, path);
        }
Example #15
0
        public static T Deserialize <T>(string path)
        {
            var settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName   = false;
            settings.IncludePublicKeyTokenInTypeName    = false;
            settings.AdvancedSettings.TypeNameConverter = new LegacyTypeNameConverter();
            var serializer = new SharpSerializer(settings);

            return((T)serializer.Deserialize(path));
        }
        public static string SharpSerialize <T>(this T item)
        {
            var sharpSettings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false
            };

            return(new SharpSerializer(sharpSettings).Serialize(item));
        }
Example #17
0
        public void GenerateTestConfig()
        {
            List<TrackItem> items = new List<TrackItem>();
            items.Add(new TrackItem() { Path = @"$/Sandbox/litvinov/XPF/DevExpress.Xpf.Core", ProjectPath = "DevExpress.Xpf.Core" });
            TrackBranch branch = new TrackBranch("2015.2", "$/Sandbox/litvinov/XPF/track2015.2.config", "$/Sandbox/litvinov/XPF", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName = false;
            SharpSerializer serializer = new SharpSerializer(settings);
            serializer.Serialize(new List<TrackBranch>() { branch }, @"c:\1\trackconfig_testxpf.config");
        }
        public ActionResult Update(ListFieldModel model)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            var record = model.Id != 0 ? listFieldService.GetById(model.Id) : new ListField();

            record.Title    = model.Title.Trim();
            record.Name     = model.Name.Trim();
            record.ListId   = model.ListId;
            record.Position = model.Position;
            record.Required = model.Required;

            // Validate unique name
            if (model.Id == 0)
            {
                var name = Regex.Replace(record.Name, "[^0-9a-zA-Z]+", "");
                if (!model.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(new AjaxResult().Alert(T("The field name contains invalid characters, please make sure field name can have only a-z and 0-9 characters.")));
                }

                var otherField = listFieldService.GetRecord(x => x.ListId == record.ListId && x.Name == record.Name);
                if (otherField != null || record.Name.Equals("Title", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(new AjaxResult().Alert(T("Have other field with same name, please make sure unique name for field.")));
                }
            }

            var fieldType = Type.GetType(model.FieldType);
            var fields    = WorkContext.Resolve <IEnumerable <IListField> >();
            var field     = fields.First(x => x.GetType() == fieldType);

            TryUpdateModel(field, fieldType);

            var settings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false
            };

            var sharpSerializer = new SharpSerializer(settings);

            record.FieldProperties = sharpSerializer.Serialize(field);
            record.FieldType       = field.FieldType;

            listFieldService.Save(record);

            return(new AjaxResult().NotifyMessage("UPDATE_ENTITY_COMPLETE").CloseModalDialog());
        }
Example #19
0
        void GenerateXpfCommonConfig(string branchName)
        {
            List <TrackItem> items = new List <TrackItem>();

            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Mvvm", ProjectPath = "DevExpress.Mvvm"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Core", ProjectPath = "DevExpress.Xpf.Core"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Controls", ProjectPath = "DevExpress.Xpf.Controls"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Grid", ProjectPath = "DevExpress.Xpf.Grid"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Xpf.NavBar", ProjectPath = "DevExpress.Xpf.NavBar"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Xpf.PropertyGrid", ProjectPath = "DevExpress.Xpf.PropertyGrid"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Ribbon", ProjectPath = "DevExpress.Xpf.Ribbon"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Layout", ProjectPath = "DevExpress.Xpf.Layout"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/XPF/DevExpress.Xpf.LayoutControl", ProjectPath = "DevExpress.Xpf.LayoutControl"
            });
            TrackBranch branch = new TrackBranch($"{branchName}", $@"$/{branchName}/Common/xpf_common_sync.config", $@"$/{branchName}/XPF", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName  = false;
            SharpSerializer serializer = new SharpSerializer(settings);

            serializer.Serialize(new List <TrackBranch>()
            {
                branch
            }, $@"z:\trackconfig_common_{branchName}.config");
        }
Example #20
0
 public static T Deserialize <T>(Stream stream)
 {
     try {
         SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
         settings.IncludeAssemblyVersionInTypeName = false;
         settings.IncludePublicKeyTokenInTypeName  = false;
         SharpSerializer serializer = new SharpSerializer(settings);
         return((T)serializer.Deserialize(stream));
     }
     catch (Exception) {
         return(default(T));
     }
 }
Example #21
0
        public override string ToString()
        {
            var settings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false
            };

            var serializer = new SharpSerializer(settings);

            return(serializer.Serialize(this));
        }
Example #22
0
        public static MailMessageWrapper Create(string str)
        {
            var settings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false
            };

            var serializer = new SharpSerializer(settings);

            return((MailMessageWrapper)serializer.DeserializeFromString(str));
        }
Example #23
0
        public void WriteSetting <TSetting>(string pOwner, string pName, object pDefaultValue, object pValue, eScope pScope)
        {
            string         fName    = FileName(pOwner);
            List <Setting> Settings = new List <Setting>();

            if (File.Exists(fName))
            {
                Settings = (List <Setting>)(new SharpSerializer()).Deserialize(fName);

                int pos = IndexOf(Settings, s => s.Owner == pOwner && s.Name == pName);
                if (pos != -1)
                {
                    Settings.RemoveAt(pos);
                }
            }
            Setting setting = new Setting(pName, pOwner, pDefaultValue, pValue, pScope);

            //if setting exists remove it from list **************  make one liner


            switch (typeof(TSetting).Name)
            {
            case "Font":
                setting.Value        = (new SerializableFont((Font)pValue));
                setting.DefaultValue = (new SerializableFont((Font)pDefaultValue));
                break;

            case "Color":
                setting.Value        = (new SerializableColor((Color)pValue));
                setting.DefaultValue = (new SerializableColor((Color)pDefaultValue));
                break;
            }

            Settings.Add(setting);

            if (File.Exists(fName))
            {
                File.Delete(fName);
            }

            // adjust for culture
            SharpSerializerXmlSettings xmlSettings = new SharpSerializerXmlSettings();

            xmlSettings.Culture  = System.Globalization.CultureInfo.CurrentCulture;
            xmlSettings.Encoding = System.Text.Encoding.Unicode;
            //Polenter.Serialization.Advanced.PropertyProvider pp = new Polenter.Serialization.Advanced.PropertyProvider();

            //serializer.
            (new SharpSerializer(xmlSettings)).Serialize(Settings, fName);
        }
Example #24
0
 /// <summary>
 /// Returns the fully rehydrated object based upon the given XML.
 /// </summary>
 /// <param name="xml">The xml that represents object.</param>
 /// <returns>Fully rehydrated object.</returns>
 public static object DeserializeFromXml(string xml)
 {
     using (var memStream = new MemoryStream(Encoding.Unicode.GetBytes(xml)))
     {
         var settings = new SharpSerializerXmlSettings
         {
             IncludeAssemblyVersionInTypeName = true,
             IncludeCultureInTypeName = true,
             IncludePublicKeyTokenInTypeName = true
         };
         SharpSerializer ser = new SharpSerializer(settings);
         return ser.Deserialize(memStream);
     }
 }
Example #25
0
 void GenerateRepoConfig(string branch, string taskName, string watchTaskName, string defaultService, bool allowTesting = false,  string[] testConfigs = null)
 {
     RepoConfig config = new RepoConfig() {
         Name = branch,
         FarmTaskName = watchTaskName,
         FarmSyncTaskName = taskName,
         DefaultServiceName = defaultService,
         SupportsTesting = allowTesting,
     };
     SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
     settings.IncludeAssemblyVersionInTypeName = false;
     settings.IncludePublicKeyTokenInTypeName = false;
     SharpSerializer serializer = new SharpSerializer(settings);
     serializer.Serialize(config, @"z:\gitconfig.config");
 }
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            var record = listFieldService.GetById(id);
            var list   = record.List ?? listService.GetById(record.ListId);

            WorkContext.Breadcrumbs.Add(T("Manage Lists"), Url.Action("Index", "List", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(list.Name);
            WorkContext.Breadcrumbs.Add(T("Fields"), Url.Action("Index", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(record.Name);
            WorkContext.Breadcrumbs.Add(T("Edit"));

            var settings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false
            };

            var sharpSerializer = new SharpSerializer(settings);

            var field = (IListField)sharpSerializer.DeserializeFromString(record.FieldProperties);

            if (field.Id == 0)
            {
                field.Id = id;
            }

            var result = new ControlFormResult <IListField>(field, field.GetType())
            {
                Title                = T("Edit Field").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.ExcludeProperty(x => x.Name);

            result.AddHiddenValue("Name", record.Name);
            result.AddHiddenValue("FieldType", GetFullTypeName(field.GetType()));

            return(result);
        }
Example #27
0
        public IList <IWidget> GetWidgets(IEnumerable <Widget> records)
        {
            var settings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false
            };
            var sharpSerializer = new SharpSerializer(settings);

            var result = new List <IWidget>();

            foreach (var record in records)
            {
                IWidget widget;
                try
                {
                    widget = (IWidget)sharpSerializer.DeserializeFromString(record.WidgetValues);
                }
                catch (InvalidCastException)
                {
                    continue;
                }
                catch (TypeLoadException)
                {
                    continue;
                }
                catch (DeserializingException)
                {
                    continue;
                }

                widget.Id               = record.Id;
                widget.Title            = record.Title;
                widget.ZoneId           = record.ZoneId;
                widget.PageId           = record.PageId;
                widget.Order            = record.Order;
                widget.Enabled          = record.Enabled;
                widget.DisplayCondition = record.DisplayCondition;
                widget.CultureCode      = record.CultureCode;
                widget.RefId            = record.RefId;
                result.Add(widget);
            }
            return(result);
        }
Example #28
0
         public void Save(string targetPath)
         {
             try
             {
                 // if the file isn't there, we can't deserialize.
                 if (String.IsNullOrEmpty(targetPath))
                     targetPath = GetDefaultPath();
 
                 SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
                 SharpSerializer serializer = new SharpSerializer(settings);
                 // create a serialized representation of our MySettings instance, and write it to a file.
                 serializer.Serialize(this, targetPath);
             }
             catch (Exception err)
             {
                 throw new InvalidOperationException(string.Format("Error in MySettings.Save(string targetPath):\r\nMessage:\r\n{0}\r\nStackTrace:\r\n{1}", err.Message, err.StackTrace), err);
             }
         }
Example #29
0
        public static T SharpDeserialize <T>(this string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return(default(T));
            }

            var settings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false
            };

            var sharpSerializer = new SharpSerializer(settings);

            return((T)sharpSerializer.DeserializeFromString(s));
        }
Example #30
0
        void GenerateRepoConfig(string branch, string taskName, string watchTaskName, string defaultService, bool allowTesting = false, string[] testConfigs = null)
        {
            RepoConfig config = new RepoConfig()
            {
                Name               = branch,
                FarmTaskName       = watchTaskName,
                FarmSyncTaskName   = taskName,
                DefaultServiceName = defaultService,
                SupportsTesting    = allowTesting,
            };
            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName  = false;
            SharpSerializer serializer = new SharpSerializer(settings);

            serializer.Serialize(config, @"z:\gitconfig.config");
        }
Example #31
0
        public void Save(string targetPath)
        {
            try
            {
                if (String.IsNullOrEmpty(targetPath))
                {
                    targetPath = GetDefaultPath();
                }

                SharpSerializerXmlSettings settings   = new SharpSerializerXmlSettings();
                SharpSerializer            serializer = new SharpSerializer(settings);

                serializer.Serialize(this, targetPath);
            }
            catch (Exception err)
            {
                throw new InvalidOperationException(string.Format("Error in MySettings.Save(string targetPath):\r\nMessage:\r\n{0}\r\nStackTrace:\r\n{1}", err.Message, err.StackTrace), err);
            }
        }
Example #32
0
 public static MySettings Load(string path)
 {
     if (!System.IO.File.Exists(path))
     {
         throw new System.ArgumentException("File \"" + path + "\" does not exist.");
     }
     try
     {
         MySettings result = null;
         SharpSerializerXmlSettings settings   = new SharpSerializerXmlSettings();
         SharpSerializer            serializer = new SharpSerializer(settings);
         result = (MySettings)serializer.Deserialize(path);
         return(result);
     }
     catch (Exception err)
     {
         throw new InvalidOperationException(string.Format("Error in MySettings.LoadConfiguration():\r\nMessage:\r\n{0}\r\nStackTrace:\r\n{1}", err.Message, err.StackTrace), err);
     }
 }
Example #33
0
 //
 public static MySettings Load(string path)
 {
     if (!System.IO.File.Exists(path)) throw new System.ArgumentException("File \"" + path + "\" does not exist.");
     try
     {
         MySettings result = null;
         // the serialization settings are just a needed standard object as long as you don't want to do something special.
         SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
         // create the serializer.
         SharpSerializer serializer = new SharpSerializer(settings);
         // deserialize from File and receive an object containing our deserialized settings, that means: a MySettings Object with every public property in the state that they were saved in.
         result = (MySettings)serializer.Deserialize(path);
         // return deserialized settings.
         return result;
     }
     catch (Exception err)
     {
         throw new InvalidOperationException(string.Format("Error in MySettings.LoadConfiguration():\r\nMessage:\r\n{0}\r\nStackTrace:\r\n{1}", err.Message, err.StackTrace), err);
     }
 }
Example #34
0
        void GenerateUWPDemoConfig(string branchName)
        {
            List <TrackItem> items = new List <TrackItem>();

            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/Demos.UWP/DemoLauncher", ProjectPath = "DemoLauncher"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/Demos.UWP/DevExpress.PackageRegistrator", ProjectPath = "DevExpress.PackageRegistrator"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/Demos.UWP/DXCRM", ProjectPath = "DXCRM"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/Demos.UWP/FeatureDemo", ProjectPath = "FeatureDemo"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/Demos.UWP/FinanceTracker", ProjectPath = "FinanceTracker"
            });
            items.Add(new TrackItem()
            {
                Path = $@"$/{branchName}/Demos.UWP/HybridDemo", ProjectPath = "HybridDemo"
            });
            TrackBranch branch = new TrackBranch($"{branchName}", $@"$/{branchName}/Demos.UWP.GIT/sync.config", $@"$/{branchName}", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName  = false;
            SharpSerializer serializer = new SharpSerializer(settings);

            serializer.Serialize(new List <TrackBranch>()
            {
                branch
            }, $@"z:\trackconfig_uwp_demos_{branchName}.config");
        }
Example #35
0
        public void GenerateTestConfig()
        {
            List <TrackItem> items = new List <TrackItem>();

            items.Add(new TrackItem()
            {
                Path = @"$/Sandbox/litvinov/XPF/DevExpress.Xpf.Core", ProjectPath = "DevExpress.Xpf.Core"
            });
            TrackBranch branch = new TrackBranch("2015.2", "$/Sandbox/litvinov/XPF/track2015.2.config", "$/Sandbox/litvinov/XPF", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();

            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName  = false;
            SharpSerializer serializer = new SharpSerializer(settings);

            serializer.Serialize(new List <TrackBranch>()
            {
                branch
            }, @"c:\1\trackconfig_testxpf.config");
        }
Example #36
0
        void GenerateWinRTConfig(string branchName)
        {
            List<TrackItem> items = new List<TrackItem>();
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.Core", ProjectPath = "DevExpress.Core" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.Drawing", ProjectPath = "DevExpress.Drawing" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.Pdf.Core", ProjectPath = "DevExpress.Pdf.Core" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.TestFramework", ProjectPath = "DevExpress.TestFramework" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.TestRunner", ProjectPath = "DevExpress.TestRunner" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.TestsKey", ProjectPath = "DevExpress.TestsKey" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.TestUtils", ProjectPath = "DevExpress.TestUtils" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.UI.Xaml", ProjectPath = "DevExpress.UI.Xaml" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.UI.Xaml.Charts", ProjectPath = "DevExpress.UI.Xaml.Charts" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.UI.Xaml.Controls", ProjectPath = "DevExpress.UI.Xaml.Controls" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.UI.Xaml.Editors", ProjectPath = "DevExpress.UI.Xaml.Editors" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.UI.Xaml.Gauges", ProjectPath = "DevExpress.UI.Xaml.Gauges" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.UI.Xaml.Grid", ProjectPath = "DevExpress.UI.Xaml.Grid" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.UI.Xaml.Layout", ProjectPath = "DevExpress.UI.Xaml.Layout" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.UI.Xaml.Map", ProjectPath = "DevExpress.UI.Xaml.Map" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.WinRT.Projects.Installers", ProjectPath = "DevExpress.WinRT.Projects.Installers" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/DevExpress.WinRT.Projects.Wizards", ProjectPath = "DevExpress.WinRT.Projects.Wizards" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/Shared", ProjectPath = "Shared" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/WinRT/Tools", ProjectPath = "Tools" });
            TrackBranch branch = new TrackBranch($"{branchName}", $@"$/{branchName}/UWP.GIT/sync.config", $@"$/{branchName}", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName = false;
            SharpSerializer serializer = new SharpSerializer(settings);
            serializer.Serialize(new List<TrackBranch>() { branch }, $@"z:\trackconfig_uwp_{branchName}.config");
        }
Example #37
0
        void GenerateAspConfig(string branchName)
        {
            List<TrackItem> items = new List<TrackItem>();
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/ASPxThemeBuilder", ProjectPath = "ASPxThemeBuilder" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/ASPxThemeDeployer", ProjectPath = "ASPxThemeDeployer" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web", ProjectPath = "DevExpress.Web" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.ASPxHtmlEditor", ProjectPath = "DevExpress.Web.ASPxHtmlEditor" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.ASPxRichEdit", ProjectPath = "DevExpress.Web.ASPxRichEdit" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.ASPxRichEdit.Tests", ProjectPath = "DevExpress.Web.ASPxRichEdit.Tests" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.ASPxScheduler", ProjectPath = "DevExpress.Web.ASPxScheduler" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.ASPxSpellChecker", ProjectPath = "DevExpress.Web.ASPxSpellChecker" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.ASPxSpreadsheet", ProjectPath = "DevExpress.Web.ASPxSpreadsheet" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.ASPxThemes", ProjectPath = "DevExpress.Web.ASPxThemes" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.ASPxTreeList", ProjectPath = "DevExpress.Web.ASPxTreeList" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.Design", ProjectPath = "DevExpress.Web.Design" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.Mvc", ProjectPath = "DevExpress.Web.Mvc" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/ASP/DevExpress.Web.Projects", ProjectPath = "DevExpress.Web.Projects" });

            TrackBranch branch = new TrackBranch($"{branchName}", $@"$/{branchName}/Diagram/xpf_common_sync.config", $@"$/{branchName}", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName = false;
            SharpSerializer serializer = new SharpSerializer(settings);
            serializer.Serialize(new List<TrackBranch>() { branch }, $@"z:\trackconfig_asp_{branchName}.config");
        }
Example #38
0
        public static void InitializeSharpSerializer()
        {
            var sxs = new SharpSerializerXmlSettings();
            sxs.AdvancedSettings.AttributesToIgnore.Add(typeof(ContentSerializerIgnoreAttribute));
            sxs.IncludeAssemblyVersionInTypeName = false;
            sxs.IncludeCultureInTypeName = false;
            sxs.IncludePublicKeyTokenInTypeName = false;

            //simple types to include
            sxs.AdvancedSettings.SimpleTypes = new Polenter.Serialization.Core.SimpleTypes(new Type[]
            {
                typeof(Range),
                typeof(TimedRange),
                typeof(Vector2),
                typeof(Vector3),
                typeof(List<Color>)
            });
            sxs.AdvancedSettings.SimpleValueConverter = new Delta.Serialization.DeltaSimpleValueConverter();
            sharpSerializer = new SharpSerializer(sxs);
        }
Example #39
0
        void GenerateUWPDemoConfig(string branchName)
        {
            List<TrackItem> items = new List<TrackItem>();
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Demos.UWP/DemoLauncher", ProjectPath = "DemoLauncher" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Demos.UWP/DevExpress.PackageRegistrator", ProjectPath = "DevExpress.PackageRegistrator" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Demos.UWP/DXCRM", ProjectPath = "DXCRM" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Demos.UWP/FeatureDemo", ProjectPath = "FeatureDemo" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Demos.UWP/FinanceTracker", ProjectPath = "FinanceTracker" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Demos.UWP/HybridDemo", ProjectPath = "HybridDemo" });
            TrackBranch branch = new TrackBranch($"{branchName}", $@"$/{branchName}/Demos.UWP.GIT/sync.config", $@"$/{branchName}", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName = false;
            SharpSerializer serializer = new SharpSerializer(settings);
            serializer.Serialize(new List<TrackBranch>() { branch }, $@"z:\trackconfig_uwp_demos_{branchName}.config");
        }
Example #40
0
        void GenerateDataAccessConfig(string branchName)
        {
            List<TrackItem> items = new List<TrackItem>();
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Win/DevExpress.DataAccess", ProjectPath = "DevExpress.DataAccess", AdditionalOffset = "Win" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/BigQueryTests", ProjectPath = "BigQueryTests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/DataAccessTests", ProjectPath = "DataAccessTests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/EntityFramework7Tests", ProjectPath = "EntityFramework7Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/MsSqlCEEF7Tests", ProjectPath = "MsSqlCEEF7Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/MsSqlEF5Tests", ProjectPath = "MsSqlEF5Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/MsSqlEF6Tests", ProjectPath = "MsSqlEF6Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/MsSqlEF7Tests", ProjectPath = "MsSqlEF7Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/MySqlEF6Tests", ProjectPath = "MySqlEF6Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/PostgreSqlEF7Tests", ProjectPath = "PostgreSqlEF7Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/PostgreSqlEF7Tests", ProjectPath = "PostgreSqlEF7Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/SqliteEF7Tests", ProjectPath = "SqliteEF7Tests", AdditionalOffset = "Tests.DataAccess" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Tests.DataAccess/WizardTests", ProjectPath = "WizardTests", AdditionalOffset = "Tests.DataAccess" });
            TrackBranch branch = new TrackBranch($"{branchName}", $@"$/{branchName}/DataAccess/sync.config", $@"$/{branchName}", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName = false;
            SharpSerializer serializer = new SharpSerializer(settings);
            serializer.Serialize(new List<TrackBranch>() { branch }, $@"z:\trackconfig_dataaccess_{branchName}.config");
        }
Example #41
0
        private void initialize(SharpSerializerXmlSettings settings) {
            // PropertiesToIgnore
            PropertyProvider.PropertiesToIgnore = settings.AdvancedSettings.PropertiesToIgnore;
            PropertyProvider.AttributesToIgnore = settings.AdvancedSettings.AttributesToIgnore;
            //RootName
            RootName = settings.AdvancedSettings.RootName;
            // TypeNameConverter)
            var typeNameConverter = settings.AdvancedSettings.TypeNameConverter ?? DefaultInitializer.GetTypeNameConverter(settings.IncludeAssemblyVersionInTypeName, settings.IncludeCultureInTypeName, settings.IncludePublicKeyTokenInTypeName, settings.FindPluginAssembly);
            // SimpleValueConverter
            var simpleValueConverter = settings.AdvancedSettings.SimpleValueConverter ?? DefaultInitializer.GetSimpleValueConverter(settings.Culture, typeNameConverter);
            // XmlWriterSettings
            var xmlWriterSettings = DefaultInitializer.GetXmlWriterSettings(settings.Encoding);
            // XmlReaderSettings
            var xmlReaderSettings = DefaultInitializer.GetXmlReaderSettings();

            // Create Serializer and Deserializer
            var reader = new DefaultXmlReader(typeNameConverter, simpleValueConverter, xmlReaderSettings);
            var writer = new DefaultXmlWriter(typeNameConverter, simpleValueConverter, xmlWriterSettings);

            _serializer = new XmlPropertySerializer(writer);
            _deserializer = new XmlPropertyDeserializer(reader);
        }
Example #42
0
 /// <summary>
 ///   Xml serialization with custom settings
 /// </summary>
 /// <param name = "settings"></param>
 public SharpSerializer(SharpSerializerXmlSettings settings) {
     if (settings == null) {
         throw new ArgumentNullException("settings");
     }
     initialize(settings);
 }
        public void XmlSerial_TwoIdenticalChildsShouldBeSameInstance()
        {
            var parent = new ParentChildTestClass()
            {
                Name = "parent",
            };

            var child = new ParentChildTestClass()
            {
                Name = "child",
                Father = parent,
                Mother = parent,
            };

            Assert.AreSame(child.Father, child.Mother, "Precondition: Saved Father and Mother are same instance");

            var stream = new MemoryStream();
            var settings = new SharpSerializerXmlSettings();
            var serializer = new SharpSerializer(settings);

            serializer.Serialize(child, stream);

            /*
                <Complex name="Root" type="Polenter.Serialization.XmlSerialisationTests+ParentChildTestClass, SharpSerializer.Tests">
                    <Properties>
                        <Simple name="Name" value="child" />
                        <Complex name="Mother" id="1">
                            <Properties>
                                <Simple name="Name" value="parent" />
                                <Null name="Mother" />
                                <Null name="Father" />
                            </Properties>
                        </Complex>
                        <ComplexReference name="Father" id="1" />
                    </Properties>
                </Complex>
             */
            stream.Position = 0;
            XmlDocument doc = new XmlDocument();
            doc.Load(stream);
            System.Console.WriteLine(doc.InnerXml);

            serializer = new SharpSerializer(settings);
            stream.Position = 0;
            ParentChildTestClass loaded = serializer.Deserialize(stream) as ParentChildTestClass;

            Assert.AreSame(loaded.Father, loaded.Mother, "Loaded Father and Mother are same instance");
        }
        private static XmlDocument Save(object data)
        {
            var stream = new MemoryStream();
            var settings = new SharpSerializerXmlSettings();

            settings.AdvancedSettings.PropertiesToIgnore.Add(typeof(Class2BeSerialized), "NameRule");
            settings.AdvancedSettings.PropertiesToIgnore.Add(typeof(Class2BeSerialized), "ComplexRule");

            settings.AdvancedSettings.AttributesToIgnore.Add(typeof(MyExcludeAttribute));
            // this does not work
            //settings.AdvancedSettings.PropertiesToIgnore.Add(null, "NameRule");
            //settings.AdvancedSettings.PropertiesToIgnore.Add(null, "ComplexRule");
            var serializer = new SharpSerializer(settings);

            serializer.Serialize(data, stream);

            stream.Position = 0;

            XmlDocument doc = new XmlDocument();
            doc.Load(stream);

            return doc;
        }
        public void XmlSerial_ShouldSerializeGuid()
        {
            var parent = new ClassWithGuid()
            {
                Guid = Guid.NewGuid(),
            };

            var stream = new MemoryStream();
            var settings = new SharpSerializerXmlSettings();
            var serializer = new SharpSerializer(settings);

            serializer.Serialize(parent, stream);

            stream.Position = 0;
            XmlDocument doc = new XmlDocument();
            doc.Load(stream);
            System.Console.WriteLine(doc.InnerXml);

            serializer = new SharpSerializer(settings);
            stream.Position = 0;
            ClassWithGuid loaded = serializer.Deserialize(stream) as ClassWithGuid;

            Assert.AreEqual(parent.Guid, loaded.Guid, "same guid");
        }
Example #46
0
        /// <summary>
        /// Returns the XML representation of the given object.
        /// </summary>
        /// <param name="entity">The object to serialize into XML.</param>
        /// <returns>XML String representation of object.</returns>
        public static string SerializeToXml(object entity)
        {
            if (entity == null) return string.Empty;

            string result;

            var settings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = true,
                IncludeCultureInTypeName = true,
                IncludePublicKeyTokenInTypeName = true
            };
            SharpSerializer ser = new SharpSerializer(settings);
            using (MemoryStream memStream = new MemoryStream())
            {
                using (var sw = new StreamWriter(memStream))
                {
                    ser.Serialize(entity, memStream);
                    sw.Flush();

                    memStream.Position = 0;
                    using (var sr = new StreamReader(memStream))
                    {
                        result = sr.ReadToEnd();
                    }
                }
            }

            return result;
        }
Example #47
0
        void GenerateXpfCommonConfig(string branchName)
        {
            List<TrackItem> items = new List<TrackItem>();
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Mvvm", ProjectPath = "DevExpress.Mvvm" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Core", ProjectPath = "DevExpress.Xpf.Core" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Controls", ProjectPath = "DevExpress.Xpf.Controls" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Grid", ProjectPath = "DevExpress.Xpf.Grid" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.NavBar", ProjectPath = "DevExpress.Xpf.NavBar" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.PropertyGrid", ProjectPath = "DevExpress.Xpf.PropertyGrid" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Ribbon", ProjectPath = "DevExpress.Xpf.Ribbon" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Layout", ProjectPath = "DevExpress.Xpf.Layout" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.LayoutControl", ProjectPath = "DevExpress.Xpf.LayoutControl" });
            TrackBranch branch = new TrackBranch($"{branchName}", $@"$/{branchName}/Common/xpf_common_sync.config", $@"$/{branchName}/XPF", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName = false;
            SharpSerializer serializer = new SharpSerializer(settings);
            serializer.Serialize(new List<TrackBranch>() { branch }, $@"z:\trackconfig_common_{branchName}.config");
        }
Example #48
0
        void GenerateXpfDiagramConfig(string branchName)
        {
            List<TrackItem> items = new List<TrackItem>();
            items.Add(new TrackItem() { Path = $@"$/{branchName}/Win/DevExpress.XtraDiagram", ProjectPath = "DevExpress.XtraDiagram", AdditionalOffset = "Win" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Diagram", ProjectPath = "DevExpress.Xpf.Diagram", AdditionalOffset = "XPF" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.ReportDesigner", ProjectPath = "DevExpress.Xpf.ReportDesigner", AdditionalOffset = "XPF" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.PdfViewer", ProjectPath = "DevExpress.Xpf.PdfViewer", AdditionalOffset = "XPF" });
            items.Add(new TrackItem() { Path = $@"$/{branchName}/XPF/DevExpress.Xpf.Printing", ProjectPath = "DevExpress.Xpf.Printing", AdditionalOffset = "XPF" });
            TrackBranch branch = new TrackBranch($"{branchName}", $@"$/{branchName}/Diagram/xpf_common_sync.config", $@"$/{branchName}", items);

            SharpSerializerXmlSettings settings = new SharpSerializerXmlSettings();
            settings.IncludeAssemblyVersionInTypeName = false;
            settings.IncludePublicKeyTokenInTypeName = false;
            SharpSerializer serializer = new SharpSerializer(settings);
            serializer.Serialize(new List<TrackBranch>() { branch }, $@"z:\trackconfig_diagram_{branchName}.config");
        }
Example #49
0
        private SharpSerializerXmlSettings createXmlSettings()
        {
            // create the settings instance
            var settings = new SharpSerializerXmlSettings();

            // Bare instance of SharpSerializerXmlSettings is enough for SharpSerializer to know,
            // it should serialize data as xml.

            // However there is more you can influence.

            // Culture
            // All float numbers and date/time values are serialized as text according to the Culture.
            // The default Culture is InvariantCulture but you can override this settings with your own culture.
            settings.Culture = System.Globalization.CultureInfo.CurrentCulture;

            // Encoding
            // Default Encoding is UTF8. Encoding impacts the format in which the whole Xml file is stored.
            settings.Encoding = System.Text.Encoding.ASCII;

            // AssemblyQualifiedName
            // During serialization all types must be converted to strings.
            // Since v.2.12 the type is stored as an AssemblyQualifiedName per default.
            // You can force the SharpSerializer to shorten the type descriptions
            // by setting the following properties to false
            // Example of AssemblyQualifiedName:
            // "System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            // Example of the short type name:
            // "System.String, mscorlib"
            settings.IncludeAssemblyVersionInTypeName = true;
            settings.IncludeCultureInTypeName = true;
            settings.IncludePublicKeyTokenInTypeName = true;

            // ADVANCED SETTINGS
            // Most of the classes needed to alter these settings are in the namespace Polenter.Serialization.Advanced

            // PropertiesToIgnore
            // Sometimes you want to ignore some properties during the serialization.
            // If they are parts of your own business objects, you can mark these properties with ExcludeFromSerializationAttribute.
            // However it is not possible to mark them in the built in .NET classes
            // In such a case you add these properties to the list PropertiesToIgnore.
            // I.e. System.Collections.Generic.List<string> has the "Capacity" property which is irrelevant for
            // the whole Serialization and should be ignored
            // serializer.PropertyProvider.PropertiesToIgnore.Add(typeof(List<string>), "Capacity")
            settings.AdvancedSettings.PropertiesToIgnore.Add(typeof (List<string>), "Capacity");

            // RootName
            // There is always a root element during serialization. Default name of this element is "Root",
            // but you can change it to any other text.
            settings.AdvancedSettings.RootName = "MyFunnyClass";

            // SimpleValueConverter
            // During xml serialization all simple values are converted to their string representation.
            // Float values, DateTime are default converted to format of the settings.Culture or CultureInfo.InvariantCulture
            // if the settings.Culture is not set.
            // If you want to store these values in your own format (Morse alphabet?) create your own converter as an instance of ISimpleValueConverter.
            // Important! This setting overrides the settings.Culture
            settings.AdvancedSettings.SimpleValueConverter = new MyCustomSimpleValueConverter();

            // TypeNameConverter
            // Since the v.2.12 all types are serialized as AssemblyQualifiedName.
            // To change this you can alter the settings above (Include...) or create your own instance of ITypeNameConverter.
            // Important! This property overrides the three properties below/above:
            //    IncludeAssemblyVersionInTypeName, IncludeCultureInTypeName, IncludePublicKeyTokenInTypeName
            settings.AdvancedSettings.TypeNameConverter = new MyTypeNameConverterWithCompressedTypeNames();

            return settings;
        }