예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RobotsFileParser"/> class.
        /// </summary>
        /// <param name="robotRulesCache">The robot rules cache.</param>
        public RobotsFileParser([DisallowNull] IRobotRulesCache robotRulesCache)
        {
            this.Options = ParseOptions.Defaults;

            this.robotRulesCache = robotRulesCache;

            this.Clear();
        }
예제 #2
0
        public void TestLoadingCachePlugIn()
        {
            var asm  = System.Reflection.Assembly.Load("BlueCurve.Seach.RobotRules.Cache");
            var type = asm.GetTypes().SingleOrDefault(x => x.GetInterface("IRobotCache.IRobotRulesCache", false) != null);


            IRobotRulesCache handle = null;

            if (type != null)
            {
                handle = Activator.CreateInstance(type) as IRobotRulesCache;
            }

            Assert.IsNotNull(handle, "handle not null");
        }
예제 #3
0
        // Properties
        // Constructors
        /// <summary>
        ///   Initialises a new RobotsFileParser.
        /// </summary>
        public RobotsFileParser()
        {
            Options = ParseOptions.Defaults;
            string cachelib = ConfigurationManager.AppSettings["CacheLibrary"];

            if (!string.IsNullOrEmpty(cachelib))
            {
                var asm = Assembly.Load(Path.Combine(Assembly.GetExecutingAssembly().Location, cachelib));
                var type =
                    asm.GetTypes().SingleOrDefault(x => x.GetInterface("IRobotCache.IRobotRulesCache", false) != null);

                if (type != null)
                    this._database = (IRobotRulesCache)Activator.CreateInstance(type);
                else
                    throw new ApplicationException(
                        "Unable to find implementation of 'IRobotCache.IRobotRulesCache' into assembly : " + cachelib);
            }

            this.Clear();
        }