コード例 #1
0
        public IEnumerable <Rule> GetRules()
        {
            List <Rule> rules = new List <Rule>();

            try
            {
                DirectoryInfo di  = new DirectoryInfo(this.folder);
                FileInfo[]    fis = di.GetFiles("*.xml");
                foreach (var fi in fis)
                {
                    var rulesInFile = new RuleStoreAsXmlFile(fi.FullName, this.logger).GetRules();
                    if (rulesInFile != null)
                    {
                        rules.AddRange(rulesInFile);
                    }
                }
            }
            catch (Exception ex)
            {
                if (!ExceptionHelper.IsCatchableExceptionType(ex))
                {
                    throw;
                }

                RuntimeException.WrapAndLog(ex, Resource.InvalidFolderPath + ":" + this.folder, this.logger);
            }

            return(rules);
        }
コード例 #2
0
        public ExtensionRuleStore(string path, ILogger logger)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException(Resource.ArgumentNotNullOrEmpty, "path");
            }

            using (var catalog = new AggregateCatalog())
            {
                try
                {
                    var directoryCatalog = new DirectoryCatalog(path);
                    catalog.Catalogs.Add(directoryCatalog);
                    using (var container = new CompositionContainer(catalog))
                    {
                        container.ComposeParts(this);
                    }
                }
                catch (Exception ex)
                {
                    if (!ExceptionHelper.IsCatchableExceptionType(ex))
                    {
                        throw;
                    }

                    RuntimeException.WrapAndLog(ex, Resource.InvalidExtensionRules + ":" + path, logger);
                }
            }
        }
コード例 #3
0
        public IEnumerable <Rule> GetRules()
        {
            IEnumerable <Rule> rules = null;

            try
            {
                using (FileStream stream = File.OpenRead(this.filePath))
                {
                    XElement xml = XElement.Load(stream);
                    rules = CreateRules(xml);
                }
            }
            catch (Exception ex)
            {
                if (!ExceptionHelper.IsCatchableExceptionType(ex))
                {
                    throw;
                }

                RuntimeException.WrapAndLog(ex, Resource.InvalidXmlRule + ":" + this.filePath, this.logger);
            }

            return(rules);
        }