예제 #1
0
        public static void Save(string filename, XmlConfigFile configFile)
        {
            if (configFile == null)
            {
                throw new ArgumentNullException(nameof(configFile));
            }

            using (FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite))
            {
                XmlWriterSettings writerSettings = new XmlWriterSettings
                {
                    Indent            = true,
                    IndentChars       = "  ",
                    NewLineChars      = Environment.NewLine,
                    NamespaceHandling = NamespaceHandling.OmitDuplicates
                };

                using (XmlWriter writer = XmlWriter.Create(stream, writerSettings))
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(XmlConfigFile));
                    serializer.WriteObject(writer, configFile);

                    writer.Flush();
                    writer.Close();
                }
            }

            configFile.FileName = filename;
            configFile.ResetChangeState();
        }
예제 #2
0
        public FlowRuleParameters(XmlConfigFile config, string flowRuleName, FlowRuleType type)
        {
            this.config = config;
            this.SourceAttributeNames = new List <string>();
            this.Transforms           = new List <Transform>();
            this.MergeValues          = flowRuleName.StartsWith("!");

            if (this.MergeValues)
            {
                flowRuleName = flowRuleName.Remove(0, 1);
            }

            this.GetAliasDefinition(flowRuleName);

            if (this.aliasDefinition == null)
            {
                this.flowRuleDescription = flowRuleName;
            }
            else
            {
                this.flowRuleDescription = this.aliasDefinition.FlowRuleDefinition;
            }

            this.FlowRuleType = type;
            this.ValidateFlowRuleName();

            this.GetSourceAttributes();
            this.GetTargetAttribute();
            this.GetTransforms();
        }
예제 #3
0
        public static XmlConfigFile LoadXml(string filename)
        {
            UniqueIDCache.ClearIdCache();

            using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                XmlDictionaryReader xdr = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas());

                DataContractSerializer serializer = new DataContractSerializer(typeof(XmlConfigFile));
                XmlConfigFile          configFile = (XmlConfigFile)serializer.ReadObject(xdr);

                configFile.FileName = filename;
                configFile.ResetChangeState();

                ConfigManager.CurrentConfig = configFile;
                return(configFile);
            }
        }
예제 #4
0
        void IMASynchronization.Initialize()
        {
            string path = MAExtensionObject.AppConfigPath;

            if (!System.IO.File.Exists(path))
            {
                path = this.FindUmarex();

                if (path == null)
                {
                    throw new FileNotFoundException(
                              @"Unable to find a UMAREX configuration file. To resolve this, either
1. Use the UMARE editor to create a file and place it in the Sync Engine extensions folder, or
2. Modify the Lithnet.Umare.RulesExtension.dll.config file in the extensions folder to point to the appropriate path containing your umarex file");
                }
            }

            this.config = ConfigManager.LoadXml(path);
        }
예제 #5
0
 public MAExtensionObject()
 {
     TransformGlobal.HostProcessSupportsLoopbackTransforms = true;
     this.config             = new XmlConfigFile();
     this.flowRuleParamCache = new Dictionary <string, FlowRuleParameters>();
 }