public PocoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity)
            : base(entityMetamodel, mappedEntity)
        {
            mappedClass              = mappedEntity.MappedClass;
            proxyInterface           = mappedEntity.ProxyInterface;
            islifecycleImplementor   = typeof(ILifecycle).IsAssignableFrom(mappedClass);
            isValidatableImplementor = typeof(IValidatable).IsAssignableFrom(mappedClass);

            foreach (Mapping.Property property in mappedEntity.PropertyClosureIterator)
            {
                if (property.IsLazy)
                {
                    lazyPropertyNames.Add(property.Name);
                }
            }
            SetReflectionOptimizer();

            Instantiator = BuildInstantiator(mappedEntity);

            if (hasCustomAccessors)
            {
                optimizer = null;
            }

            proxyValidator = Cfg.Environment.BytecodeProvider.ProxyFactoryFactory.ProxyValidator;
        }
		public PocoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity)
			: base(entityMetamodel, mappedEntity)
		{
			mappedClass = mappedEntity.MappedClass;
			proxyInterface = mappedEntity.ProxyInterface;
			islifecycleImplementor = typeof(ILifecycle).IsAssignableFrom(mappedClass);
			isValidatableImplementor = typeof(IValidatable).IsAssignableFrom(mappedClass);

			foreach (Mapping.Property property in mappedEntity.PropertyClosureIterator)
			{
				if (property.IsLazy)
					lazyPropertyNames.Add(property.Name);
				if (property.UnwrapProxy)
					unwrapProxyPropertyNames.Add(property.Name);
			}
			SetReflectionOptimizer();

			Instantiator = BuildInstantiator(mappedEntity);

			if (hasCustomAccessors)
			{
				optimizer = null;
			}

			proxyValidator = Cfg.Environment.BytecodeProvider.ProxyFactoryFactory.ProxyValidator;
		}
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="options">选项</param>
 /// <param name="loggerFactory">日志接口工厂</param>
 public DownloaderAllocator(
     IProxyValidator proxyValidator,
     IDownloaderAgentOptions options,
     ILoggerFactory loggerFactory)
 {
     _proxyValidator = proxyValidator;
     _loggerFactory  = loggerFactory;
     _options        = options;
 }
Beispiel #4
0
 public ProxyProvider(IProxyConfiguration configuration,
                      IProxyCollection collection,
                      IProxyTypeGenerator typeGenerator,
                      IProxyValidator validator)
 {
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _collection    = collection ?? throw new ArgumentNullException(nameof(collection));
     _generator     = typeGenerator ?? throw new ArgumentNullException(nameof(typeGenerator));
     _validator     = validator ?? throw new ArgumentNullException(nameof(validator));
 }
Beispiel #5
0
        public IProxyFlare Use(IProxyValidatorFactory validatorFactory)
        {
            if (validatorFactory == null)
            {
                throw new ArgumentNullException(nameof(validatorFactory));
            }

            _validator = validatorFactory.BuilderValidator();
            return(this);
        }
Beispiel #6
0
        public HttpProxyPool(IHttpProxyFinder finder, IProxyValidator proxyValidator, int reuseInterval, int refreshInterval = 2 * 1000)
        {
            _finder          = finder;
            _reuseInterval   = reuseInterval;
            _refreshInterval = refreshInterval;

            if (refreshInterval < 100)
            {
                throw new ArgumentException("'refreshInterval' must greater than 100 ");
            }

            _proxyValidator = proxyValidator;

            Task.Run(() => RefreshProxies());
        }
Beispiel #7
0
        public PocoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity)
            : base(entityMetamodel, mappedEntity)
        {
            mappedClass              = mappedEntity.MappedClass;
            proxyInterface           = mappedEntity.ProxyInterface;
            islifecycleImplementor   = typeof(ILifecycle).IsAssignableFrom(mappedClass);
            isValidatableImplementor = typeof(IValidatable).IsAssignableFrom(mappedClass);

            SetReflectionOptimizer();

            Instantiator = BuildInstantiator(mappedEntity);

            ClearOptimizerWhenUsingCustomAccessors();

            proxyValidator = Cfg.Environment.BytecodeProvider.ProxyFactoryFactory.ProxyValidator;
        }
Beispiel #8
0
 public DownloaderProxyPools(IHttpProxyFinder proxyFinder, IProxyValidator proxyValidator, int reuseInterval, int refreshInterval)
 {
     proxyPool = new HttpProxyPool(proxyFinder, proxyValidator, reuseInterval, refreshInterval);
 }
Beispiel #9
0
        /// <summary>
        ///  使用代理池
        /// </summary>
        /// <param name="spider"></param>
        /// <param name="proxyFinder">代理获取</param>
        /// <param name="proxyValidator">代理有效验证</param>
        /// <param name="reuseInterval">复用间隔时间(ms)</param>
        /// <returns></returns>
        public static Spider UseHttpProxyPools(this Spider spider, IHttpProxyFinder proxyFinder, IProxyValidator proxyValidator, int reuseInterval, int refreshInterval = 2 * 1000)
        {
            DownloaderProxyPools downloaderProxy = new DownloaderProxyPools(proxyFinder, proxyValidator, reuseInterval, refreshInterval);

            spider.SetDownloaderProxy(downloaderProxy);

            return spider;
        }
Beispiel #10
0
 public ProxyService(IProxyValidator proxyValidator)
 {
     _proxyValidator = proxyValidator;
     _queue          = new ConcurrentQueue <ProxyEntry>();
     _dict           = new ConcurrentDictionary <Uri, ProxyEntry>();
 }
Beispiel #11
0
 public ProxyPool(IProxyValidator proxyValidator)
 {
     _proxyValidator = proxyValidator;
     _queue          = new ConcurrentQueue <HttpProxy>();
     _dict           = new ConcurrentDictionary <string, HttpProxy>();
 }