示例#1
0
        public IHandler Build(IHandler parent)
        {
            if (_Content == null)
            {
                throw new BuilderMissingPropertyException("Content");
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new PageProvider(p, _Info.Build(), _Content)));
        }
        public IHandler Build(IHandler parent)
        {
            if (_Location == null)
            {
                throw new BuilderMissingPropertyException("Location");
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new RedirectProvider(p, _Location, _Temporary)));
        }
        public IHandler Build(IHandler parent)
        {
            if (_FileProvider == null)
            {
                throw new BuilderMissingPropertyException("File Provider");
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new MarkdownPageProvider <T>(p, _FileProvider, _Info.Build())));
        }
示例#4
0
        public IHandler Build(IHandler parent)
        {
            if (_Upstream == null)
            {
                throw new BuilderMissingPropertyException("Upstream");
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new ReverseProxyProvider(p, _Upstream, _ConnectTimeout, _ReadTimeout)));
        }
示例#5
0
        internal CoreRouter(IHandlerBuilder content, IEnumerable <IConcernBuilder> concerns, bool development)
        {
            Content = Concerns.Chain(this, concerns, (p) => content.Build(p));

            Template = Placeholders.Template <TemplateModel>(Data.FromResource("Template.html"))
                       .Build();

            ErrorRenderer = Placeholders.Template <ErrorModel>(Data.FromResource(development ? "ErrorStacked.html" : "Error.html"))
                            .Build();
        }
        public IHandler Build(IHandler parent)
        {
            if (_ResourceProvider == null)
            {
                throw new BuilderMissingPropertyException("Resource Provider");
            }

            if (_ContentType == null)
            {
                throw new BuilderMissingPropertyException("Content Type");
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new DownloadProvider(p, _ResourceProvider, new FlexibleContentType((ContentType)_ContentType))));
        }
        public IHandler Build(IHandler parent)
        {
            if (_TemplateProvider == null)
            {
                throw new BuilderMissingPropertyException("Template Provider");
            }

            if (_ModelProvider == null)
            {
                throw new BuilderMissingPropertyException("Model Provider");
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new RazorPageProvider <T>(p, _TemplateProvider, _ModelProvider, _Info.Build())));
        }
        public IHandler Build(IHandler parent)
        {
            if (_Root == null)
            {
                throw new BuilderMissingPropertyException("Root");
            }

            if (_Assembly == null)
            {
                _Assembly = System.Reflection.Assembly.GetCallingAssembly();
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new EmbeddedResourcesProvider(p, _Assembly, _Root)));
        }
示例#9
0
        public IHandler Build(IHandler parent)
        {
            if (_Directory == null)
            {
                throw new BuilderMissingPropertyException("Directory");
            }

            if (!_Directory.Exists)
            {
                throw new DirectoryNotFoundException($"The given directory does not exist: '{_Directory.FullName}'");
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new FileResourcesProvider(parent, _Directory)));
        }
示例#10
0
        public IHandler Build(IHandler parent)
        {
            if (_Data == null)
            {
                throw new BuilderMissingPropertyException("Data");
            }

            if (_ContentType == null)
            {
                throw new BuilderMissingPropertyException("Content Type");
            }

            return(Concerns.Chain(parent, _Concerns, (p) => new StringProvider(p, _Data, new FlexibleContentType((ContentType)_ContentType))));
        }
示例#11
0
        public HttpResponseMessage AddConcerns([FromBody] Concerns Param)
        {
            try
            {
                ConcernsProvider _Provider = new ConcernsProvider();
                var result = _Provider.AddConcerns(Param);
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "添加关注", "AddConcerns", ex);

                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
示例#12
0
        public override System.Runtime.Remoting.Messaging.IMessage Invoke(System.Runtime.Remoting.Messaging.IMessage msg)
        {
            object             returnValue   = null;
            IMethodCallMessage methodMessage = ( IMethodCallMessage )msg;
            MethodBase         method        = methodMessage.MethodBase;

            var concernMethod = Joinpoints
                                .Where(
                x =>
                x.PointcutMethod.Name == method.Name &&
                Utils.TypeArrayMatch(x.PointcutMethod.GetParameters( ).Select(p => p.ParameterType).ToArray( ), method.GetParameters( ).Select(p => p.ParameterType).ToArray( ))
                )
                                .Select(x => x.ConcernMethod).FirstOrDefault( );

            if (concernMethod != null)
            {
                var param = concernMethod.IsStatic ? null : Concerns.First(x => x.GetType( ) == concernMethod.DeclaringType);
                returnValue = concernMethod.Invoke(param, methodMessage.Args);
            }
            else
            {
                var targetMethod = Target
                                   .GetType( )
                                   .GetMethods( )
                                   .Where(
                    x =>
                    x.Name == method.Name &&
                    Utils.TypeArrayMatch(x.GetParameters( ).Select(p => p.ParameterType).ToArray( ), method.GetParameters( ).Select(p => p.ParameterType).ToArray( ))
                    )
                                   .FirstOrDefault( );

                var param = targetMethod.IsStatic ? null : Target;

                returnValue = targetMethod.Invoke(param, methodMessage.Args);
            }

            return(new ReturnMessage(returnValue, methodMessage.Args, methodMessage.ArgCount, methodMessage.LogicalCallContext, methodMessage));
        }
示例#13
0
        public IHandler Build(IHandler parent)
        {
            var directory = _Directory ?? throw new BuilderMissingPropertyException("directory");

            return(Concerns.Chain(parent, _Concerns, (p) => new ListingRouter(p, directory)));
        }
示例#14
0
        public IHandler Build(IHandler parent)
        {
            var scripts = (_Theme != null) ? _Theme.Scripts.Union(_Scripts) : _Scripts;

            return(Concerns.Chain(parent, _Concerns, (p) => new ScriptRouter(p, scripts.ToList())));
        }
示例#15
0
 public IHandler Build(IHandler parent)
 {
     return(Concerns.Chain(parent, _Concerns, (p) => new BundleProvider(parent, _Items, _ContentType)));
 }
示例#16
0
 public IHandler Build(IHandler parent)
 {
     return(Concerns.Chain(parent, _Concerns, (p) => new RobotsProvider(p, _Directives, _Sitemap)));
 }
示例#17
0
 public IHandler Build(IHandler parent)
 {
     return(Concerns.Chain(parent, _Concerns, (p) => new SitemapProvider(p)));
 }
示例#18
0
 public IHandler Build(IHandler parent)
 {
     return(Concerns.Chain(parent, _Concerns, (p) => new LayoutRouter(p, Handlers, _Index, _Fallback)));
 }
        public IHandler Build(IHandler parent)
        {
            var root = _Root ?? throw new BuilderMissingPropertyException("root");

            return(Concerns.Chain(parent, _Concerns, (p) => new LoadBalancerRedirectionHandler(p, root)));
        }
 public IHandler Build(IHandler parent)
 {
     return(Concerns.Chain(parent, _Concerns, (p) => new CustomHandler(p)));
 }
 public IHandler Build(IHandler parent)
 {
     return(Concerns.Chain(parent, _Concerns, (p) => new VirtualHostRouter(p, _Hosts, _DefaultRoute)));
 }
 public static void Register(string concernName, IUIConcern <T> uiConcern)
 {
     Concerns.Add(uiConcern);
 }