Esempio n. 1
0
        private static void CombineInstanceCounts(Index combineTo, Index combineFrom)
        {
            foreach (InstanceCount instanceToAdd in combineFrom.InstanceCounts)
            {
                InstanceCount instanceToUpdate =
                    combineTo.InstanceCounts.Where(
                        i => InstanceCountExtensions.InstanceCountEqualById(instanceToAdd, i))
                    .SingleOrDefault();

                if (instanceToUpdate != null)
                {
                    combineTo.InstanceCounts.Remove(instanceToUpdate);
                }

                combineTo.InstanceCounts.Add(instanceToAdd);
            }
        }
Esempio n. 2
0
        public static void AddFieldIndices(
            this List <Index> indices,
            AnonymousObject anon,
            string fieldName,
            string fieldValueString)
        {
            string[] fieldValues = fieldValueString.ParseField();

            IDictionary <string, int> fieldValueCounts = AggregateFieldValueCounts(fieldValues);

            foreach (string fieldValue in fieldValueCounts.Keys)
            {
                Index newIndexToAdd = IndexExtensions.CreateNewIndex(fieldName, fieldValue);

                fieldValueCounts.TryGetValue(fieldValue, out int fieldValueCount);
                newIndexToAdd.InstanceCounts.Add(
                    InstanceCountExtensions.CreateInstanceCount(newIndexToAdd, anon, fieldValueCount));

                indices.Add(newIndexToAdd);
            }
        }