Esempio n. 1
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                FitFunctionScript s = null != o ? (FitFunctionScript)o : new FitFunctionScript();

                // deserialize the base class
                info.GetBaseValueEmbedded(s, typeof(AbstractScript), parent);

                s._fitFunctionCategory              = info.GetString("Category");
                s._fitFunctionName                  = info.GetString("Name");
                s._fitFunctionCreationTime          = info.GetDateTime("CreationTime");
                s._NumberOfParameters               = info.GetInt32("NumberOfParameters");
                s._IsUsingUserDefinedParameterNames = info.GetBoolean("UserDefinedParameters");
                if (s._IsUsingUserDefinedParameterNames)
                {
                    info.GetArray("UserDefinedParameterNames", out s._UserDefinedParameterNames);
                }
                info.GetArray("IndependentVariableNames", out s._IndependentVariablesNames);
                info.GetArray("DependentVariableNames", out s._DependentVariablesNames);

                var surr = new XmlSerializationSurrogate1
                {
                    _deserializedObject = s
                };

                info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.info_DeserializationFinished);

                if (s._IsUsingUserDefinedParameterNames && s._NumberOfParameters != s._UserDefinedParameterNames.Length)
                {
                    s.Compile(); // dirty quick fix in the case that the userdefined parameters where not updated before serialization
                }
                return(s);
            }
Esempio n. 2
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                FitFunctionScript s = null != o ? (FitFunctionScript)o : new FitFunctionScript();


                s._fitFunctionCategory     = info.GetString("Category");
                s._fitFunctionName         = info.GetString("Name");
                s._fitFunctionCreationTime = info.GetDateTime("CreationTime");
                s._fitFunctionDescription  = info.GetString("Description");

                // deserialize the base class
                info.GetBaseValueEmbedded(s, typeof(AbstractScript), parent);

                s._NumberOfParameters = info.GetInt32("NumberOfParameters");
                s._IsUsingUserDefinedParameterNames = info.GetBoolean("UserDefinedParameters");
                if (s._IsUsingUserDefinedParameterNames)
                {
                    info.GetArray("UserDefinedParameterNames", out s._UserDefinedParameterNames);
                }
                info.GetArray("IndependentVariableNames", out s._IndependentVariablesNames);
                info.GetArray("DependentVariableNames", out s._DependentVariablesNames);

                XmlSerializationSurrogate2 surr = new XmlSerializationSurrogate2();

                surr._deserializedObject      = s;
                info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.info_DeserializationFinished);

                return(s);
            }
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                MultivariateContentMemento s = null != o ? (MultivariateContentMemento)o : new MultivariateContentMemento();

                s.OriginalDataTableName     = info.GetString("Name");
                s.SpectrumIsRow             = info.GetBoolean("SpectrumIsRow");
                s.SpectralIndices           = (IAscendingIntegerCollection)info.GetValue("SpectralIndices", s);
                s.ConcentrationIndices      = (IAscendingIntegerCollection)info.GetValue("ConcentrationIndices", s);
                s.MeasurementIndices        = (IAscendingIntegerCollection)info.GetValue("MeasurementIndices", s);
                s._PreferredNumberOfFactors = info.GetInt32("PreferredNumberOfFactors");

                // new in version 1
                info.GetArray("SpectralPreprocessingRegions", out int[] regions);
                s._spectralPreprocessing.Regions         = regions;
                s._spectralPreprocessing.Method          = (SpectralPreprocessingMethod)info.GetEnum("SpectralPreprocessingMethod", typeof(SpectralPreprocessingMethod));
                s._spectralPreprocessing.DetrendingOrder = info.GetInt32("SpectralPreprocessingDetrending");
                s._spectralPreprocessing.EnsembleScale   = info.GetBoolean("SpectralPreprocessingEnsembleScale");

                // new in version 2
                s._ClassNameOfAnalysisClass = info.GetString("ClassNameOfAnalysisClass");

                // added fix after version 2 : forgotten to serialize crossPRESSCalculationType
                if (info.GetNodeName() == "CrossPRESSCalculationType")
                {
                    s._crossPRESSCalculationType = (CrossPRESSCalculationType)info.GetValue("CrossPRESSCalculationType", s);
                }
                else
                {
                    s._crossPRESSCalculationType = CrossPRESSCalculationType.ExcludeGroupsOfSimilarMeasurements;
                }

                return(s);
            }
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                MultivariateContentMemento s = null != o ? (MultivariateContentMemento)o : new MultivariateContentMemento();

                s.OriginalDataTableName     = info.GetString("Name");
                s.SpectrumIsRow             = info.GetBoolean("SpectrumIsRow");
                s.SpectralIndices           = (IAscendingIntegerCollection)info.GetValue("SpectralIndices", s);
                s.ConcentrationIndices      = (IAscendingIntegerCollection)info.GetValue("ConcentrationIndices", s);
                s.MeasurementIndices        = (IAscendingIntegerCollection)info.GetValue("MeasurementIndices", s);
                s._PreferredNumberOfFactors = info.GetInt32("PreferredNumberOfFactors");

                // new in version 1
                if (info.CurrentElementName == "SpectralPreprocessingRegions")
                {
                    info.GetArray("SpectralPreprocessingRegions", out int[] regions);
                    s._spectralPreprocessing.Regions         = regions;
                    s._spectralPreprocessing.Method          = (SpectralPreprocessingMethod)info.GetEnum("SpectralPreprocessingMethod", typeof(SpectralPreprocessingMethod));
                    s._spectralPreprocessing.DetrendingOrder = info.GetInt32("SpectralPreprocessingDetrending");
                    s._spectralPreprocessing.EnsembleScale   = info.GetBoolean("SpectralPreprocessingEnsembleScale");
                }

                // neccessary since version 2
                s.Analysis = new PLS2WorksheetAnalysis();

                return(s);
            }
