コード例 #1
0
ファイル: Command.cs プロジェクト: vanbrayne/ZenioxIrcBot
        public Command(string name, CommandFunction function)
        {
            this.Name = name;
            this.Function = function;

            CommandDispatcher.CommandList.Add(this.Name, this);
        }
コード例 #2
0
ファイル: TextOnly.cs プロジェクト: Dahrkael/CoRe
 public void AddCommand(string Text, CommandFunction F)
 {
     Command.TextOnly temp = new Command.TextOnly(Text);
     temp.OnClick = F;
     commands.Add(temp);
     RebuildWindow();
 }
コード例 #3
0
 public ReplicationCommandType GetReplicationCommandType(System.Data.IDbCommand cmd, CommandFunction fct)
 {
     switch (fct)
     {
         case CommandFunction.ExecuteNonQuery:
             return ReplicationCommandType.Write;
         case CommandFunction.ExecuteScalar:
         case CommandFunction.ExecuteReader:
             return ReplicationCommandType.Read;
     }
     return ReplicationCommandType.Read;
 }
コード例 #4
0
        void CommandButton(CommandFunction func, string buttonLabel, ref float buttonIndex)
        {
            if(GUI.Button(new Rect(margin, buttonEndY + (buttonIndex*(buttonHeight+buttonGap)), buttonWidth, buttonHeight), buttonLabel, HighLogic.Skin.button))
            {
                if(!selectAll)
                {
                    if(focusIndex < wingmen.Count)
                    {
                        func(wingmen[focusIndex], focusIndex);
                    }
                }
                else
                {
                    for(int i = 0; i < wingmen.Count; i++)
                    {
                        func(wingmen[i], i);
                    }
                }
            }

            buttonIndex++;
        }
コード例 #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="sCmd"></param>
 /// <param name="sHelp"></param>
 /// <param name="pFunc"></param>
 public GameCommand(string sCmd, string sHelp, CommandFunction pFunc)
 {
     m_sCommand = sCmd;
     m_sHelp    = sHelp;
     m_Function = pFunc;
 }
コード例 #6
0
 internal PrtgRequestMessage(ConnectionDetails connectionDetails, CommandFunction function, IParameters parameters) :
     this(connectionDetails, GetResourcePath(function), parameters)
 {
 }
