Esempio n. 1
0
        public AxModelSettings LoadSettings()
        {
            AxModelSettings axModelSettings = null;
            //XmlDocument doc = new XmlDocument();
            //var xsSubmit = new DataContractSerializer(typeof(AxModelSettings));
            var filePath = this.GetFilePath();

            if (File.Exists(filePath))
            {
                FileStream          fs     = new FileStream(filePath, FileMode.Open);
                XmlDictionaryReader reader =
                    XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());
                DataContractSerializer ser = new DataContractSerializer(typeof(AxModelSettings));

                // Deserialize the data and read it from the instance.
                axModelSettings = (AxModelSettings)ser.ReadObject(reader, true);
                reader.Close();
                fs.Close();

                /*
                 * doc.Load(filePath);
                 *
                 * using (TextReader reader = new StringReader(doc.InnerXml))
                 * {
                 *  axModelSettings = (AxModelSettings)xsSubmit.Deserialize(reader);
                 * }
                 */
            }

            return(axModelSettings ?? (axModelSettings = new AxModelSettings()));
        }
Esempio n. 2
0
        public void LoadDefaultSettings(ExtensionTemplateDefaultScheme extensionTemplateDefaultScheme)
        {
            AxModelSettings = new AxModelSettings();
            InitMissingSettings();
            switch (extensionTemplateDefaultScheme)
            {
            case ExtensionTemplateDefaultScheme.DefaultWithUnderscore:
                string templateStringControl;
                templateStringControl =
                    @"TST
                    $MainObject$ + _ + $Prefix$ + _Extension
                    $MainObject$ + _ + $Prefix$ + _Extension
                    $MainObject$ + _ + $Prefix$ + _Extension
                    $MainObject$ + _ + $Prefix$ + _Extension
                    $MainObject$ + Form + _ + $Prefix$ + _Extension
                    $MainObject$ + Form + _ + $Prefix$+ _ + $SubObject$ + _Extension
                    $MainObject$ + Form + _ + $Prefix$+ _ + $SubObject$ + _Extension
                    $MainObject$ + Form + _ + $Prefix$+ _ + $SubObject$ + _Extension
                    $MainObject$ + _ + $Prefix$ + _EventHandler
                    $MainObject$ + _ + $Prefix$ + _EventHandler
                    $MainObject$ + _ + $Prefix$ + _EventHandler
                    $MainObject$ + _ + $Prefix$ + _EventHandler
                    $MainObject$ + Form + _ + $Prefix$ + _EventHandler
                    $MainObject$ + Form + _ + $Prefix$ + _EventHandler
                    $MainObject$ + Form + _ + $Prefix$ + _EventHandler
                    $MainObject$ + Form + _ + $Prefix$ + _EventHandler";

                LoadSettingsFromFormControlData(templateStringControl);
                break;
            }
        }
Esempio n. 3
0
        public bool SaveSettings(AxModelSettings axModelSettings)
        {
            var  filePath = this.GetFilePath();
            bool res      = false;

            try
            {
                var xmlDocument = new XmlDocument();
                var serializer  = new DataContractSerializer(axModelSettings.GetType());
                using (var writer = new XmlTextWriter(filePath, null))
                {
                    writer.Formatting = Formatting.Indented; // indent the Xml so it's human readable
                    serializer.WriteObject(writer, axModelSettings);
                    writer.Flush();

                    res = true;
                }

                /*
                 * using (var stream = new MemoryStream())
                 * {
                 *  serializer.Serialize(stream, axModelSettings);
                 *  stream.Position = 0;
                 *  xmlDocument.Load(stream);
                 *  xmlDocument.Save(filePath);
                 *  stream.Close();
                 * }
                 */
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, @"Unhandled Exception");
                //CoreUtility.HandleExceptionWithErrorMessage(ex);
            }

            return(res);
        }
Esempio n. 4
0
        public void LoadSettings()
        {
            AxModelSettings = _kernelSettingsStorage.LoadSettings();

            InitMissingSettings();
        }