Esempio n. 5
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var s = (o == null ? new FixedColumnWidthWithoutTabSeparationStrategy() : (FixedColumnWidthWithoutTabSeparationStrategy)o);

                info.GetArray("StartPositions", out s._startPositions);
                return(s);
            }
Esempio n. 6
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                int independentVariable = info.GetInt32("IndependentVariable");
                int dependentVariable   = info.GetInt32("DependentVariable");

                double[] parameter;
                info.GetArray("ParameterValues", out parameter);

                object fo = info.GetValue("FitFunction");

                if (fo is Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)
                {
                    fo = ((Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)fo).CreateInstance();
                }

                FitFunctionToScalarFunctionDDWrapper s;

                if (o == null)
                {
                    s = new FitFunctionToScalarFunctionDDWrapper(fo as IFitFunction, dependentVariable, independentVariable, parameter);
                }
                else
                {
                    s = (FitFunctionToScalarFunctionDDWrapper)o;
                    s = (FitFunctionToScalarFunctionDDWrapper)o;
                    s._independentVariable = independentVariable;
                    s._dependentVariable   = dependentVariable;
                    s._parameter           = parameter;
                    s._fitFunction         = fo as IFitFunction;
                }

                return(s);
            }
Esempio n. 7
0
            public virtual object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                PolynomialFunction s = null != o ? (PolynomialFunction)o : new PolynomialFunction();

                info.GetArray("Coefficients", out s._coefficients);

                return(s);
            }
Esempio n. 8
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                Altaxo.Data.DateTimeColumn s = null != o ? (Altaxo.Data.DateTimeColumn)o : new Altaxo.Data.DateTimeColumn();

                // deserialize the base class
                info.GetBaseValueEmbedded(s, typeof(Altaxo.Data.DataColumn), parent);

                int count = info.GetInt32Attribute("Count");

                s._data = new DateTime[count];
                info.GetArray(s._data, count);
                s._capacity = null == s._data ? 0 : s._data.Length;
                s._count    = s._capacity;
                return(s);
            }
Esempio n. 9
0
            public virtual object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                FitElement s = o != null ? (FitElement)o : new FitElement();

                s.FitFunction = (IFitFunction)info.GetValue("FitFunction", s);

                int numRows  = info.GetInt32("NumberOfRows");
                int firstRow = info.GetInt32("FirstRow");

                s._rangeOfRows = PositiveIntegerRange.NewFromFirstAndCount(firstRow, numRows);

                int arraycount = info.OpenArray();

                s._independentVariables = new NumericColumnProxy[arraycount];
                for (int i = 0; i < arraycount; ++i)
                {
                    s._independentVariables[i] = (NumericColumnProxy)info.GetValue(s);
                }
                info.CloseArray(arraycount);

                arraycount            = info.OpenArray();
                s._dependentVariables = new NumericColumnProxy[arraycount];
                for (int i = 0; i < arraycount; ++i)
                {
                    s._dependentVariables[i] = (NumericColumnProxy)info.GetValue(s);
                }
                info.CloseArray(arraycount);


                arraycount         = info.OpenArray();
                s._errorEvaluation = new IVarianceScaling[arraycount];
                for (int i = 0; i < arraycount; ++i)
                {
                    s._errorEvaluation[i] = (IVarianceScaling)info.GetValue(s);
                }
                info.CloseArray(arraycount);

                info.GetArray("ParameterNames", out s._parameterNames);
                for (int i = 0; i < s._parameterNames.Length; ++i)
                {
                    if (s._parameterNames[i] == string.Empty)
                    {
                        s._parameterNames[i] = null; // serialization can not distinguish between an empty string and a null string
                    }
                }
                s._parameterNameStart = info.GetString("ParameterNameStart");
                return(s);
            }
