Exemplo n.º 1
0
        /// <summary>
        /// Gets the part of the subject string, that is between the two given strings.
        /// </summary>
        public static void Between(StringBuilder subject, IList <string> attributes)
        {
            int    startPosition = subject.ToString().IndexOf(attributes[0]);
            int    endPosition   = subject.ToString().IndexOf(attributes[1]);
            string stringy       = StringStuff.SubstrSafe(subject.ToString(), startPosition + 1, endPosition - startPosition - 1);

            subject.Clear();
            subject.Append(stringy);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Limit the length of the subject string by the specified given legths, by cutting off the end.
        /// </summary>
        public static void CutEnd(StringBuilder subject, IList <string> attributes)
        {
            int limit = int.Parse(attributes[0]);

            if (subject.Length > limit)
            {
                string stringy = StringStuff.SubstrSafe(subject.ToString(), 0, limit) + "…";
                subject.Clear();
                subject.Append(stringy);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the part of the subject string, that is after the last occurence of the given string.
        /// </summary>
        public static void AfterLast(StringBuilder subject, IList <string> attributes)
        {
            int position = subject.ToString().IndexOf(attributes[0]);

            if (position >= 0)
            {
                string stringy = StringStuff.SubstrSafe(subject.ToString(), position + attributes[0].Length);
                subject.Clear();
                subject.Append(stringy);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Do a short hash based on the subject, of a given length.
        /// </summary>
        public static void EasyHash(StringBuilder subject, IList <string> attributes)
        {
            string stringy;

            if (string.IsNullOrEmpty(attributes[0]))
            {
                stringy = StringStuff.ShortHashCode(subject.ToString());
            }
            else
            {
                stringy = StringStuff.ShortHashCode(subject.ToString(), int.Parse(attributes[0]));
            }

            subject.Clear();
            subject.Append(stringy);
        }
Exemplo n.º 5
0
        /// <summary>
        /// PHP-like substring, takes negative and out-of-bounds values.
        /// </summary>
        public static void Substr(StringBuilder subject, IList <string> attributes)
        {
            int    parsedStart = int.Parse(attributes[0]);
            string stringy;

            if (attributes.Count > 1)
            {
                var parsedEnd = int.Parse(attributes[1]);
                stringy = StringStuff.SubstrSafe(subject.ToString(), parsedStart, parsedEnd);
            }
            else
            {
                stringy = StringStuff.SubstrSafe(subject.ToString(), parsedStart);
            }

            subject.Clear();
            subject.Append(stringy);
        }
Exemplo n.º 6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            stringStuff  = new StringStuff();
            csvParse     = new CsvParse();
            clipBoard    = new ClipBoard();
            txtPath.Text = Properties.Settings.Default.appDataPath;
            var roamingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            rootDir = Path.Combine(roamingDirectory, @"LoonieTunes");
            Directory.CreateDirectory(rootDir);
            if (!string.IsNullOrEmpty(txtPath.Text))
            {
                btnProg.Visible = true;
            }
            if (!string.IsNullOrWhiteSpace(txtPath.Text))
            {
                btnCopy.Visible = true;
                PopulateDropDown();
                cmbRealmName.Text = Properties.Settings.Default.realmSelection;
            }
        }
Exemplo n.º 7
0
 public void StringNoSpaceCount_StringWithSpaces_ReturnsSeven()
 {
     StringStuff strStuff = new StringStuff();
     int result = strStuff.StringNoSpaceCount("a    bc   d    e    f                  g");
     Assert.AreEqual(7, result);
 }
Exemplo n.º 8
0
 public void StringNoSpaceCount_SimpleString_ReturnsOne()
 {
     StringStuff strStuff = new StringStuff();
     int result = strStuff.StringNoSpaceCount("a");
     Assert.AreEqual(1, result);
 }
Exemplo n.º 9
0
 public void StringNoSpaceCount_EmptyString_ReturnsZero()
 {
     StringStuff strStuff = new StringStuff();
     int result = strStuff.StringNoSpaceCount("");
     Assert.AreEqual(0, result);
 }