예제 #1
0
    protected virtual bool CheckDependencies(ArgumentDescriptionAttribute InArugmentDescription, DependencyDescription[] InDependencies, string[] InArguments, out string OutMessage)
    {
        OutMessage = string.Empty;
        if (InArguments == null)
        {
            OutMessage = "缺少所有必要参数";
            return(false);
        }
        for (int i = 0; i < InDependencies.Length; i++)
        {
            DependencyDescription dependencyDescription = InDependencies[i];
            DebugHelper.Assert(dependencyDescription.dependsIndex >= 0 && dependencyDescription.dependsIndex < this.argumentsTypes.Length, "maybe internal error, can't find depend argument description.");
            if (dependencyDescription.dependsIndex < 0 || dependencyDescription.dependsIndex >= this.argumentsTypes.Length)
            {
                OutMessage = "maybe internal error, can't find depend argument description.";
                return(false);
            }
            DebugHelper.Assert(dependencyDescription.dependsIndex < InArguments.Length);
            string text         = InArguments[dependencyDescription.dependsIndex];
            Type   argumentType = this.argumentsTypes[dependencyDescription.dependsIndex].argumentType;
            IArgumentDescription description = Singleton <ArgumentDescriptionRepository> .instance.GetDescription(argumentType);

            DebugHelper.Assert(description != null);
            text = description.GetValue(argumentType, text);
            if (dependencyDescription.ShouldBackOff(text))
            {
                OutMessage = string.Format("您必须提供参数<{2}>, 因为参数<{0}>=\"{1}\"", this.argumentsTypes[dependencyDescription.dependsIndex].name, text, InArugmentDescription.name);
                return(false);
            }
        }
        return(true);
    }
예제 #2
0
    private bool ShouldSkip(ArgumentDescriptionAttribute InArgAttr, ref string[] ExistsValues)
    {
        DebugHelper.Assert(InArgAttr.isOptional);
        foreach (DependencyDescription description in InArgAttr.depends)
        {
            string               inArgument   = ExistsValues[description.dependsIndex];
            System.Type          argumentType = this.CheatCommand.argumentsTypes[description.dependsIndex].argumentType;
            IArgumentDescription description2 = Singleton <ArgumentDescriptionRepository> .instance.GetDescription(argumentType);

            DebugHelper.Assert(description2 != null);
            inArgument = description2.GetValue(argumentType, inArgument);
            if (description.ShouldBackOff(inArgument))
            {
                return(false);
            }
        }
        return(true);
    }
예제 #3
0
    private bool ShouldSkip(ArgumentDescriptionAttribute InArgAttr, ref string[] ExistsValues)
    {
        DebugHelper.Assert(InArgAttr.isOptional);
        DependencyDescription[] depends = InArgAttr.depends;
        for (int i = 0; i < depends.Length; i++)
        {
            DependencyDescription dependencyDescription = depends[i];
            string text         = ExistsValues[dependencyDescription.dependsIndex];
            Type   argumentType = this.CheatCommand.argumentsTypes[dependencyDescription.dependsIndex].argumentType;
            IArgumentDescription description = Singleton <ArgumentDescriptionRepository> .instance.GetDescription(argumentType);

            DebugHelper.Assert(description != null);
            text = description.GetValue(argumentType, text);
            if (dependencyDescription.ShouldBackOff(text))
            {
                return(false);
            }
        }
        return(true);
    }