Esempio n. 1
0
 public virtual bool CheckArguments(string[] InArguments, out string OutMessage)
 {
     if (this.argumentsTypes != null && this.argumentsTypes.Length > 0)
     {
         for (int i = 0; i < this.argumentsTypes.Length; i++)
         {
             ArgumentDescriptionAttribute argumentDescriptionAttribute = this.argumentsTypes[i];
             if (InArguments == null || i >= InArguments.Length)
             {
                 if (!argumentDescriptionAttribute.isOptional)
                 {
                     OutMessage = string.Format("无法执行命令,因为缺少参数<{0}>, 类型为:<{1}>", argumentDescriptionAttribute.name, argumentDescriptionAttribute.argumentType.get_Name());
                     return(false);
                 }
                 DependencyDescription[] depends = argumentDescriptionAttribute.depends;
                 if (depends != null && !this.CheckDependencies(argumentDescriptionAttribute, depends, InArguments, out OutMessage))
                 {
                     return(false);
                 }
             }
             else if (!argumentDescriptionAttribute.isOptional)
             {
                 string text;
                 if (!CheatCommandBase.TypeCastCheck(InArguments[i], this.argumentsTypes[i], out text))
                 {
                     OutMessage = string.Format("无法执行命令,因为参数[{2}]=\"{0}\"无法转换到{1}, 错误信息:{3}", new object[]
                     {
                         InArguments[i],
                         this.argumentsTypes[i].argumentType.get_Name(),
                         this.GetArgumentNameAt(i),
                         text
                     });
                     return(false);
                 }
             }
             else
             {
                 DependencyDescription[] depends2 = argumentDescriptionAttribute.depends;
                 string text2;
                 if (depends2 != null && !this.CheckDependencies(argumentDescriptionAttribute, depends2, InArguments, out OutMessage) && !CheatCommandBase.TypeCastCheck(InArguments[i], this.argumentsTypes[i], out text2))
                 {
                     OutMessage = string.Format("无法执行命令,因为参数[{2}]=\"{0}\"无法转换到{1}, 错误信息:{3}", new object[]
                     {
                         InArguments[i],
                         this.argumentsTypes[i].argumentType.get_Name(),
                         this.GetArgumentNameAt(i),
                         text2
                     });
                     return(false);
                 }
             }
         }
     }
     OutMessage = string.Empty;
     return(true);
 }
Esempio n. 2
0
 public static bool TypeCastCheck(string InArgument, ArgumentDescriptionAttribute InArgDescription, out string OutErrorMessage)
 {
     DebugHelper.Assert(InArgDescription != null);
     return(CheatCommandBase.TypeCastCheck(InArgument, InArgDescription.argumentType, out OutErrorMessage));
 }