Beispiel #1
0
        public static void InitWebActionField(FieldInfo field, IWebController controller)
        {
            string actionName = field.GetAttribute <WebUrlAttribute>(false).Match(
                some: a => a.url,
                none: () => field.Name
                );

            WebMethod actionMethod;

            string[] paramNames;

            WebActionAttribute attribute;

            if (!field.GetAttribute <WebActionAttribute>(false).TryGet(out attribute))
            {
                return;
            }

            actionMethod = attribute.httpMethod;
            paramNames   = attribute.paramNames;

            string[] headerNames = field.GetAttribute <WebHeadersAttribute>(false).Match(
                some: a => a.headerNames,
                none: () => new string[0]
                );

            var action = System.Activator.CreateInstance(field.FieldType, actionName, actionMethod, headerNames, paramNames, controller) as IWebAction;

            if (action != null)
            {
                field.SetValue(controller, action);
            }
        }
 public bool Validate(IWebController context)
 {
     if (string.IsNullOrEmpty(context.Account) ||
         string.IsNullOrEmpty(context.DeviceSN) ||
         string.IsNullOrEmpty(context.Ticket))
         return false;
     return TicketGenerator.Instance.ValidTicket(context.Account, context.DeviceSN, context.Ticket);
 }
Beispiel #3
0
 public WebAction(string name, WebMethod actionMethod, string[] headerNames, string[] paramNames, IWebController controller)
 {
     Name        = name;
     Method      = actionMethod;
     HeaderNames = headerNames;
     ParamNames  = paramNames;
     Controller  = controller;
 }
 public bool Validate(IWebController context)
 {
     if (string.IsNullOrEmpty(context.ClientVersion))
     {
         return(false);
     }
     return(Versions.Contains(context.ClientVersion));
 }
Beispiel #5
0
 public HttpServer(INSmartLogger logger, IDbOperator dbop, IServerContext serverContext, IWebController controllerInstance)
 {
     Logger = logger;
     Dbop   = dbop;
     //第一次加载所有mime类型
     PopulateMappings();
     ServerContext      = serverContext;
     ControllerInstance = controllerInstance;
 }
 public bool Validate(IWebController context)
 {
     if (string.IsNullOrEmpty(context.Account) ||
         string.IsNullOrEmpty(context.DeviceSN) ||
         string.IsNullOrEmpty(context.Ticket))
     {
         return(false);
     }
     return(TicketGenerator.Instance.ValidTicket(context.Account, context.DeviceSN, context.Ticket));
 }
Beispiel #7
0
 public bool Validate(IWebController context, WebRequestFilterType level)
 {
     foreach (var validator in GetValidator(level))
     {
         if (!validator.Validate(context))
         {
             return(false);
         }
     }
     return(true);
 }
 public bool Validate(IWebController context)
 {
     return !string.IsNullOrEmpty(context.Account);
 }
Beispiel #9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="IceApplication"></param>
 public IndexModel([FromServices] IWebController webController) => this.webController = webController;
Beispiel #10
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="IceApplication"></param>
 public CreateModel([FromServices] IWebController webController) => this.webController = webController;
 public bool Validate(IWebController context)
 {
     return(!string.IsNullOrEmpty(context.Account));
 }
 public bool Validate(IWebController context)
 {
     return context.DeviceType != DeviceType.Unknown;
 }
 public bool Validate(IWebController context)
 {
     return(context.WebMethod.Equals(_method));
 }
Beispiel #14
0
 public bool Validate(IWebController context, WebRequestFilterType level)
 {
     foreach (var validator in GetValidator(level))
     {
         if (!validator.Validate(context)) return false;
     }
     return true;
 }
 public FunnyForm(IWebController i_WebController)
 {
     m_WebController = i_WebController;
     InitializeComponent();
     InitiailizeWebController();
 }
 public bool Validate(IWebController context)
 {
     return !string.IsNullOrEmpty(context.DeviceSN);
 }
Beispiel #17
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="IceApplication"></param>
 public DetailsModel([FromServices] IWebController webController) => this.webController = webController;
Beispiel #18
0
 public bool Validate(IWebController context)
 {
     return(!string.IsNullOrEmpty(context.DeviceSN));
 }
 public FactForm(IWebController i_WebController)
 {
     m_WebController = i_WebController;
     InitializeComponent();
     m_FacebookFetcher.m_FetchedFriendsCompletedInvoker += onFetchedFriendsCompleted;
 }
 public bool Validate(IWebController context)
 {
     return context.WebMethod.Equals(_method);
 }
 public bool Validate(IWebController context)
 {
     return(context.DeviceType != DeviceType.Unknown);
 }
 public bool Validate(IWebController context)
 {
     if (string.IsNullOrEmpty(context.ClientVersion)) return false;
     return Versions.Contains(context.ClientVersion);
 }
Beispiel #23
0
 public WrongNumberOfParamsException(IWebAction action, IWebController controller)
 {
     actionName     = action.GetType().Name;
     controllerName = controller.GetType().Name;
 }