Example #1
0
File: Util.cs Project: shoff/Rant
 public static string Capitalize(string input, Case caps, RantFormatStyle formatStyle, char lastChar, bool article = false)
 {
     if (String.IsNullOrEmpty(input))
     {
         return(input);
     }
     return(Capitalize(input, ref caps, formatStyle, ref lastChar, article));
 }
Example #2
0
 internal Channel(string name, ChannelVisibility visibility, RantFormatStyle formatStyle)
 {
     Name           = name;
     Visiblity      = visibility;
     _currentBuffer = new StringBuilder(InitialBufferSize);
     _buffers       = new List <StringBuilder> {
         _currentBuffer
     };
     _formatStyle = formatStyle;
 }
Example #3
0
        public ChannelStack(RantFormatStyle formatStyle, Limit <int> sizeLimit)
        {
            _sizeLimit = sizeLimit;
            _main      = new Channel("main", ChannelVisibility.Public, formatStyle);

            _stack = new List <Channel> {
                _main
            };
            _stackSize = 1;

            _channels = new Dictionary <string, Channel>
            {
                { "main", _main }
            };
        }
Example #4
0
File: Util.cs Project: shoff/Rant
        public static string Capitalize(string input, ref Case caps, RantFormatStyle formatStyle, ref char lastChar, bool article = false)
        {
            if (String.IsNullOrEmpty(input))
            {
                return(input);
            }
            switch (caps)
            {
            case Case.Lower:
                input = input.ToLower();
                break;

            case Case.Upper:
                input = input.ToUpper();
                break;

            case Case.First:
                input = RegCapsFirst.Replace(input, m => m.Value.ToUpper());
                caps  = Case.None;
                break;

            case Case.Title:
                if ((article || formatStyle.Excludes(input)) && Char.IsWhiteSpace(lastChar))
                {
                    break;
                }

                char lc = lastChar;
                input = RegCapsWord.Replace(input, m => (
                                                lc == '\0' ||
                                                Char.IsSeparator(lc) ||
                                                Char.IsWhiteSpace(lc)) ||
                                            Char.IsPunctuation(lc)
                    ? m.Value.ToUpper() : m.Value);
                break;
            }
            lastChar = input[input.Length - 1];
            return(input);
        }
Example #5
0
        public void PushChannel(string channelName, ChannelVisibility visibility, RantFormatStyle formatStyle)
        {
            Channel ch;

            if (!_channels.TryGetValue(channelName, out ch))
            {
                ch = new Channel(channelName, visibility, formatStyle);
                _channels[channelName] = ch;
            }

            if (channelName == "main")
            {
                return;
            }

            ch.Visiblity = visibility;

            if (_stack.Contains(ch))
            {
                return;
            }
            _stack.Add(ch);
            _stackSize++;
        }