コード例 #7
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommandEx(CommandFunction<CCommand, bool[], bool> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #8
0
        /// <summary>
        /// Add a command to the debugger with a specific name and help text.
        /// </summary>
        /// <param name="name">The name of the method in the debugger.</param>
        /// <param name="help">The help text to display in the console for the function.</param>
        /// <param name="function">The method to register.</param>
        /// <param name="types">The types for the arguments.</param>
        public void RegisterCommand(string name, string help, CommandFunction function, params CommandType[] types)
        {
            if (commands.ContainsKey(name)) return;
            if (instantCommands.ContainsKey(name)) return;

            commands.Add(name, new DebugCommand(function, types) { HelpDescription = help, Name = name });
        }
コード例 #9
0
 void RegisterInstantCommand(string name, string help, CommandFunction function, params CommandType[] types)
 {
     instantCommands.Add(name, new DebugCommand(function, types) { HelpDescription = help, Name = name });
 }
コード例 #10
0
 public static void RegisterCommandEx(string name, CommandFunction <float[]> action)
 {
     CRegistery.RegisterDelegate(name, action);
 }
コード例 #11
0
 public static void RegisterCommandEx(CommandFunction <string, string, string, bool> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #12
0
 public Command(CommandFunction func, string descr, int args)
 {
     description   = descr;
     function      = func;
     argumentCount = args;
 }
コード例 #13
0
        private async Task AddObjectInternalAsync(int objectId, NewObjectParameters parameters, CommandFunction function)
        {
            var lengthLimit = RequestParser.ValidateObjectParameters(parameters);

            var internalParams = RequestParser.GetInternalNewObjectParameters(objectId, parameters);

            if (lengthLimit.Count > 0)
            {
                await AddObjectWithExcessiveValueAsync(lengthLimit, internalParams, function).ConfigureAwait(false);
            }
            else
            {
                await requestEngine.ExecuteRequestAsync(function, internalParams).ConfigureAwait(false);
            }
        }
コード例 #14
0
        internal async Task <List <T> > AddObjectAsync <T>(int parentId, NewObjectParameters parameters, CommandFunction function,
                                                           Func <SearchFilter[], Task <List <T> > > getObjects, bool resolve, Action <Type, int> errorCallback = null, Func <bool> shouldStop = null,
                                                           bool allowMultiple = false) where T : SensorOrDeviceOrGroupOrProbe
        {
            if (resolve)
            {
                var filters = RequestParser.GetFilters(parentId, parameters);

                Func <Task> addObjectInternal = async() => await AddObjectInternalAsync(parentId, parameters, function).ConfigureAwait(false);

                Func <Task <List <T> > > getObjs = async() => await getObjects(filters).ConfigureAwait(false);

                return((await ResolveWithDiffAsync(addObjectInternal, getObjs, ResponseParser.ExceptTableObject, errorCallback, shouldStop, allowMultiple).ConfigureAwait(false)).OrderBy(o => o.Id).ToList());
            }
            else
            {
                await AddObjectInternalAsync(parentId, parameters, function).ConfigureAwait(false);

                return(null);
            }
        }
コード例 #15
0
        //######################################
        // AddObject
        //######################################

        internal List <T> AddObject <T>(int parentId, NewObjectParameters parameters, CommandFunction function,
                                        Func <SearchFilter[], List <T> > getObjects, bool resolve, Action <Type, int> errorCallback = null, Func <bool> shouldStop = null,
                                        bool allowMultiple = false) where T : SensorOrDeviceOrGroupOrProbe
        {
            if (resolve)
            {
                var filters = RequestParser.GetFilters(parentId, parameters);

                Action           addObjectInternal = () => AddObjectInternal(parentId, parameters, function);
                Func <List <T> > getObjs           = () => getObjects(filters);

                return((ResolveWithDiff(addObjectInternal, getObjs, ResponseParser.ExceptTableObject, errorCallback, shouldStop, allowMultiple)).OrderBy(o => o.Id).ToList());
            }
            else
            {
                AddObjectInternal(parentId, parameters, function);

                return(null);
            }
        }
コード例 #16
0
        private async Task AddObjectWithExcessiveValueAsync(List <KeyValuePair <Parameter, object> > lengthLimit, Parameters.Parameters internalParams, CommandFunction function)
        {
            var limitParam = lengthLimit.First();

            var limit = limitParam.Key.GetEnumAttribute <LengthLimitAttribute>().Length;

            if (limitParam.Value is IEnumerable)
            {
                var list = ((IEnumerable)limitParam.Value).Cast <object>().ToList();

                var count = list.Count();

                if (count > limit)
                {
                    for (int i = 0; i < count; i += limit)
                    {
                        var thisRequest = list.Skip(i).Take(limit);

                        internalParams[limitParam.Key] = thisRequest;

                        await requestEngine.ExecuteRequestAsync(function, internalParams).ConfigureAwait(false);
                    }
                }
                else
                {
                    await requestEngine.ExecuteRequestAsync(function, internalParams).ConfigureAwait(false);
                }
            }
            else
            {
                throw new NotImplementedException($"Don't know how to handle {nameof(LengthLimitAttribute)} applied to value of type {limitParam.Value.GetType()}");
            }
        }
コード例 #17
0
ファイル: CommandType.cs プロジェクト: ramseur/ModernMUD
 CommandType(string nam, CommandFunction fun, int pos, int lvl, LogType logged, bool shown, bool removeinvis, bool removehide, bool removemed, bool usePara, bool mustSpellOut)
 {
     Name = nam;
     Function = fun;
     MinLevel = lvl;
     LoggingType = logged;
     Show = shown;
     BreakInvisibility = removeinvis;
     BreakHide = removehide;
     BreakMeditate = removemed;
     MinPosition = pos;
     CanUseWhenParalyzed = usePara;
     MustSpellOut = mustSpellOut;
 }
コード例 #18
0
ファイル: Debugger.cs プロジェクト: KrissLaCross/BreakOut
 public void RegisterInstantCommand(CommandFunction function, params CommandType[] types) {
     RegisterInstantCommand(function, types);
 }
コード例 #19
0
 public PrtgUrl(ConnectionDetails connectionDetails, CommandFunction function, IParameters parameters) :
     this(connectionDetails, GetResourcePath(function), parameters)
 {
 }
コード例 #20
0
 private PrtgUrl GetPrtgUrl(CommandFunction function, IParameters parameters) =>
 new PrtgUrl(prtgClient.connectionDetails, function, parameters);
コード例 #21
0
 public static void RegisterCommandEx(CommandFunction <CCommand, bool[], bool> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #22
0
ファイル: FunctionParameters.cs プロジェクト: vsbopi/PrtgAPI
 public CommandFunctionParameters(CommandFunction function)
 {
     Function = function;
 }
コード例 #23
0
 public static void RegisterCommandEx(string name, CommandFunction <CCommand, bool, bool, bool, bool> action)
 {
     CRegistery.RegisterDelegate(name, action);
 }
コード例 #24
0
 internal List <T> AddAndResolveObject <T>(int destinationId, NewObjectParameters parameters, CommandFunction function,
                                           Func <SearchFilter[], List <T> > getObjects) where T : SensorOrDeviceOrGroupOrProbe
 {
     return(AddAndResolveRunner(
                () => client.AddObject(
                    destinationId,
                    parameters,
                    function,
                    getObjects,
                    true,
                    DisplayResolutionError,
                    ShouldStop,
                    typeof(T) == typeof(Sensor)
                    )
                ));
 }
コード例 #25
0
 /// <summary>
 /// Add a command to the debugger with help text.
 /// </summary>
 /// <param name="function">The method to register.</param>
 /// <param name="help">The help text to display in the console for the function.</param>
 /// <param name="types">The types for the arguments.</param>
 public void RegisterCommand(CommandFunction function, string help, params CommandType[] types)
 {
     RegisterCommand(function.Method.Name.ToLower(), help, function, types);
 }
コード例 #26
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommandEx(string name, CommandFunction<CCommand, int[], bool> action)
 {
     CRegistery.RegisterDelegate(name, action);
 }
コード例 #27
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommandEx(CommandFunction<string, string, string, bool> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #28
0
		void CommandButton(CommandFunction func, string buttonLabel, ref float buttonLine, float startY, float margin, float buttonGap, float buttonWidth, float buttonHeight, bool sendToWingmen, bool pressed, object data)
		{
			float yPos = startY + margin + ((buttonHeight + buttonGap) * buttonLine);
			if(GUI.Button(new Rect(margin, yPos, buttonWidth, buttonHeight), buttonLabel, pressed ? HighLogic.Skin.box : HighLogic.Skin.button))
			{
				if(sendToWingmen)
				{
					if(wingmen.Count > 0)
					{
						foreach(var index in focusIndexes)
						{
							func(wingmen[index], index, data);
						}
					}

					if(commandSelf)
					{
						foreach(var ai in vessel.FindPartModulesImplementing<BDModulePilotAI>())
						{
							func(ai, -1, data);
						}
					}
				}
				else
				{
					func(null, -1, null);
				}
			}

			buttonLine++;
		}
コード例 #29
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommandEx(string name, CommandFunction<float[]> action)
 {
     CRegistery.RegisterDelegate(name, action);
 }
コード例 #30
0
ファイル: Debugger.cs プロジェクト: JOCP9733/tank
 /// <summary>
 /// Add a command to the debugger with help text.
 /// </summary>
 /// <param name="function">The method to register.</param>
 /// <param name="help">The help text to display in the console for the function.</param>
 /// <param name="types">The types for the arguments.</param>
 public void RegisterCommand(CommandFunction function, string help, params CommandType[] types)
 {
     RegisterCommand(function.Method.Name.ToLower(), help, function, types);
 }
コード例 #31
0
		void CommandButton(CommandFunction func, string buttonLabel, ref float buttonLine, bool sendToWingmen, bool pressed, object data = null)
		{
			CommandButton(func, buttonLabel, ref buttonLine, buttonEndY, margin, buttonGap, buttonWidth, buttonHeight, sendToWingmen, pressed, data);
		}
コード例 #32
0
 void CommandButton(CommandFunction func, string buttonLabel, ref float buttonLine, bool sendToWingmen,
                    bool pressed, object data = null)
 {
     CommandButton(func, buttonLabel, ref buttonLine, buttonEndY, margin, buttonGap, buttonWidth, buttonHeight,
                   sendToWingmen, pressed, data);
 }
コード例 #33
0
ファイル: SourceControlCommands.cs プロジェクト: sbambach/ATF
 private bool WrapCommandFunction(Command command, CommandFunction function, bool doing)
 {
     try
     {
         m_currentCommnd = command;
         return function(doing);
     }
     finally
     {
         m_currentCommnd = Command.Invalid;
     }
 }
コード例 #34
0
 public PrtgUrl(string server, string username, string passhash, CommandFunction function, Parameters.Parameters parameters) :
     this(server, username, passhash, GetResourcePath(function), parameters)
 {
 }