コード例 #1
0
        private static void DeserializeInstaller(XmlNode node, IConfigurationStore store)
        {
            var config          = XmlConfigurationDeserializer.GetDeserializedNode(node);
            var type            = config.Attributes["type"];
            var assembly        = config.Attributes["assembly"];
            var directory       = config.Attributes["directory"];
            var attributesCount = 0;

            if ((string.IsNullOrEmpty(type)) == false)
            {
                attributesCount++;
            }
            if (string.IsNullOrEmpty(assembly) == false)
            {
                attributesCount++;
            }
            if (string.IsNullOrEmpty(directory) == false)
            {
                attributesCount++;
            }
            if (attributesCount != 1)
            {
                throw new Exception(
                          "install must have exactly one of the following attributes defined: 'type', 'assembly' or 'directory'.");
            }
            AddInstallerConfig(config, store);
        }
コード例 #2
0
        public void Tab_character_is_not_trimmed_from_config_value_XML()
        {
            var node   = new XmlDocument().ReadNode(XmlReader.Create(new StringReader("<foo><![CDATA[\t]]></foo>")));
            var result = XmlConfigurationDeserializer.GetDeserializedNode(node);

            Assert.AreEqual("\t", result.Value);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: jirkaceska/C_sharp
        static void Main(string[] args)
        {
            JsonConfigurationDeserializer jsonConfigurationDeserializer = new JsonConfigurationDeserializer();
            XmlConfigurationDeserializer  xmlConfigurationDeserializer  = new XmlConfigurationDeserializer();

            RandomItemAccess randomItemAccess = new RandomItemAccess();
            LogLineDirector  logLineDirector  = new LogLineDirector();

            LogGenerator jsonConfigurationLogGenerator = new LogGenerator(jsonConfigurationDeserializer.Deserialize(@"..\..\InputData\LogConfiguration_.json"), randomItemAccess, logLineDirector);

            jsonConfigurationLogGenerator.GenerateLog();

            LogGenerator xmlConfigurationLogGenerator = new LogGenerator(xmlConfigurationDeserializer.Deserialize(@"..\..\InputData\LogConfiguration_.xml"), randomItemAccess, logLineDirector);

            xmlConfigurationLogGenerator.GenerateLog();

            /*string fileName = @"..\..\OutputData\json_correctlog1.txt";
             * Mutator mutator = new Mutator();
             * mutator.HideDateByRandomDate(fileName);
             * mutator.HideIpAddressByLocalhost(fileName);
             *
             * Analyzer analyzer = new Analyzer();
             * analyzer.GetNumberOfClassStatusCodes(fileName, HttpStatusClass.ClientError);
             *
             * Validator validator = new Validator();
             * validator.ValidateRandomLogs(fileName, "%h %l %u %t %r %s %b");*/
        }
コード例 #4
0
        private static void DeserializeFacility(XmlNode node, IConfigurationStore store, IConversionManager converter)
        {
            var config   = XmlConfigurationDeserializer.GetDeserializedNode(node);
            var typeName = GetRequiredAttributeValue(config, "type");
            var type     = converter.PerformConversion <Type>(typeName);

            AddFacilityConfig(type.FullName, config, store);
        }
コード例 #5
0
        private static void DeserializeComponent(XmlNode node, IConfigurationStore store, IConversionManager converter)
        {
            var config = XmlConfigurationDeserializer.GetDeserializedNode(node);
            var id     = config.Attributes["id"];

            if (string.IsNullOrEmpty(id))
            {
                var type = converter.PerformConversion <Type>(config.Attributes["type"]);
                id = type.FullName;
                config.Attributes["id"] = id;
                config.Attributes.Add("id-automatic", true.ToString());
            }
            AddComponentConfig(id, config, store);
        }
コード例 #6
0
 protected static void Deserialize(XmlNode section, IConfigurationStore store, IConversionManager converter)
 {
     foreach (XmlNode node in section)
     {
         if (XmlConfigurationDeserializer.IsTextNode(node))
         {
             throw new ConfigurationProcessingException(String.Format("{0} cannot contain text nodes", node.Name));
         }
         if (node.NodeType == XmlNodeType.Element)
         {
             DeserializeElement(node, store, converter);
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// Deserializes the specified section.
        /// </summary>
        /// <param name="section">The section.</param>
        public void Deserialize(XmlNode section)
        {
            var typeAtt = section.Attributes["type"];

            if (typeAtt == null || typeAtt.Value == String.Empty)
            {
                var message = "To add a service, please specify the 'type' attribute. " +
                              "Check the documentation for more information";
                throw new ConfigurationErrorsException(message);
            }

            extensionType = TypeLoadUtil.GetType(typeAtt.Value);

            extensionNode = XmlConfigurationDeserializer.GetDeserializedNode(section);
        }
コード例 #8
0
        private static void DeserializeContainer(XmlNode node, IConfigurationStore store)
        {
            IConfiguration config    = XmlConfigurationDeserializer.GetDeserializedNode(node);
            IConfiguration newConfig = new MutableConfiguration(config.Name, node.InnerXml);

            // Copy all attributes
            string[] allKeys = config.Attributes.AllKeys;

            foreach (string key in allKeys)
            {
                newConfig.Attributes.Add(key, config.Attributes[key]);
            }

            // Copy all children
            newConfig.Children.AddRange(config.Children);

            string name = GetRequiredAttributeValue(config, "name");

            AddChildContainerConfig(name, newConfig, store);
        }
コード例 #9
0
        /// <summary>
        ///   Deserializer given property to configuration
        /// </summary>
        /// <param name="property">Property to deserialize</param>
        /// <returns>Property configuration</returns>
        public static IConfiguration Deserialize(XmlElement property)
        {
            IConfiguration rawConfig       = XmlConfigurationDeserializer.GetDeserializedNode(property);
            IConfiguration processedConfig = null;

            if (rawConfig.Children.Count > 0)
            {
                IConfiguration firstChild = rawConfig.Children[0];
                string         configName = firstChild.Name.ToLowerInvariant();
                if (SpecialNodes.Contains(configName))
                {
                    processedConfig = new MutableConfiguration(rawConfig.Name, string.Empty);
                    processedConfig.Attributes.Add(rawConfig.Attributes);
                    processedConfig.Children.AddRange(firstChild.Children);
                }
            }

            processedConfig = processedConfig ?? rawConfig;

            return(processedConfig);
        }
コード例 #10
0
        /// <summary>
        /// Deserializes the specified node.
        /// </summary>
        /// <param name="node">The node.</param>
        public void Deserialize(XmlNode node)
        {
            viewEngineConfig.Deserialize(node);
            smtpConfig.Deserialize(node);
            controllersConfig.Deserialize(node);
            viewComponentsConfig.Deserialize(node);
            scaffoldConfig.Deserialize(node);
            urlConfig.Deserialize(node);

            extensions.Deserialize(node);
            routingRules.Deserialize(node);
            defaultUrls.Deserialize(node);

            ProcessFilterFactoryNode(node.SelectSingleNode("customFilterFactory"));
            ProcessMatchHostNameAndPath(node.SelectSingleNode("routing"));
            ProcessExcludeAppPath(node.SelectSingleNode("routing"));

            var services = node.SelectSingleNode("services");

            if (services != null)
            {
                servicesConfig = XmlConfigurationDeserializer.GetDeserializedNode(services);
            }
        }
コード例 #11
0
        public void Tab_character_is_not_trimmed_from_config_value()
        {
            string result = XmlConfigurationDeserializer.GetConfigValue("\t");

            Assert.AreEqual("\t", result);
        }
コード例 #12
0
 /// <summary>
 /// Pendent
 /// </summary>
 /// <param name="section"></param>
 public MonoRailConfiguration(XmlNode section) : this()
 {
     ConfigurationSection = XmlConfigurationDeserializer.GetDeserializedNode(section);
 }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocalizationConfiguration"/> class.
 /// </summary>
 /// <param name="section">The section.</param>
 public LocalizationConfiguration(XmlNode section)
     : this()
 {
     _ConfigurationSection = XmlConfigurationDeserializer.GetDeserializedNode(section);
 }