Пример #1
0
        void IInitializable <HttpRealProxyFactorySetting> .Init(HttpRealProxyFactorySetting setting)
        {
            //Url映射
            var urls = setting?.UrlMapping;

            if (urls != null && urls.Length > 0)
            {
                foreach (var urlMapping in urls)
                {
                    this.urlMappings.Add(urlMapping.Name, urlMapping.Url);
                }
            }

            var coreAttributes = this.ObjectService.AsObjectServiceInternal().CoreAttributes;

            //初始化处理Url的处理器,比如可以处理形如下面格式的Url:esb://
            coreAttributes.TryGetValue(typeof(HttpRealProxyAttribute), out var list);
            if (list != null && list.Count > 0)
            {
                foreach (HttpRealProxyAttribute attribute in list)
                {
                    this.handlers.Add(attribute);
                }
            }
            //初始化扩展器
            ServiceExtenderAttribute.ExtenderInit <IHttpRealProxyFactory, HttpRealProxyFactoryExtenderAttribute>(this.ObjectService, this);
        }
Пример #2
0
        public void Init(ServiceFactorySetting setting)
        {
            this.Setting = setting;

            this.factories = new ValueProviderFactoryCollection {
                new CustomValueProviderFactory(),
                new FormValueProviderFactory(),
                new QueryStringValueProviderFactory()
            };

            //添加服务
            this.services = new Dictionary <string, ServiceContainer>(StringComparer.OrdinalIgnoreCase);
            this.AddServicesFromAttributes();

            this.regexRoute = new Regex(this.Setting.RouteUrl + this.Setting.PathRegex, RegexOptions.Compiled | RegexOptions.Singleline);

            ServiceExtenderAttribute.ExtenderInit <IServiceFactory, ServiceFactoryExtenderAttribute>(this.ObjectService, this);
        }