Exemplo n.º 1
0
            public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                Altaxo.Data.DataTable s = (Altaxo.Data.DataTable)obj;
                info.AddValue("Name", s._tableName);           // name of the Table
                info.AddValue("DataCols", s._dataColumns);
                info.AddValue("PropCols", s._propertyColumns); // the property columns of that table

                // new in version 1
                info.AddValue("TableScript", s._tableScript);

                // new in version 2 - Add table properties
                int numberproperties = s._tableProperties == null ? 0 : s._tableProperties.Keys.Count;

                info.CreateArray("TableProperties", numberproperties);
                if (s._tableProperties != null)
                {
                    foreach (string propkey in s._tableProperties.Keys)
                    {
                        if (propkey.StartsWith("tmp/"))
                        {
                            continue;
                        }
                        info.CreateElement("e");
                        info.AddValue("Key", propkey);
                        object val = s._tableProperties[propkey];
                        info.AddValue("Value", info.IsSerializable(val) ? val : null);
                        info.CommitElement();
                    }
                }
                info.CommitArray();
            }
Exemplo n.º 2
0
            public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                GraphDocument s = (GraphDocument)obj;

                // info.AddBaseValueEmbedded(s,typeof(GraphDocument).BaseType);
                // now the data of our class
                info.AddValue("Name", s._name);
                info.AddValue("PageBounds", s._pageBounds);
                info.AddValue("PrintableBounds", s._printableBounds);
                info.AddValue("Layers", s._layers);

                // new in version 1 - Add graph properties
                int numberproperties = s._graphProperties == null ? 0 : s._graphProperties.Keys.Count;

                info.CreateArray("TableProperties", numberproperties);
                if (s._graphProperties != null)
                {
                    foreach (string propkey in s._graphProperties.Keys)
                    {
                        if (propkey.StartsWith("tmp/"))
                        {
                            continue;
                        }
                        info.CreateElement("e");
                        info.AddValue("Key", propkey);
                        object val = s._graphProperties[propkey];
                        info.AddValue("Value", info.IsSerializable(val) ? val : null);
                        info.CommitElement();
                    }
                }
                info.CommitArray();
            }
Exemplo n.º 3
0
            public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                var s = (PropertyBagLazyLoaded)obj;

                var assemblyVersion = s.GetType().Assembly.GetName().Version;
                var keyList         = new HashSet <string>();

                foreach (var entry in s._properties)
                {
                    if (entry.Key.StartsWith(TemporaryPropertyPrefixString))
                    {
                        continue;
                    }
                    if (!info.IsSerializable(entry.Value))
                    {
                        continue;
                    }
                    keyList.Add(entry.Key);
                }
                foreach (var entry in s._propertiesLazyLoaded)
                {
                    if (entry.Key.StartsWith(TemporaryPropertyPrefixString))
                    {
                        continue;
                    }
                    keyList.Add(entry.Key);
                }

                info.CreateArray("Properties", keyList.Count);
                info.AddAttributeValue("AssemblyVersion", assemblyVersion.ToString());
                foreach (var key in keyList)
                {
                    // Since this is a lazy bag, each property is deserialized individually. Thus we must serialize it individually, too.
                    // ClearProperties clears all properties left by former serializations so that each item is serialized as if serialized individually.
                    info.ClearProperties();

                    info.CreateElement("e");
                    info.AddValue("Key", key);

                    if (s._properties.TryGetValue(key, out var value))
                    {
                        info.AddValue("Value", value);
                    }
                    else if (s._propertiesLazyLoaded.TryGetValue(key, out var rawXml))
                    {
                        info.WriteRaw(rawXml);
                    }
                    else
                    {
                        throw new InvalidOperationException("Key neither found in regular properties nor in lazy loaded properties");
                    }

                    info.CommitElement();
                }
                info.CommitArray();
            }
Exemplo n.º 4
0
            public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                FitFunctionToScalarFunctionDDWrapper s = (FitFunctionToScalarFunctionDDWrapper)obj;

                info.AddValue("IndependentVariable", s._independentVariable);
                info.AddValue("DependentVariable", s._dependentVariable);
                info.AddArray("ParameterValues", s._parameter, s._parameter.Length);

                if (s._fitFunction == null || info.IsSerializable(s._fitFunction))
                {
                    info.AddValue("FitFunction", s._fitFunction);
                }
                else
                {
                    info.AddValue("FitFunction", new Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate(s._fitFunction));
                }
            }
Exemplo n.º 5
0
            public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                var s       = (PropertyBag)obj;
                var keyList = new List <string>(s._properties.Count);

                foreach (var entry in s._properties)
                {
                    if (entry.Key.StartsWith(TemporaryPropertyPrefixString))
                    {
                        continue;
                    }
                    if (!info.IsSerializable(entry.Value))
                    {
                        continue;
                    }
                    keyList.Add(entry.Key);
                }

                info.CreateArray("Properties", keyList.Count);
                info.AddAttributeValue("AssemblyVersion", s.GetType().Assembly.GetName().Version.ToString());
                foreach (var key in keyList)
                {
                    var value = s._properties[key];

                    info.CreateElement("e");
                    info.AddValue("Key", key);

                    if (s._propertiesLazyLoaded.Contains(key) && value is string rawXml)
                    {
                        info.WriteRaw(rawXml);
                    }
                    else
                    {
                        info.AddValue("Value", value);
                    }

                    info.CommitElement();
                }
                info.CommitArray();
            }