Ejemplo n.º 1
0
        public bool IsConnect(int id)
        {
            var tureId = GetType().FullName + id;

            lock (ActionDictionary)
            {
                return(ActionDictionary.ContainsKey(tureId) && ActionDictionary[tureId].Count > 0);
            }
        }
Ejemplo n.º 2
0
        public ActionDictionary GetActions()
        {
            ActionDictionary actionTypes = new ActionDictionary();

            actionTypes.Add("create", create);
            actionTypes.Add("call", call);
            actionTypes.Add("get", get);
            actionTypes.Add("set", set);
            return(actionTypes);
        }
Ejemplo n.º 3
0
 public NativeWindowHook(Control control)
     : base()
 {
     MessageActions = new ActionDictionary();
     Hooked         = control;
     if (!control.IsHandleCreated)
     {
         control.HandleCreated += OnHookedHandleCreated;
     }
     else
     {
         AssignHandle(control.Handle);
     }
 }
Ejemplo n.º 4
0
 public AdminController()
     : base()
 {
     ActionDictionary.Add("DCIP", DisconnectIP);
     ActionDictionary.Add("DCSERVER", DisconnectServer);
     ActionDictionary.Add("CSERVER", ConnectServer);
     ActionDictionary.Add("ACSERVER", AddConnectNewServer);
     ActionDictionary.Add("ADDSERVER", AddNewServer);
     ActionDictionary.Add("DELSERVER", RemoveServer);
     ActionDictionary.Add("LISTSERVERS", ListServers);
     ActionDictionary.Add("DCL", DisableCommand);
     ActionDictionary.Add("CLS", ClearConsole);
     ActionDictionary.Add("EXIT", Exit);
     ActionDictionary.Add("HELP", Help);
     NLConsole.WriteLine(UIStrings.HelpPrompt, ConsoleColor.Red);
 }
Ejemplo n.º 5
0
    private void Initialize()
    {
        ActionDictionary.Subscribe(ActionID.Trigger_Click_Down, Hello);
        ActionDictionary.Subscribe(ActionID.Trigger_Click_Up, Goodbye);

        ActionDictionary.Subscribe(ActionID.Grip_Click_Down, TeleportAim);
        ActionDictionary.Subscribe(ActionID.Grip_Click_Up, TeleportMove);

        ActionDictionary.Subscribe(ActionID.TrackPad_Touching_Down, OpenMenu);
        ActionDictionary.Subscribe(ActionID.TrackPad_Touching_Up, CloseMenu);

        ActionDictionary.Subscribe(ActionID.TrackPad_Click_Down, TrackPadClickDown);
        ActionDictionary.Subscribe(ActionID.TrackPad_Click_Up, TrackPadClickUp);
        ActionDictionary.Subscribe(ActionID.Restart, Restart);

        SetSize(Enum.GetValues(typeof(InputID)).Length);
    }
Ejemplo n.º 6
0
        public ClearcoatDataItemCollection Flatten()
        {
            ClearcoatDataItemCollection retCollection = new ClearcoatDataItemCollection();
            // foreach constr in action
            ActionDictionary actionTypes = GetActions();

            foreach (var actionType in actionTypes)
            {
                PropertyDictionary property = actionType.Value;
                if (property != null)
                {
                    foreach (KeyValuePair <string, int> propertyCount in property)
                    {
                        ClearCoatDataItem ccdi = new ClearCoatDataItem(this.session, this.url, actionType.Key, propertyCount.Key, propertyCount.Value);
                        retCollection.Add(ccdi);
                    }
                }
            }
            return(retCollection);
        }
 public DeploymentModule(
     IExceptionHandler exceptionHandler,
     IApplicationSettings applicationSettings,
     ISystemClock systemClock,
     IConsoleWrapper <DeploymentModule> consoleWrapper,
     ITargetService targetService,
     IDeploymentService deploymentService)
     : base(exceptionHandler)
 {
     ActionDictionary
     .Add(builder => builder.Add("add", AddDeployment)
          .Add("list", ListDeployments));
     DefaultAction            = GetDeployment;
     RequiresArguments        = true;
     WriteLineAsyncAction     = (format, args, logLevel) => consoleWrapper.WriteLineAsync(format, true, logLevel, args);
     this.applicationSettings = applicationSettings;
     this.systemClock         = systemClock;
     this.consoleWrapper      = consoleWrapper;
     this.targetService       = targetService;
     this.deploymentService   = deploymentService;
 }
