예제 #1
0
        // Private interface
        private bool Parse_Parameters( CSlashCommandInstance command_request, CSlashCommand command, ref string error_string )
        {
            CSlashCommandInfo command_info = Get_Command_Info( command.GetType() );
            if ( !command_request.Parse( command_info.CommandParser, command_info.RequiredParamCount, command_info.RequiredParamCount + command_info.OptionalParamCount ) )
            {
                error_string =	CCommonResource.Get_Text( ECommonTextID.Unable_To_Parse_Slash_Command );
                return false;
            }

            int current_parsed_param = 0;
            foreach ( var param_info in command_info.Params )
            {
                if ( current_parsed_param >= command_request.Count )
                {
                    if ( current_parsed_param < command_info.RequiredParamCount )
                    {
                        error_string =	CCommonResource.Get_Text( ECommonTextID.Slash_Command_Missing_Parameter );
                        return false;
                    }

                    break;
                }

                string param_string_value = command_request[ current_parsed_param ];
                PropertyInfo prop_info = param_info.ParamInfo;

                object param_value = Parse_Parameter( prop_info, param_string_value );
                if ( param_value == null )
                {
                    error_string = string.Format( CCommonResource.Get_Text( ECommonTextID.Unable_To_Parse_Parameter ),
                                                            param_string_value,
                                                            prop_info.Name,
                                                            current_parsed_param,
                                                            prop_info.PropertyType.Name,
                                                            command.GetType().Name );
                    return false;
                }

                prop_info.SetValue( command, param_value, null );
                current_parsed_param++;
            }

            return true;
        }