Exemplo n.º 1
0
 public virtual bool Contains(
     T item)
 {
     return(EH.Contains(
                this.items,
                item));
 }
Exemplo n.º 2
0
 public virtual bool Contains(
     T item)
 {
     this.checkItems();
     return(EH.Contains(
                this.items,
                item));
 }
Exemplo n.º 3
0
 public virtual bool Contains(
     V value)
 {
     return(EH.Contains(
                EH.Select(
                    this.items,
                    kvp => kvp.Value),
                value));
 }
Exemplo n.º 4
0
        protected virtual ICollection <string> readKeysInSectionProtected(
            string[] lines,
            SectionHeader targetHeader)
        {
            ICollection <string> keys = new LinkedList <string>();

            if (targetHeader == default)
            {
                return(keys);
            }

            var headers = this.readSectionHeaders(lines);

            if (!EH.Contains(
                    EH.Select(
                        headers,
                        header => header.Name),
                    targetHeader.Name))
            {
                return(keys);
            }

            var lineNumber = targetHeader.LineNumber;
            int lastLineIndex;

            if (EH.Last(
                    EH.Select(
                        headers,
                        header => header.Name)) == targetHeader.Name)
            {
                lastLineIndex = lines.Length - 1;
                goto readKeys;
            }

            var headerCounter = 1;

            foreach (var header in headers)
            {
                if (header.Name == targetHeader.Name)
                {
                    break;
                }

                ++headerCounter;
            }

            var nextHeader = EH.FirstOrDefault(
                EH.Skip(
                    headers, headerCounter));

            lastLineIndex = nextHeader?.LineNumber - 1
                            ?? lines.Length - 1;


readKeys:
            for (var i = lineNumber; i <= lastLineIndex; ++i)
            {
                var indexOfSemicolon = lines[i].IndexOf(';');
                if (indexOfSemicolon == 0)
                {
                    continue;
                }

                var indexOfEquals = lines[i].IndexOf('=');
                if (indexOfEquals < 0)
                {
                    continue;
                }

                if (indexOfSemicolon > -1 &&
                    indexOfSemicolon < indexOfEquals)
                {
                    continue;
                }

                var keyName = lines[i]
                              .Substring(0, indexOfEquals);
                keys.Add(keyName);
            }

            return(keys);
        }