コード例 #1
0
        public static IEnumerable <FormatEvent> CreateCommandEvent(string format = null)
        {
            if (format == null || string.IsNullOrWhiteSpace(format))
            {
                yield break;
            }

            if (CasingHelper.Check(out var cmd1, format) && (cmd1 == 'U' || cmd1 == 'w'))
            {
                yield return(new FormatEvent(cmd1, 10000, CasingHelper.Format()(cmd1)));
            }

            if (PaddingHelper.Check(out var cmd2, out var width, format) && (cmd2 == 'r' || cmd2 == 'l'))
            {
                yield return(new FormatEvent(cmd2, 10001, PaddingHelper.Format()(cmd2)(width)));
            }

            if (CallerInfoHelper.Check(out var cmd3, format) && !string.IsNullOrWhiteSpace(cmd3))
            {
                yield return(new FormatEvent(cmd3, 9998, CallerInfoHelper.Format()(cmd3)));
            }

            if (EventInfoHelper.Check(out var cmd4, format) && !string.IsNullOrWhiteSpace(cmd4))
            {
                yield return(new FormatEvent(cmd4, 9999, EventInfoHelper.Format()(cmd4)));
            }
        }
コード例 #2
0
        /// <summary>
        /// Create command event
        /// </summary>
        /// <param name="format"></param>
        /// <returns></returns>
        public static IEnumerable <FormatEvent> CreateCommandEvent(string format = null)
        {
            if (format == null || string.IsNullOrWhiteSpace(format))
            {
                yield break;
            }

            if (CasingHelper.Check(out var cmd1, format) && (cmd1 == 'U' || cmd1 == 'w'))
            {
                yield return(new FormatEvent(cmd1, 10000, CasingHelper.Format()(cmd1)));
            }

            if (PaddingHelper.Check(out var cmd2, out var width, format) && (cmd2 == 'r' || cmd2 == 'l'))
            {
                yield return(new FormatEvent(cmd2, 10001, PaddingHelper.Format()(cmd2)(width)));
            }

            if (JsonHelper.Check(format))
            {
                yield return(new FormatEvent('j', 99999, JsonHelper.Format));
            }

            foreach (var provider in CustomFormatProviderManager.Get())
            {
                if (provider != null)
                {
                    var additionalFormats = provider.Invoke(format);
                    foreach (var f in additionalFormats)
                    {
                        yield return(f);
                    }
                }
            }
        }
コード例 #3
0
        public static IEnumerable <Func <object, IFormatProvider, object> > CreateCommandFunc(string format = null)
        {
            if (format == null || string.IsNullOrWhiteSpace(format))
            {
                yield break;
            }

            if (CallerInfoHelper.Check(out var cmd3, format) && !string.IsNullOrWhiteSpace(cmd3))
            {
                yield return(CallerInfoHelper.Format()(cmd3));
            }

            if (EventInfoHelper.Check(out var cmd4, format) && !string.IsNullOrWhiteSpace(cmd4))
            {
                yield return(EventInfoHelper.Format()(cmd4));
            }

            if (CasingHelper.Check(out var cmd1, format) && (cmd1 == 'U' || cmd1 == 'w'))
            {
                yield return(CasingHelper.Format()(cmd1));
            }

            if (PaddingHelper.Check(out var cmd2, out var width, format) && (cmd2 == 'r' || cmd2 == 'l'))
            {
                yield return(PaddingHelper.Format()(cmd2)(width));
            }
        }
コード例 #4
0
        /// <summary>
        /// Create command func
        /// </summary>
        /// <param name="format"></param>
        /// <param name="customFormatProvider"></param>
        /// <returns></returns>
        public static IEnumerable <Func <object, IFormatProvider, object> > CreateCommandFunc(
            string format = null,
            Func <string, IEnumerable <Func <object, IFormatProvider, object> > > customFormatProvider = null)
        {
            if (format == null || string.IsNullOrWhiteSpace(format))
            {
                yield break;
            }

            if (CasingHelper.Check(out var cmd1, format) && (cmd1 == 'U' || cmd1 == 'w'))
            {
                yield return(CasingHelper.Format()(cmd1));
            }

            if (PaddingHelper.Check(out var cmd2, out var width, format) && (cmd2 == 'r' || cmd2 == 'l'))
            {
                yield return(PaddingHelper.Format()(cmd2)(width));
            }

            if (JsonHelper.Check(format))
            {
                yield return(JsonHelper.Format);
            }

            if (customFormatProvider != null)
            {
                var additionalFormatFuncs = customFormatProvider.Invoke(format);
                foreach (var f in additionalFormatFuncs)
                {
                    yield return(f);
                }
            }
        }