示例#1
0
        public static PatternError ConvertAll(string MultiVariable, out string Output)
        {
            PatternError Err = PatternError.NoError;

            Output = "";

            if (string.IsNullOrEmpty(MultiVariable)) { Err = PatternError.BlankString; return Err; }


            bool AutoUsed = false;

            for (int i = 0; i <= MultiVariable.Length - 1; i++)
            {
                string VribleCheckStr, CheckChar = MultiVariable.Substring(i, 1);

                if (i + 2 > MultiVariable.Length) VribleCheckStr = MultiVariable.Substring(i);
                else VribleCheckStr = MultiVariable.Substring(i, 2);

                string[] checkStr = { "%d", "%D", "%s", "%t", "%T", "%a", "%%" };
                bool flag = false;

                foreach (string str in checkStr)
                    if (VribleCheckStr == str) {
                        if (AutoUsed == true) { Err = PatternError.AlreadyAutoUsed; return Err; }
                        if (VribleCheckStr == "%a") AutoUsed = true; 
                        flag = true;
                        break;
                    }

                foreach (string CheckAccstr in NotAccessStr.ToCharArray().Select((elem) => elem.ToString()))
                    if (CheckChar == CheckAccstr) { Err = PatternError.CannotAccessString; return Err; }

                if (flag)
                {
                    Output += Convert(VribleCheckStr);

                    i++;
                }
                else if (!flag)
                {

                    if (VribleCheckStr.Substring(0, 1) == "%")
                    {
                        Err = PatternError.UnknownVariable; return Err;
                    }
                    Output += MultiVariable.Substring(i, 1);
                    continue;
                }
            }
            
            return Err;
        }
示例#2
0
        public static PatternError ConvertAll(string MultiVariable, out string Output)
        {
            PatternError Err = PatternError.NoError;

            Output = "";

            if (string.IsNullOrEmpty(MultiVariable))
            {
                Output = Convert("%a"); return(Err);
            }


            for (int i = 0; i <= MultiVariable.Length - 1; i++)
            {
                string VribleCheckStr, CheckChar = MultiVariable.Substring(i, 1);

                if (i + 2 > MultiVariable.Length)
                {
                    VribleCheckStr = MultiVariable.Substring(i);
                }
                else
                {
                    VribleCheckStr = MultiVariable.Substring(i, 2);
                }

                string[] checkStr = { "%d", "%m", "%a", "%%" };
                bool     flag     = false;

                foreach (string str in checkStr)
                {
                    if (VribleCheckStr == str)
                    {
                        flag = true;
                        break;
                    }
                }

                foreach (string CheckAccstr in NotAccessStr.ToCharArray().Select((elem) => elem.ToString()))
                {
                    if (CheckChar == CheckAccstr && CheckAccstr != "\\" && CheckAccstr != ":")
                    {
                        Err = PatternError.CannotAccessString; return(Err);
                    }
                }

                if (flag)
                {
                    Output += Convert(VribleCheckStr);

                    i++;
                }
                else if (!flag)
                {
                    if (VribleCheckStr.Substring(0, 1) == "%")
                    {
                        Err = PatternError.UnknownVariable; return(Err);
                    }
                    Output += MultiVariable.Substring(i, 1);
                    continue;
                }
            }

            return(Err);
        }