예제 #1
0
        public static void Save()
        {
            foreach (var ds in ProtokollerConfiguration.ActualConfigInstance.Datasets)
            {
                foreach (var rw in ds.DatasetConfigRows)
                {
                    if (rw.PLCTag != null)
                    {
                        rw.PLCTag.ClearValue();
                    }
                }
            }

            string conf = SerializeToString <ProtokollerConfiguration> .Serialize(ProtokollerConfiguration.ActualConfigInstance);

            /*
             * RegistryKey regKey = Registry.LocalMachine;
             * regKey = regKey.CreateSubKey("SYSTEM\\CurrentControlSet\\services\\" + StaticServiceConfig.MyServiceName + "\\Parameters");
             * if (regKey != null)
             * {
             *  regKey.SetValue("XMLConfig", conf,RegistryValueKind.String);
             *  ProtokollerConfiguration.ActualConfigInstance.isDirty = false;
             * }
             * else
             *  MessageBox.Show("Error writing Config to the Registry, maybe you need to Login as Administrator?");
             */
            Directory.CreateDirectory(Path.GetDirectoryName(ConfigFileName()));
            StreamWriter sstrm = new StreamWriter(ConfigFileName(), false);

            sstrm.Write(conf);
            sstrm.Close();
        }
예제 #2
0
        private static ProtokollerConfiguration DeSerialize(string txt)
        {
            ProtokollerConfiguration retVal = null;

            try
            {
                retVal = JsonNetDeSerialize <ProtokollerConfiguration>(txt);
            }
            catch (Exception)
            { }

            if (retVal == null)
            {
                try
                {
                    retVal = SerializeToString <ProtokollerConfiguration> .DeSerialize(txt);
                }
                catch (Exception)
                { }
            }

            ReReferenceProtokollerConfiguration(retVal);

            return(retVal);
        }
예제 #3
0
        private static ProtokollerConfiguration DeSerialize(string txt)
        {
            ProtokollerConfiguration retVal = SerializeToString <ProtokollerConfiguration> .DeSerialize(txt);

            ReReferenceProtokollerConfiguration(retVal);

            return(retVal);
        }
예제 #4
0
        public static void SaveToFile(string filename)
        {
            StreamWriter fstrm = new StreamWriter(filename, false);

            string conf = SerializeToString <ProtokollerConfiguration> .Serialize(ProtokollerConfiguration.ActualConfigInstance);

            fstrm.Write(conf);
            fstrm.Close();
        }
예제 #5
0
 public DatasetConfig Clone()
 {
     return(SerializeToString <DatasetConfig> .DeSerialize(SerializeToString <DatasetConfig> .Serialize(this)));
 }