Ejemplo n.º 8
0
    bool CheckAgainstTriggerValueGlobal(ActionDictionary ad, EZPZ_TreeInfoHolder.VariableData vd)
    {
        switch (ad.varTypeToCheck)
        {
        case VarType.BOOL:
            //If it's t then it's true, anything else and it's false
            bool adBool = (ad.triggerValue == "t") ? true : false;
            return(adBool == vd.boolVal);

        case VarType.INT:
            return(ad.triggerValue == vd.intVal.ToString());

        case VarType.FLOAT:
            return(ad.triggerValue == vd.floatVal.ToString());

        case VarType.STRING:
            return(ad.triggerValue == vd.stringVal);

        default:
            return(false);
        }
    }
 public TargetModule(
     ISystemClock systemClock,
     IExceptionHandler exceptionHandler,
     IConsoleWrapper <TargetModule> consoleWrapper,
     ICacheState <DateTimeOffset> cacheState,
     ITargetTypeService targetTypeService,
     ITargetService targetService,
     IDeploymentCache deploymentCache)
     : base(exceptionHandler)
 {
     ActionDictionary.Add(builder => builder
                          .Add("add", AddTarget)
                          .Add("list", ListTargets));
     WriteLineAsyncAction   = (format, args, logLevel) => consoleWrapper.WriteLineAsync(format, true, logLevel, args);
     DefaultAction          = GetTarget;
     RequiresArguments      = true;
     this.systemClock       = systemClock;
     this.consoleWrapper    = consoleWrapper;
     this.cacheState        = cacheState;
     this.targetTypeService = targetTypeService;
     this.targetService     = targetService;
     this.deploymentCache   = deploymentCache;
 }
Ejemplo n.º 10
0
        public virtual Task ExecuteRequest(ICommand command, IEnumerable <string> arguments, IEnumerable <IParameter> parameters, CancellationToken cancellationToken)
        {
            return(exceptionHandler.TryAsync(arguments, args =>
            {
                var firstArgument = arguments.FirstOrDefault();
                bool hasFirstArgument = false;

                if (RequiresArguments && (hasFirstArgument = firstArgument == null))
                {
                    throw ModuleException("Invalid arguments", LogLevel.Warning);
                }

                var remainingArguments = hasFirstArgument ? arguments.RemoveAt(0) : arguments;

                if (ActionDictionary.TryGetValue(firstArgument ?? command.Name.ToLower(), out var action))
                {
                    action(remainingArguments, parameters, cancellationToken);
                }
                else
                {
                    return DefaultAction?.Invoke(firstArgument, remainingArguments, parameters, cancellationToken);
                }

                return Task.CompletedTask;
            }, exception =>
            {
                if (exception is ModuleException moduleException)
                {
                    return WriteLineAsyncAction(exception.Message, moduleException.Arguments, moduleException.LogLevel);
                }

                return WriteLineAsyncAction(exception.Message, null, LogLevel.Error);
            },
                                             exceptionTypes => exceptionTypes
                                             .DescribeType <ModuleException>()
                                             .DescribeType <DataValidationException>()));
        }
Ejemplo n.º 11
0
 public QueryController() : base()
 {
     ActionDictionary.Add("HASH", CheckHashAction);
     RemoteActionDictionary.Add("HASH", CheckHashAction);
 }
