Exemple #1
0
        public static Dictionary <string, DefinitionBase> Parse(TextReader reader)
        {
            var parser = new XmlConfigParser(reader);

            parser.Parse();

            return(parser.Definitions);
        }
Exemple #2
0
        public static Dictionary <string, DefinitionBase> Parse(Stream stream)
        {
            var parser = new XmlConfigParser(stream);

            parser.Parse();

            return(parser.Definitions);
        }
Exemple #3
0
        public ObjectContainer(string xml)
        {
            if (string.IsNullOrWhiteSpace(xml))
            {
                throw new ArgumentNullException(nameof(xml));
            }

            try
            {
                Log.Debug("Parse config string and initialize container.");

                container = XmlConfigParser.Parse(xml);

                Log.Debug($"Container initialized successfully, total {container.Count} objects loaded.");
            }
            catch (Exception ex)
            {
                Log.Error($"Container initialized error: {ex.Message}.", ex);
                throw ex;
            }
        }
Exemple #4
0
        public ObjectContainer(FileInfo configFile)
        {
            if (!configFile.Exists)
            {
                throw new FileNotFoundException("File cannot be found.", configFile.FullName);
            }

            try
            {
                Log.Debug("Parse config file and initialize container.");

                using (Stream stream = configFile.OpenRead())
                {
                    container = XmlConfigParser.Parse(stream);
                }

                Log.Debug($"Container initialized successfully, total {container.Count} objects loaded.");
            }
            catch (Exception ex)
            {
                Log.Error($"Container initialized error: {ex.Message}.", ex);
                throw ex;
            }
        }