Exemple #1
0
        public RedditQueryResult(IRedditApiSearchAgent provider, T query, params K[] values)
        {
            _searchAgent = provider ?? throw new ArgumentNullException(nameof(provider));
            Query        = query ?? throw new ArgumentNullException(nameof(query));

            HasValue = (values != null && values.Length > 0);
            ValueList.AddRange(values);
        }
Exemple #2
0
        // GetValues
        // Routine Description:
        //     This method takes a header name and returns a string array representing
        //     the individual values for that headers. For example, if the headers
        //     contained the line Accept: text/plain, text/html then
        //     GetValues("Accept") would return an array of two strings: "text/plain"
        //     and "text/html".
        // Arguments:
        //     header      - Name of the header.
        // Return Value:
        //     string[] - array of parsed string objects

        /// <devdoc>
        ///    <para>
        ///       Gets an array of header values stored in a
        ///       header.
        ///    </para>
        /// </devdoc>
        public override string[] GetValues(string header)
        {
            // First get the information about the header and the values for
            // the header.
            HeaderInfo Info = s_headerInfos[header];

            string[] Values = InnerCollection.GetValues(header);
            // If we have no information about the header or it doesn't allow
            // multiple values, just return the values.
            if (Info == null || Values == null || !Info.AllowMultiValues)
            {
                return(Values);
            }
            // Here we have a multi value header. We need to go through
            // each entry in the multi values array, and if an entry itself
            // has multiple values we'll need to combine those in.
            //
            // We do some optimazation here, where we try not to copy the
            // values unless there really is one that have multiple values.
            string[]  TempValues;
            ArrayList ValueList = null;
            int       i;

            for (i = 0; i < Values.Length; i++)
            {
                // Parse this value header.
                TempValues = Info.Parser(Values[i]);
                // If we don't have an array list yet, see if this
                // value has multiple values.
                if (ValueList == null)
                {
                    // See if it has multiple values.
                    if (TempValues.Length > 1)
                    {
                        // It does, so we need to create an array list that
                        // represents the Values, then trim out this one and
                        // the ones after it that haven't been parsed yet.
                        ValueList = new ArrayList(Values);
                        ValueList.RemoveRange(i, Values.Length - i);
                        ValueList.AddRange(TempValues);
                    }
                }
                else
                {
                    // We already have an ArrayList, so just add the values.
                    ValueList.AddRange(TempValues);
                }
            }
            // See if we have an ArrayList. If we don't, just return the values.
            // Otherwise convert the ArrayList to a string array and return that.
            if (ValueList != null)
            {
                string[] ReturnArray = new string[ValueList.Count];
                ValueList.CopyTo(ReturnArray);
                return(ReturnArray);
            }
            return(Values);
        }
Exemple #3
0
        public AggregateBucket(params Bucket[] items)
        {
            if (items is null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            _buckets  = new();
            _nDispose = 1;
            _buckets.AddRange(items);
        }
Exemple #4
0
                public override ValueList <string> /*!*/ Flatten()
                {
                    var result = new ValueList <string>();

                    foreach (var node in _nodes)
                    {
                        result.AddRange(node.Flatten());
                    }

                    return(result);
                }
Exemple #5
0
        public int OverWriteValueMembers(string values)
        {
            int valueDifference = Value.Length - values.Length;

            Value = values;
            ValueList.Clear();
            ValueList.AddRange(values);
            ValueSet.Clear();
            ValueSet.UnionWith(values);

            return(valueDifference);
        }
        public void ValueListTest()
        {
            var list = new ValueList <int>();

            for (int i = 0; i < 10; i++)
            {
                list.AddRange(new[] { 0, 1, 2, 3 });
                list.Add(4);
                list.Insert(list.Count, 5);
            }

            list.Insert(0, -1);
            list.Insert(1, 1);
        }
Exemple #7
0
        public int OverWriteValueMembers(List <char> values)
        {
            int valueDifference = ValueList.Count - values.Count;

            StringBuilder sb = new StringBuilder();

            foreach (var c in values)
            {
                sb.Append(c.ToString());
            }

            Value = sb.ToString();
            ValueList.Clear();
            ValueList.AddRange(values);
            ValueSet.Clear();
            ValueSet.UnionWith(values);

            return(valueDifference);
        }