Exemple #1
0
        protected override void OnInit()
        {
            base.OnInit();
            this.factories = new ValueProviderFactoryCollection {
                new CustomValueProviderFactory(),
                new FormValueProviderFactory(),
                new QueryStringValueProviderFactory()
            };
            var dictionary = this.services = new Dictionary <string, ServiceItemSetting>(StringComparer.OrdinalIgnoreCase);

            foreach (var item in this.Setting.ServiceItems)
            {
                dictionary.Add(item.Name, item);
            }

            this.regexRoute = new Regex(this.Setting.PathRegex, RegexOptions.Compiled | RegexOptions.Singleline);
            if (this.Setting.Extenders == null || this.Setting.Extenders.Length <= 0)
            {
                return;
            }
            foreach (var extenderSetting in this.Setting.Extenders)
            {
                if (!extenderSetting.Enabled)
                {
                    continue;
                }
                var extender = this.ObjectService.GetOrCreateObject <IObjectExtender <IServiceFactory> >(extenderSetting.TypeName);
                extender?.Init(this);
            }
        }
Exemple #2
0
        protected override void OnInit()
        {
            base.OnInit();
            this.factories = new ValueProviderFactoryCollection {
                new CustomValueProviderFactory(),
                new FormValueProviderFactory(),
                new RouteDataValueProviderFactory(),
                new QueryStringValueProviderFactory(),
            };
            var dictionary = this.services = new Dictionary <string, ServiceItemSetting>(StringComparer.OrdinalIgnoreCase);

            foreach (var item in this.Setting.ServiceItems)
            {
                dictionary.Add(item.Name, item);
            }
            var route = new Route(this.Setting.RouteUrl, this)
            {
                Defaults    = new RouteValueDictionary(),
                Constraints = new RouteValueDictionary(),
                DataTokens  = new RouteValueDictionary()
            };

            RouteTable.Routes.Insert(0, route);
            if (this.Setting.Extenders == null || this.Setting.Extenders.Length <= 0)
            {
                return;
            }
            foreach (var extenderSetting in this.Setting.Extenders)
            {
                if (!extenderSetting.Enabled)
                {
                    continue;
                }
                var extender = this.ObjectService.GetOrCreateObject <IObjectExtender <IServiceFactory> >(extenderSetting.TypeName);
                if (extender != null)
                {
                    extender.Init(this);
                }
            }
        }