コード例 #1
0
        public void TestThatGetFilteredStringPathRemovedIllegalCharacters()
        {
            string sTestString     = "`~!@#$%^&*()=+[{]}|;'\",<>?\a\b\t\r\v\f\n\u001B/opt/SpeechBridge`~!@#$%^&*()=+[{]}|;'\",<>?\a\b\t\r\v\f\n\u001B/Voice Doc_Store/AAMain.xml.vxml`~!@#$%^&*()=+[{]}|;'\",<>?\a\b\t\r\v\f\n\u001B";
            string sExpectedString = "/opt/SpeechBridge/Voice Doc_Store/AAMain.xml.vxml";

            Assert.That(StringFilter.GetFilteredStringPath(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #2
0
 public LocalizationFilter(int?id = null, DictionaryFilter dictionary = null, CultureFilter culture = null, StringFilter value = null)
 {
     Id         = id;
     Dictionary = dictionary;
     Culture    = culture;
     Value      = value;
 }
コード例 #3
0
ファイル: StringFilterTests.cs プロジェクト: b0wter/Podfilter
        public void PassesFilter_DoesNotContain_ReturnsTrue(string argument, bool caseInvariant, bool expected)
        {
            var filter = new StringFilter(argument, StringFilter.StringFilterMethod.DoesNotContain, caseInvariant);
            var result = filter.PassesFilter("This is a string for TESTING.");

            Assert.Equal(expected, result);
        }
コード例 #4
0
        public void TestThatGetFilteredStringPathCanHandleAnEmptyString()
        {
            string sTestString     = "";
            string sExpectedString = sTestString;

            Assert.That(StringFilter.GetFilteredStringPath(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #5
0
        public void TestThatGetFilteredStringPathLeavesAValidWindowsPathUnchanged()
        {
            string sTestString     = @"C:\Program Files\SpeechBridge\VoiceDoc Store\AAMain.xml.vxml";
            string sExpectedString = sTestString;

            Assert.That(StringFilter.GetFilteredStringPath(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #6
0
        public void TestThatGetFilteredStringPathLeavesAValidLinuxPathUnchanged()
        {
            string sTestString     = "/opt/SpeechBridge/Voice DocStore/AAMain.xml.vxml";
            string sExpectedString = sTestString;

            Assert.That(StringFilter.GetFilteredStringPath(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #7
0
        public void TestReplacementOfMultipleAnd()
        {
            string sTestString     = "Going on & on & on";
            string sExpectedString = "Going on and on and on";

            Assert.That(StringFilter.GetFilteredString(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #8
0
        public void TestThatGetFilteredStringDialOnlyAllowsDigits()
        {
            string sTestString     = "ABCDEFGHIJKLMNOPQRSTUVWXYZ (123) 456-7890 abcdefghijklpmnopqrstuvwxyz ~`!@#$%^&*()_-+={[}}\\|:;\"'<,>.?/";
            string sExpectedString = "1234567890";

            Assert.That(StringFilter.GetFilteredStringDial(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #9
0
        public void TestThatGetFilteredStringRemovesLeadingAndTrailingUnderscores()
        {
            string sTestSting      = "_I use underscore instead of spaces __ ";
            string sExpectedString = "I use underscore instead of spaces";

            Assert.That(StringFilter.GetFilteredString(sTestSting), Is.EqualTo(sExpectedString));
        }
コード例 #10
0
        public void TestReplacementOfAnd()
        {
            string sTestString     = "Adam & Eve";
            string sExpectedString = "Adam and Eve";

            Assert.That(StringFilter.GetFilteredString(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #11
0
        public void TestThatGetFilteredStringReplacesUnderscoreWithSpace()
        {
            string sTestSting      = "I_use_underscore_instead_of_spaces";
            string sExpectedString = "I use underscore instead of spaces";

            Assert.That(StringFilter.GetFilteredString(sTestSting), Is.EqualTo(sExpectedString));
        }
コード例 #12
0
        public void TestThatGetFilteredStringReplacesMultipleConsecutiveUnderscoresWithASingleSpace()
        {
            string sTestSting      = "I__use__underscore__instead____of_________spaces";
            string sExpectedString = "I use underscore instead of spaces";

            Assert.That(StringFilter.GetFilteredString(sTestSting), Is.EqualTo(sExpectedString));
        }
コード例 #13
0
        public void TestThatRemoveApostrophesCanHandleAnEmptyString()
        {
            string sTestString     = "";
            string sExpectedString = sTestString;

            Assert.That(StringFilter.RemoveApostrophes(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #14
0
        public void TestThatRemoveApostrophesWorks()
        {
            string sTestString     = "I'd like to help but can't.";
            string sExpectedString = "Id like to help but cant.";

            Assert.That(StringFilter.RemoveApostrophes(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #15
0
        public void TestThatMultipleHtmlNbspAreRemoved()
        {
            string sTestString     = "&nbsp; &nbsp;&nbsp;";
            string sExpectedString = "";

            Assert.That(StringFilter.GetFilteredString(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #16
0
        public void TestThatRemoveSpacesWorks()
        {
            string sTestString     = "This is a test.";
            string sExpectedString = "Thisisatest.";

            Assert.That(StringFilter.RemoveSpaces(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #17
0
        public void TestThatGetFilteredStringReducesConsecutiveSpacesToASingleSpace()
        {
            string sTestString     = "Jane    Doe";
            string sExpectedString = "Jane Doe";

            Assert.That(StringFilter.GetFilteredString(sTestString), Is.EqualTo(sExpectedString));
        }
コード例 #18
0
ファイル: StringFilterTests.cs プロジェクト: b0wter/Podfilter
        public void PassesFilter_DoesNotMatch_ReturnsTrue(string toTest, bool caseInvariant, bool expected)
        {
            var filter = new StringFilter("This is a string for TESTING.", StringFilter.StringFilterMethod.DoesNotMatch, caseInvariant);
            var result = filter.PassesFilter(toTest);

            Assert.Equal(expected, result);
        }
コード例 #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sendType">1:添加,2:编辑,3:删除</param>
        /// <param name="DataType">1:Excel批量导入,2:单条数据</param>
        /// <param name="DeviceList"></param>
        public void PostSend(int sendType, int DataType, string DeviceList)
        {
            HttpContext context        = HttpContext.Current;
            Random      rand           = new Random();
            int         Num            = rand.Next(1000, 9999);
            string      Token          = StringFilter.RefKeyMd5(key + Num);
            string      tempDeviceList = DeviceList;

            DeviceList = context.Server.UrlEncode(DesModel.RefDesStr(DeviceList, 1));

            System.Net.WebClient WebClientObj = new System.Net.WebClient();
            System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection();
            PostVars.Add("Token", Token);
            PostVars.Add("Num", Num.ToString());
            PostVars.Add("DeviceList", DeviceList);
            PostVars.Add("DataType", DataType.ToString());

            try
            {
                byte[] byRemoteInfo = WebClientObj.UploadValues(SynUrl + DevSendType(sendType), "POST", PostVars);
                //下面都没用啦,就上面一句话就可以了
                string sRemoteInfo = System.Text.Encoding.Default.GetString(byRemoteInfo);
                Logger.writeLog("同步AP数据:" + tempDeviceList + ",处理结果:" + sRemoteInfo);
                //这是获取返回信息
            }
            catch (Exception e)
            {
                Logger.ErrorLog(e, new Dictionary <string, string>()
                {
                    { "sendMessage", tempDeviceList }
                });
            }
        }
コード例 #20
0
ファイル: UserFilter.cs プロジェクト: RWooters/Platformus
 public UserFilter(int?id = null, StringFilter name = null, DateTimeFilter created = null, CredentialFilter credential = null)
 {
     Id         = id;
     Name       = name;
     Created    = created;
     Credential = credential;
 }
コード例 #21
0
 public DataTypeParameterValueFilter(int?id = null, DataTypeParameterFilter dataTypeParameter = null, MemberFilter member = null, StringFilter value = null)
 {
     Id = id;
     DataTypeParameter = dataTypeParameter;
     Member            = member;
     Value             = value;
 }
コード例 #22
0
    private void OkClick()
    {
        string s = _InputField.text.Trim();

        if (s.Equals(null) || s.Equals(""))
        {
            Warning.text = "字符串为空!";
            return;
        }

        if (null != FilterRegularStr)
        {
            bool b = StringFilter.StrMatchRegex(s, FilterRegularStr);

            if (!b)
            {
                //不符合过滤规则,输出错误提示
                Warning.text = WarningStr;
                return;
            }
        }


        if (null != Callback)
        {
            IoBuffer ib = new IoBuffer();
            if (!s.Equals(null))
            {
                ib.PutString(_InputField.text);
                Callback(ib.ToArray());
            }
        }

        Close();
    }
コード例 #23
0
        public void ShouldRemoveXsOfStringMaintainingFirstAndLastX()
        {
            StringFilter firstString = new StringFilter("xxHxix");

            firstString.removeXs();

            StringFilter secondString = new StringFilter("abcd");

            secondString.removeXs();

            StringFilter thirdString = new StringFilter("xabcdx");

            thirdString.removeXs();

            StringFilter fourthString = new StringFilter("");

            fourthString.removeXs();

            StringFilter fiftyString = new StringFilter("x");

            fiftyString.removeXs();


            Assert.Equal("abcd", secondString.GetString());
            Assert.Equal("xabcdx", thirdString.GetString());
            Assert.Equal("", fourthString.GetString());
            Assert.Equal("x", fiftyString.GetString());
            Assert.Equal("xHix", firstString.GetString());
        }
コード例 #24
0
        protected override void ReadHeader(StreamReader sr)
        {
            base.ReadHeader(sr);

            string filterType;

            while ((filterType = sr.ReadLine()) != null)
            {
                Filter filter = null;

                switch (filterType)
                {
                case "StringFilter":
                    filter = new StringFilter(sr);
                    break;

                case "RatingFilter":
                    filter = new RatingFilter(sr);
                    break;

                case "DateFilter":
                    filter = new DateFilter(sr);
                    break;

                default:
                    throw new FileLoadException();
                }

                Filters.Add(filter);
            }
        }
コード例 #25
0
#pragma warning restore CA1051 // Do not declare visible instance fields

        public VisualizationSettings()
        {
            PlayMode = PlayModeOption.History;

            DateFrom = new DateTime(1900, 1, 1);
            DateTo   = new DateTime(2099, 1, 1);

            UsersFilter = new StringFilter("*", "");
            FilesFilter = new StringFilter("*", "");

            ViewFileNames = false;
            ViewDirNames  = true;
            ViewUserNames = true;
            ViewAvatars   = true;

            TimeScale     = TimeScaleOption.None;
            SecondsPerDay = 5;
            MaxFiles      = 10000;

            ResolutionWidth  = Screen.PrimaryScreen.Bounds.Width;
            ResolutionHeight = Screen.PrimaryScreen.Bounds.Height;

            ViewLogo     = CheckState.Indeterminate;
            LogoFileName = null;
        }
コード例 #26
0
ファイル: FilterPopup.cs プロジェクト: Weltorn/KoPlayer
        public void EditStringFilter(StringFilter filter)
        {
            old = new StringFilter(filter);
            SetStringFilterParams();

            if (filter.Field == "title")
            {
                filterType_combobox.SelectedIndex = 0;
            }
            else if (filter.Field == "artist")
            {
                filterType_combobox.SelectedIndex = 1;
            }
            else if (filter.Field == "album")
            {
                filterType_combobox.SelectedIndex = 2;
            }
            else if (filter.Field == "genre")
            {
                filterType_combobox.SelectedIndex = 3;
            }

            if (filter.Contains)
            {
                filterParams_combobox.SelectedIndex = 0;
            }
            else
            {
                filterParams_combobox.SelectedIndex = 1;
            }

            searchString_textbox.Text = filter.SearchTerm;
        }
コード例 #27
0
        public void NoAttributes()
        {
            //arrange
            Init();
            var filter = new StringFilter {
                NoAttribute = "NoAttribute"
            };

            //act
            var filtered = Context.StringTestItems
                           .AutoFilter(filter)
                           .OrderBy(x => x.NoAttribute)
                           .ToList();

            //assert
            Assert.Equal(2, filtered.Count);
            Assert.Equal("noattribute", filtered[0].NoAttribute);
            Assert.Equal("NoAttributeOk", filtered[1].NoAttribute);

            /* EF Core
             * SELECT [Id]
             * ,[NoAttribute]
             * ,LEFT(s.[NoAttribute], (LEN(N'NoAttribute')))  as L
             * FROM [dbo].[StringTestItems] s
             * where [NoAttribute] LIKE 'NoAttribute' + '%' AND (LEFT(s.[NoAttribute], (LEN(N'NoAttribute'))) = N'NoAttribute')
             *
             */

            /* EF 6
             * WHERE NoAttribute LIKE N'NoAttribute%'
             */
        }
コード例 #28
0
        public void ContainsCase()
        {
            //arrange
            Init();
            var filter = new StringFilter {
                ContainsCase = "ContainsCase"
            };

            //act
            var filtered = Context.StringTestItems
                           .AutoFilter(filter)
                           .OrderBy(x => x.ContainsCase)
                           .ToList();

            //assert
            Assert.Equal(2, filtered.Count);
            Assert.Equal("containscase", filtered[0].ContainsCase);
            Assert.Equal("TestContainsCase", filtered[1].ContainsCase);

            /* EF Core
             * SELECT [Id], ContainsCase
             * FROM [dbo].[StringTestItems] s
             * where charindex('ContainsCase', s.ContainsCase) > 0
             */

            /* EF 6
             * WHERE ContainsCase LIKE '%ContainsCase%'
             */
        }
コード例 #29
0
        public async void OnDrop(IDataObject dropObject, IEnumerable dropTarget)
        {
            string[] filenames = (string[])dropObject.GetData(DataFormats.FileDrop, true);
            var      list      = StringFilter.FilterFiles(filenames);

            await LoadImages(list);
        }
コード例 #30
0
 public StringFilterViewModel(
     ICommandBus commandBus,
     StringFilter filter)
     : base(commandBus, filter)
 {
     _filter = filter;
 }
コード例 #31
0
 private static string BuildFilter(StringFilter Filter)
 {
     string FilterValue = "";
     string Separator = "";
     if (Filter.HasFlag(StringFilter.Alpha))
     {
         FilterValue += Separator + "[a-zA-Z]";
         Separator = "|";
     }
     if (Filter.HasFlag(StringFilter.Numeric))
     {
         FilterValue += Separator + "[0-9]";
         Separator = "|";
     }
     if (Filter.HasFlag(StringFilter.FloatNumeric))
     {
         FilterValue += Separator + @"[0-9\.]";
         Separator = "|";
     }
     if (Filter.HasFlag(StringFilter.ExtraSpaces))
     {
         FilterValue += Separator + @"[ ]{2,}";
         Separator = "|";
     }
     return FilterValue;
 }
コード例 #32
0
 public void Test1xItemFitCaseSensitive()
 {
     var result = new StringFilter(true).Filter(new List<string> { "AAaBBb", "AAa", "BBb" });
     Assert.AreEqual(1, result.Count);
     Assert.IsTrue(result.Contains("AAaBBb"));
 }
コード例 #33
0
 public void Test0xItemFitCaseSensitive()
 {
     var result = new StringFilter(true).Filter(new List<string> { "aaabbb", "aAa", "Bbb" });
     Assert.AreEqual(0, result.Count);
 }
コード例 #34
0
ファイル: Evaluator.cs プロジェクト: SuperJMN/Glass
 protected Evaluator(StringFilter stringFilter)
 {
     Filter = stringFilter;
 }
コード例 #35
0
 /// <summary>
 /// Removes everything that is in the filter text from the input.
 /// </summary>
 /// <param name="Input">Input text</param>
 /// <param name="Filter">Predefined filter to use (can be combined as they are flags)</param>
 /// <returns>Everything not in the filter text.</returns>
 public static string Remove(this string Input, StringFilter Filter)
 {
     if (string.IsNullOrEmpty(Input))
         return "";
     string Value = BuildFilter(Filter);
     return Input.Remove(Value);
 }
コード例 #36
0
 public AlphanumericEvaluator(StringFilter stringFilter)
     : base(stringFilter)
 {
 }
コード例 #37
0
 /// <summary>
 /// Removes everything that is not in the filter text from the input.
 /// </summary>
 /// <param name="Input">Input text</param>
 /// <param name="Filter">Predefined filter to use (can be combined as they are flags)</param>
 /// <returns>The input text minus everything not in the filter text.</returns>
 public static string Keep(this string Input, StringFilter Filter)
 {
     if (string.IsNullOrEmpty(Input))
         return "";
     var Value = BuildFilter(Filter);
     return Input.Keep(Value);
 }
コード例 #38
0
 /// <summary>
 /// Replaces everything that is in the filter text with the value specified.
 /// </summary>
 /// <param name="Input">Input text</param>
 /// <param name="Value">Value to fill in</param>
 /// <param name="Filter">Predefined filter to use (can be combined as they are flags)</param>
 /// <returns>The input text with the various items replaced</returns>
 public static string Replace(this string Input, StringFilter Filter, string Value = "")
 {
     if (string.IsNullOrEmpty(Input))
         return "";
     string FilterValue = BuildFilter(Filter);
     return new Regex(FilterValue).Replace(Input, Value);
 }