Exemplo n.º 1
0
 public HttpApiServer(HttpConfig serverConfig)
 {
     mActionFactory = new ActionHandlerFactory();
     if (serverConfig != null)
     {
         ServerConfig = serverConfig;
     }
     else
     {
         string configFile = "HttpConfig.json";
         if (System.IO.File.Exists(configFile))
         {
             using (System.IO.StreamReader reader = new StreamReader(configFile, Encoding.UTF8))
             {
                 string json = reader.ReadToEnd();
                 Newtonsoft.Json.Linq.JToken toke = (Newtonsoft.Json.Linq.JToken)Newtonsoft.Json.JsonConvert.DeserializeObject(json);
                 ServerConfig = toke["HttpConfig"].ToObject <HttpConfig>();
             }
         }
         else
         {
             ServerConfig = new HttpConfig();
         }
     }
     mResourceCenter = new StaticResurce.ResourceCenter(this);
 }
Exemplo n.º 2
0
 internal ActionContext(ActionHandler handler, IHttpContext context, ActionHandlerFactory actionHandlerFactory)
 {
     Handler              = handler;
     mFilters             = handler.Filters;
     HttpContext          = context;
     ActionHandlerFactory = actionHandlerFactory;
     Parameters           = handler.GetParameters(context);
 }
Exemplo n.º 3
0
        public object Invoke(IHttpContext context, ActionHandlerFactory actionHandlerFactory, object[] parameters)
        {
            var controller = Controller;

            if (!SingleInstance)
            {
                controller = actionHandlerFactory.GetController(ControllerType);
                if (controller == null)
                {
                    controller = this.Controller;
                }
            }
            return(mMethodHandler.Execute(controller, parameters));
        }
Exemplo n.º 4
0
 public HttpApiServer(HttpConfig serverConfig = null)
 {
     mActionFactory = new ActionHandlerFactory();
     if (serverConfig != null)
     {
         ServerConfig = serverConfig;
     }
     else
     {
         var builder = new ConfigurationBuilder()
                       .SetBasePath(Directory.GetCurrentDirectory())
                       .AddJsonFile("HttpConfig.json", false);
         var configuration = builder.Build();
         ServerConfig = configuration.GetSection("HttpConfig").Get <HttpConfig>();
     }
 }
Exemplo n.º 5
0
 public HttpApiServer(HttpOptions options)
 {
     mFileLog        = new FileLogWriter("BEETLEX_HTTP_SERVER");
     FrameSerializer = this;
     if (options != null)
     {
         Options = options;
     }
     else
     {
         Options = LoadOptions();
     }
     mActionFactory  = new ActionHandlerFactory(this);
     mResourceCenter = new StaticResurce.ResourceCenter(this);
     mUrlRewrite     = new RouteRewrite(this);
     mModuleManager  = new ModuleManager(this);
 }
Exemplo n.º 6
0
 internal ActionContext(ActionHandler handler, IHttpContext context, ActionHandlerFactory actionHandlerFactory)
 {
     Handler              = handler;
     mFilters             = handler.Filters;
     HttpContext          = context;
     ActionHandlerFactory = actionHandlerFactory;
     Parameters           = handler.GetParameters(context);
     Controller           = handler.Controller;
     if (!handler.SingleInstance)
     {
         Controller = actionHandlerFactory.GetController(handler.ControllerType);
         if (Controller == null)
         {
             Controller = this.Controller;
         }
     }
 }
Exemplo n.º 7
0
 public HttpApiServer(HttpConfig serverConfig)
 {
     mFileLog        = new FileLogWriter("BEETLEX_HTTP_SERVER");
     FrameSerializer = this;
     if (serverConfig != null)
     {
         ServerConfig = serverConfig;
     }
     else
     {
         ServerConfig = LoadConfig();
     }
     mActionFactory  = new ActionHandlerFactory(this);
     mResourceCenter = new StaticResurce.ResourceCenter(this);
     mUrlRewrite     = new RouteRewrite(this);
     mModuleManage   = new ModuleManage(this);
 }
Exemplo n.º 8
0
 internal ActionContext(ActionHandler handler, IHttpContext context, ActionHandlerFactory actionHandlerFactory)
 {
     Handler              = handler;
     mFilters             = handler.Filters;
     HttpContext          = context;
     ActionHandlerFactory = actionHandlerFactory;
     Parameters           = handler.GetParameters(context);
     Controller           = handler.Controller;
     if (handler.InstanceType != InstanceType.Single)
     {
         if (handler.InstanceType == InstanceType.Session)
         {
             var factory = SessionControllerFactory.GetFactory(context.Session);
             Controller = factory[handler.ControllerUID];
             if (Controller == null)
             {
                 Controller = actionHandlerFactory.GetController(handler.ControllerType, context);
                 if (Controller == null)
                 {
                     Controller = Activator.CreateInstance(handler.ControllerType);
                 }
                 factory[handler.ControllerUID] = Controller;
             }
         }
         else
         {
             Controller = actionHandlerFactory.GetController(handler.ControllerType, context);
             if (Controller == null)
             {
                 Controller = Activator.CreateInstance(handler.ControllerType);
             }
         }
     }
     if (Controller == null)
     {
         Controller = handler.Controller;
     }
 }
Exemplo n.º 9
0
 public object Invoke(object controller, IHttpContext context, ActionHandlerFactory actionHandlerFactory, object[] parameters)
 {
     return(mMethodHandler.Execute(controller, parameters));
 }
Exemplo n.º 10
0
 public ParamterEventBinder(ActionHandlerFactory actionHandlerFactory)
 {
     ActionHandlerFactory = actionHandlerFactory;
 }