Esempio n. 1
0
        public ArgumentDescriptionAttribute(
            int Index,
            Type InArgumentType,
            string InName,
            params object[] InDependencies
            )
        {
            index        = Index;
            argumentType = InArgumentType;
            name         = InName;
            defaultValue = "";

            commandLineType = argumentType.IsEnum ? typeof(string) : argumentType;

            if (InDependencies != null && InDependencies.Length >= 2)
            {
                DebugHelper.Assert(InDependencies.Length % 2 == 0);

                int GroupCount = InDependencies.Length >> 1;
                depends = new DependencyDescription[GroupCount];

                for (int i = 0; i < GroupCount; ++i)
                {
                    depends[i] = new DependencyDescription(
                        Convert.ToInt32(InDependencies[i << 1]),
                        Convert.ToString(InDependencies[(i << 1) + 1])
                        );
                }
            }
        }
Esempio n. 2
0
        private bool ShouldSkip(ArgumentDescriptionAttribute InArgAttr, ref string[] ExistsValues)
        {
            DebugHelper.Assert(InArgAttr.isOptional);

            DependencyDescription[] Dependencies = InArgAttr.depends;

            for (int i = 0; i < Dependencies.Length; ++i)
            {
                DependencyDescription Depend = Dependencies[i];

                string ExistsValue = ExistsValues[Depend.dependsIndex];

                var DependType = CheatCommand.argumentsTypes[Depend.dependsIndex].argumentType;

                var ArgDescInterface = ArgumentDescriptionRepository.instance.GetDescription(DependType);

                DebugHelper.Assert(ArgDescInterface != null);

                ExistsValue = ArgDescInterface.GetValue(DependType, ExistsValue);

                if (Depend.ShouldBackOff(ExistsValue))
                {
                    return(false);
                }
            }

            return(true);
        }
        protected virtual bool CheckDependencies(
            ArgumentDescriptionAttribute InArugmentDescription,
            DependencyDescription[] InDependencies,
            string[] InArguments,
            out string OutMessage
            )
        {
            OutMessage = "";

            if (InArguments == null)
            {
                OutMessage = "Missing parameters";
                return(false);
            }

            for (int i = 0; i < InDependencies.Length; ++i)
            {
                DependencyDescription CurDependency = InDependencies[i];

                DebugHelper.Assert(CurDependency.dependsIndex >= 0 && CurDependency.dependsIndex < argumentsTypes.Length, "maybe internal error, can't find depend argument description.");

                if (CurDependency.dependsIndex < 0 || CurDependency.dependsIndex >= argumentsTypes.Length)
                {
                    OutMessage = "maybe internal error, can't find depend argument description.";

                    return(false);
                }

                DebugHelper.Assert(CurDependency.dependsIndex < InArguments.Length);

                // try convert to actual value
                string CurDependValue = InArguments[CurDependency.dependsIndex];

                Type DependType = argumentsTypes[CurDependency.dependsIndex].argumentType;
                var  ArgDescriptionInterface = ArgumentDescriptionRepository.instance.GetDescription(DependType);

                DebugHelper.Assert(ArgDescriptionInterface != null);

                CurDependValue = ArgDescriptionInterface.GetValue(DependType, CurDependValue);

                if (CurDependency.ShouldBackOff(CurDependValue))
                {
                    OutMessage = string.Format(
                        "you must provide parameter <{2}>, because <{0}>=\"{1}\"",
                        argumentsTypes[CurDependency.dependsIndex].name,
                        CurDependValue,
                        InArugmentDescription.name
                        );

                    return(false);
                }
            }

            return(true);
        }
Esempio n. 4
0
        private bool ShouldSkip(ArgumentDescriptionAttribute InArgAttr, ref string[] ExistsValues)
        {
            DebugHelper.Assert(InArgAttr.isOptional);

            DependencyDescription[] Dependencies = InArgAttr.depends;

            for (int i = 0; i < Dependencies.Length; ++i)
            {
                DependencyDescription Depend = Dependencies[i];

                string ExistsValue = ExistsValues[Depend.dependsIndex];

                if (Depend.ShouldBackOff(ExistsValue))
                {
                    return(false);
                }
            }

            return(true);
        }