Example #1
0
        public static int IndexOfSafe(this string data, string keyword, bool inv = false)
        {
            var dataSafe    = SystemExtension.ToStringSafe(data);
            var keywordSafe = SystemExtension.ToStringSafe(keyword);

            return(inv ? keywordSafe.IndexOf(dataSafe) : dataSafe.IndexOf(keywordSafe));
        }
Example #2
0
        public static bool ToFilter(this string data, string keyword, Filter filter = Filter.Contains)
        {
            switch (filter)
            {
            case Filter.Contains:
            case Filter.ContainsInv:
            case Filter.NotContains:
            case Filter.NotContainsInv:
            {
                var inv   = Filter.ContainsInv == filter || Filter.NotContainsInv == filter;
                var index = SystemExtension.IndexOfSafe(data, keyword, inv);

                switch (filter)
                {
                case Filter.Contains:
                case Filter.ContainsInv:
                    return(-1 != index);

                case Filter.NotContains:
                case Filter.NotContainsInv:
                    return(-1 == index);
                }

                return(false);
            }

            case Filter.Equals:
                return(SystemExtension.ToStringSafe(data) == SystemExtension.ToStringSafe(keyword));

            case Filter.NotEquals:
                return(SystemExtension.ToStringSafe(data) != SystemExtension.ToStringSafe(keyword));
            }

            return(false);
        }
Example #3
0
 public static uint ToHexRGBA(float r, float g, float b, float a)
 {
     return(SystemExtension.ToHexRGBA((byte)(r * 255), (byte)(g * 255), (byte)(b * 255), (byte)(a * 255)));
 }