コード例 #1
0
ファイル: Molder.cs プロジェクト: jakeins/WatchCake
        /// <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);
        }
コード例 #2
0
ファイル: Molder.cs プロジェクト: jakeins/WatchCake
        /// <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);
            }
        }
コード例 #3
0
ファイル: Molder.cs プロジェクト: jakeins/WatchCake
        /// <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);
            }
        }
コード例 #4
0
ファイル: Molder.cs プロジェクト: jakeins/WatchCake
        /// <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);
        }
コード例 #5
0
ファイル: Molder.cs プロジェクト: jakeins/WatchCake
        /// <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);
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: vengent/Loonie-Tunes
        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;
            }
        }
コード例 #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);
 }
コード例 #8
0
 public void StringNoSpaceCount_SimpleString_ReturnsOne()
 {
     StringStuff strStuff = new StringStuff();
     int result = strStuff.StringNoSpaceCount("a");
     Assert.AreEqual(1, result);
 }
コード例 #9
0
 public void StringNoSpaceCount_EmptyString_ReturnsZero()
 {
     StringStuff strStuff = new StringStuff();
     int result = strStuff.StringNoSpaceCount("");
     Assert.AreEqual(0, result);
 }