Esempio n. 10
0
            public virtual object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                ProductFunction s = null != o ? (ProductFunction)o : new ProductFunction();

                info.GetArray("Coefficients", out s._coefficients);

                int cnt = info.OpenArray();

                s._functions = new Altaxo.Calc.IScalarFunctionDD[cnt];
                for (int i = 0; i < cnt; i++)
                {
                    s._functions[i] = (Altaxo.Calc.IScalarFunctionDD)info.GetValue("e", parent);
                }

                info.CloseArray(cnt);

                return(s);
            }
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                int independentVariable = info.GetInt32("IndependentVariable");
                var independentVariableTransformation = (IVariantToVariantTransformation)info.GetValue("IndependentVariableTransformation", null);
                int dependentVariable = info.GetInt32("DependentVariable");
                var dependentVariableTransformation = (IVariantToVariantTransformation)info.GetValue("DependentVariableTransformation", null);

                info.GetArray("ParameterValues", out double[] parameter);

                object fo = info.GetValue("FitFunction", null);

                if (fo is Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)
                {
                    fo = ((Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)fo).CreateInstance();
                }

                FitFunctionToScalarFunctionDDWrapper s;

                if (o == null)
                {
                    s = new FitFunctionToScalarFunctionDDWrapper(fo as IFitFunction, dependentVariable, dependentVariableTransformation, independentVariable, independentVariableTransformation, parameter);
                }
                else
                {
                    s = (FitFunctionToScalarFunctionDDWrapper)o;
                    s._independentVariable = independentVariable;
                    s._independentVariableTransformation = independentVariableTransformation;
                    s._dependentVariable = dependentVariable;
                    s._dependentVariableTransformation = dependentVariableTransformation;
                    s._parameter   = parameter;
                    s._fitFunction = fo as IFitFunction;

                    if (s._fitFunction is Main.IDocumentLeafNode && !(s._fitFunction is Altaxo.Scripting.FitFunctionScript))
                    {
                        ((Main.IDocumentLeafNode)s._fitFunction).ParentObject = s;
                    }
                }

                return(s);
            }
Esempio n. 12
0
            public virtual object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                FitElement s = o != null ? (FitElement)o : new FitElement();

                s.ChildSetMemberAlt(ref s._fitFunction, (IFitFunction)info.GetValue("FitFunction", s));

                int numRows  = info.GetInt32("NumberOfRows");
                int firstRow = info.GetInt32("FirstRow");

                s._rangeOfRows = RangeOfRowIndices.FromStartAndCount(firstRow, numRows);
                if (null != s._rangeOfRows)
                {
                    s._rangeOfRows.ParentObject = s;
                }

                int arraycount = info.OpenArray();

                s._independentVariables = new IReadableColumnProxy[arraycount];
                for (int i = 0; i < arraycount; ++i)
                {
                    s._independentVariables[i] = (IReadableColumnProxy)info.GetValue("e", s);
                    if (null != s._independentVariables[i])
                    {
                        s._independentVariables[i].ParentObject = s;
                    }
                }
                info.CloseArray(arraycount);

                arraycount            = info.OpenArray();
                s._dependentVariables = new IReadableColumnProxy[arraycount];
                for (int i = 0; i < arraycount; ++i)
                {
                    s._dependentVariables[i] = (IReadableColumnProxy)info.GetValue("e", s);
                    if (null != s._dependentVariables[i])
                    {
                        s._dependentVariables[i].ParentObject = s;
                    }
                }
                info.CloseArray(arraycount);

                arraycount         = info.OpenArray();
                s._errorEvaluation = new IVarianceScaling[arraycount];
                for (int i = 0; i < arraycount; ++i)
                {
                    s._errorEvaluation[i] = (IVarianceScaling)info.GetValue("e", s);
                }
                info.CloseArray(arraycount);

                info.GetArray("ParameterNames", out s._parameterNames);
                for (int i = 0; i < s._parameterNames.Length; ++i)
                {
                    if (s._parameterNames[i] == string.Empty)
                    {
                        s._parameterNames[i] = null; // serialization can not distinguish between an empty string and a null string
                    }
                }
                s._parameterNameStart = info.GetString("ParameterNameStart");

                // now some afterwork
                if (s.InternalCheckAndCorrectArraySize(false, false))
                {
                    Current.Console.WriteLine("Error: Fitelement array size mismatch");
                }

                return(s);
            }