Ejemplo n.º 12
0
        public static RouteCollection MapRoutes(this RouteCollection routes, Assembly assembly, ActionDictionary actions)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }

            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            assembly.GetTypes()
                // Find all non abstract classes of type Controller and whose names end with "Controller"
                .Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(typeof(Controller)) && x.Name.EndsWith("Controller"))

                // Find all public methods from those controller classes
                .SelectMany(x => x.GetMethods(), (x, y) => new { Controller = x.Name, Method = y, Namespace = x.Namespace })

                // Find all route attributes from those methods
                .SelectMany(x => x.Method.GetCustomAttributes(typeof(RouteAttribute), false),
                            (x, y) => new { Controller = x.Controller.Substring(0, x.Controller.Length - 10), Action = x.Method.Name, Method = x.Method, Namespace = x.Namespace, Route = (RouteAttribute)y })

                // Order selected entires by rank number and iterate through each of them
                .OrderBy(x => x.Route.Order == -1).ThenBy(x => x.Route.Order).ToList().ForEach(x =>
                {
                    // Set Defautls
                    var defaults = ParseRouteValues(x.Route.Defaults);
                    defaults.Add("controller", x.Controller);
                    defaults.Add("action", x.Action);

                    // Set Optional Parameters and remove '?' mark from the url
                    Match m;

                    while ((m = Regex.Match(x.Route.Url, @"\{([^\}]+?)\?\}")) != null && m.Success)
                    {
                        var p = m.Groups[1].Value;
                        defaults.Add(p, UrlParameter.Optional);
                        x.Route.Url = x.Route.Url.Replace("{" + p + "?}", "{" + p + "}");
                    }

                    // Set Defautls
                    var constraints = ParseRouteValues(x.Route.Constraints);

                    // Set Data Tokens
                    var dataTokens = new RouteValueDictionary();
                    dataTokens.Add("Namespaces", new string[] { x.Namespace });

                    var route = new Route(x.Route.Url, new MvcRouteHandler())
                    {
                        Defaults = defaults,
                        Constraints = constraints,
                        DataTokens = dataTokens
                    };

                    //Setup Actions
                    var par = x.Method.GetParameters().FirstOrDefault();
                    if (par == null)
                        throw new Exception("No Parameter found for action - " + x.Method.DeclaringType + ", " + x.Method.Name);

                    if (actions.ContainsKey(par.ParameterType))
                    {
                        throw new Exception("Parameter type already exists on another action - " + x.Method.DeclaringType + ", " + x.Method.Name + ", " + par.ParameterType);
                    }

                    actions.Add(par.ParameterType, new ActionInfo()
                    {
                        ClassType = x.Method.DeclaringType,
                        HttpMethod = x.Method.GetAttribute<HttpPostAttribute>() != null ? "post" : "get",
                        Name = x.Method.Name,
                        Controller = x.Controller,
                        Action = x.Action
                    });

                    x.Route.Name = par.ParameterType.FullName;
                    routes.Add(x.Route.Name, route);
                });

            return routes;
        }
Ejemplo n.º 13
0
        public static RouteCollection MapRoutes(this RouteCollection routes, Assembly assembly, ActionDictionary actions)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }

            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            assembly.GetTypes()
            // Find all non abstract classes of type Controller and whose names end with "Controller"
            .Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(typeof(Controller)) && x.Name.EndsWith("Controller"))

            // Find all public methods from those controller classes
            .SelectMany(x => x.GetMethods(), (x, y) => new { Controller = x.Name, Method = y, Namespace = x.Namespace })

            // Find all route attributes from those methods
            .SelectMany(x => x.Method.GetCustomAttributes(typeof(RouteAttribute), false),
                        (x, y) => new { Controller = x.Controller.Substring(0, x.Controller.Length - 10), Action = x.Method.Name, Method = x.Method, Namespace = x.Namespace, Route = (RouteAttribute)y })

            // Order selected entires by rank number and iterate through each of them
            .OrderBy(x => x.Route.Order == -1).ThenBy(x => x.Route.Order).ToList().ForEach(x =>
            {
                // Set Defautls
                var defaults = ParseRouteValues(x.Route.Defaults);
                defaults.Add("controller", x.Controller);
                defaults.Add("action", x.Action);

                // Set Optional Parameters and remove '?' mark from the url
                Match m;

                while ((m = Regex.Match(x.Route.Url, @"\{([^\}]+?)\?\}")) != null && m.Success)
                {
                    var p = m.Groups[1].Value;
                    defaults.Add(p, UrlParameter.Optional);
                    x.Route.Url = x.Route.Url.Replace("{" + p + "?}", "{" + p + "}");
                }

                // Set Defautls
                var constraints = ParseRouteValues(x.Route.Constraints);

                // Set Data Tokens
                var dataTokens = new RouteValueDictionary();
                dataTokens.Add("Namespaces", new string[] { x.Namespace });

                var route = new Route(x.Route.Url, new MvcRouteHandler())
                {
                    Defaults    = defaults,
                    Constraints = constraints,
                    DataTokens  = dataTokens
                };

                //Setup Actions
                var par = x.Method.GetParameters().FirstOrDefault();
                if (par == null)
                {
                    throw new Exception("No Parameter found for action - " + x.Method.DeclaringType + ", " + x.Method.Name);
                }

                if (actions.ContainsKey(par.ParameterType))
                {
                    throw new Exception("Parameter type already exists on another action - " + x.Method.DeclaringType + ", " + x.Method.Name + ", " + par.ParameterType);
                }

                actions.Add(par.ParameterType, new ActionInfo()
                {
                    ClassType  = x.Method.DeclaringType,
                    HttpMethod = x.Method.GetAttribute <HttpPostAttribute>() != null ? "post" : "get",
                    Name       = x.Method.Name,
                    Controller = x.Controller,
                    Action     = x.Action
                });

                x.Route.Name = par.ParameterType.FullName;
                routes.Add(x.Route.Name, route);
            });

            return(routes);
        }