Beispiel #1
0
        public static string WriteInputVariables(Type2ParamsList inputVariables)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Type2ParamsList));
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Encoding = new UnicodeEncoding(false, false); // no BOM in a .NET string
            settings.Indent = false;
            settings.OmitXmlDeclaration = false;
            using (StringWriter textWriter = new StringWriter())
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(textWriter, settings))
                {
                    serializer.Serialize(xmlWriter, inputVariables);
                }

                return textWriter.ToString();
            }
        }
Beispiel #2
0
        public static void SaveInputVariables(Type2ParamsList inputVariables)
        {
            // xml
            string dirName = "c:\\Data\\variables_t2_" + DateTime.Now.Ticks;
            Directory.CreateDirectory(dirName);
            XmlSerializer x = new XmlSerializer(typeof(Type2ParamsList));
            TextWriter writer = new StreamWriter(string.Format("{0}\\variables.xml", dirName));
            x.Serialize(writer, inputVariables);

            // MF images
            Directory.CreateDirectory(string.Format("{0}\\variables", dirName));
            foreach (var parameter in inputVariables.Items)
            {
                if (parameter.TermsImg != null)
                {
                    parameter.TermsImg.Save(string.Format("{0}\\variables\\{1}.png", dirName, parameter.ParamName));
                }
            }
        }