Пример #1
0
        private static void AddExtensionSchemas(XmlSchemaSet schemas, ExtensionsLoader loader)
        {
            if (schemas == null)
            {
                schemas = new XmlSchemaSet();
            }

            var validationExceptions = new List <Exception>();

            foreach (var xsdFile in loader.SchemaFileNames)
            {
                using (var reader = XmlReader.Create(xsdFile, new XmlReaderSettings()
                {
                    CloseInput = true
                }))
                {
                    var schema = XmlSchema.Read(reader, (s, a) => validationExceptions.Add(a.Exception));
                    if (schema.TargetNamespace != Constants.Namespace)
                    {
                        schemas.Add(schema);
                    }
                }
            }

            if (validationExceptions.Count > 0)
            {
                throw new ConfigurationException(validationExceptions);
            }
        }
Пример #2
0
 internal ConfigurationReader(string file)
 {
     var fileInfo = FileUtil.ProcessFileNameForLogging(file);
     this.File = fileInfo.FullName;
     this.loader = ExtensionsLoader.GetOrCreateInstance(fileInfo.DirectoryName);
     FormatterElementFactory.FormatterElements = this.loader.FormatterElements;
 }
Пример #3
0
        internal ConfigurationReader(string file)
        {
            var fileInfo = FileUtil.ProcessFileNameForLogging(file);

            this.File   = fileInfo.FullName;
            this.loader = ExtensionsLoader.GetOrCreateInstance(fileInfo.DirectoryName);
            FormatterElementFactory.FormatterElements = this.loader.FormatterElements;
        }
        internal static ExtensionsLoader GetOrCreateInstance(string probingPath)
        {
            ExtensionsLoader loader;
            if (!Instances.TryGetValue(probingPath, out loader))
            {
                loader = new ExtensionsLoader(probingPath);
                Instances.Add(probingPath, loader);
            }

            return loader;
        }
Пример #5
0
        internal static ExtensionsLoader GetOrCreateInstance(string probingPath)
        {
            ExtensionsLoader loader;

            if (!Instances.TryGetValue(probingPath, out loader))
            {
                loader = new ExtensionsLoader(probingPath);
                Instances.Add(probingPath, loader);
            }

            return(loader);
        }
Пример #6
0
        private static void AddExtensionSchemas(XmlSchemaSet schemas, ExtensionsLoader loader)
        {
            if (schemas == null)
            {
                schemas = new XmlSchemaSet();
            }

            var validationExceptions = new List<Exception>();

            foreach (var xsdFile in loader.SchemaFileNames)
            {
                using (var reader = XmlReader.Create(xsdFile, new XmlReaderSettings() { CloseInput = true }))
                {
                    var schema = XmlSchema.Read(reader, (s, a) => validationExceptions.Add(a.Exception));
                    if (schema.TargetNamespace != Constants.Namespace)
                    {
                        schemas.Add(schema);
                    }
                }
            }

            if (validationExceptions.Count > 0)
            {
                throw new ConfigurationException(validationExceptions);
            }
        }
 protected override void Given()
 {
     this.Sut = new ExtensionsLoader();
 }
 public void then_all_custom_implementations_should_be_loaded()
 {
     using (var domain = new DisposableDomain())
     {
         domain.DoCallBack(() =>
         {
             var sut = new ExtensionsLoader();
             Assert.IsTrue(sut.FormatterElements.Any(s => s.Value.GetType().FullName == "Test.TestFormatterElement"));
         });
     }
 }