Esempio n. 1
0
        public bool GenerateAccount(StringBuilder sb, bool noVirtual = false)
        {
            bool mustBalance = true;
            bool isVirtual   = false;

            if (!noVirtual)
            {
                switch (ThreeGen.Value())
                {
                case 1:
                    sb.Append('[');
                    isVirtual = true;
                    break;

                case 2:
                    sb.Append('(');
                    mustBalance = false;
                    isVirtual   = true;
                    break;

                case 3:
                    break;
                }
            }

            sb.Append(GenerateString(StrLenGen.Value()));

            if (isVirtual)
            {
                if (mustBalance)
                {
                    sb.Append(']');
                }
                else
                {
                    sb.Append(')');
                }
            }

            return(mustBalance);
        }
Esempio n. 2
0
 public string GenerateNote()
 {
     return(String.Format("\n    ; {0}", GenerateString(StrLenGen.Value())));
 }
Esempio n. 3
0
 public string GeneratePayee()
 {
     return(GenerateString(StrLenGen.Value()));
 }
Esempio n. 4
0
        /// <summary>
        /// Ported from void generate_posts_iterator::generate_string
        /// </summary>
        public string GenerateString(int len, bool onlyAlpha = false)
        {
            Logger.Current.Debug("generate.post.string", () => String.Format("Generating string of length {0}, only alpha {1}", len, onlyAlpha));

            StringBuilder sb = new StringBuilder();

            int  last  = -1;
            bool first = true;

            for (int i = 0; i < len; i++)
            {
                int  next   = onlyAlpha ? 3 : ThreeGen.Value();
                bool output = true;
                switch (next)
                {
                case 1:                         // colon
                    if (!first && last == 3 && StrLenGen.Value() % 10 == 0 && i + 1 != len)
                    {
                        sb.Append(':');
                    }
                    else
                    {
                        i--;
                        output = false;
                    }
                    break;

                case 2:                         // space
                    if (!first && last == 3 && StrLenGen.Value() % 20 == 0 && i + 1 != len)
                    {
                        sb.Append(' ');
                    }
                    else
                    {
                        i--;
                        output = false;
                    }
                    break;

                case 3:                         // character
                    switch (ThreeGen.Value())
                    {
                    case 1:                     // uppercase
                        sb.Append(UpcharGen.Value());
                        break;

                    case 2:                     // lowercase
                        sb.Append(DowncharGen.Value());
                        break;

                    case 3:                     // number
                        if (!onlyAlpha && !first)
                        {
                            sb.Append(NumcharGen.Value());
                        }
                        else
                        {
                            i--;
                            output = false;
                        }
                        break;
                    }
                    break;
                }
                if (output)
                {
                    last  = next;
                    first = false;
                }
            }

            return(sb.ToString());
        }