private static SelectionSpec[] GenerateSelectionSet(IEnumerable <SelectionSpec> selectionSet, IEnumerator <DynamicPropertyFilterSpecGenerator.ManagedObjectDefinition> moListIterator, int reverseCounter)
        {
            List <SelectionSpec> list = (selectionSet != null) ? new List <SelectionSpec>(selectionSet) : new List <SelectionSpec>();

            if (reverseCounter != 1)
            {
                moListIterator.MoveNext();
                TraversalSpec traversalSpec = null;
                using (List <SelectionSpec> .Enumerator enumerator = list.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        TraversalSpec traversalSpec2 = (TraversalSpec)enumerator.Current;
                        if (moListIterator.Current.ObjectType == traversalSpec2.Type && moListIterator.Current.PropertyPath == traversalSpec2.Path)
                        {
                            traversalSpec = traversalSpec2;
                            break;
                        }
                    }
                }
                if (traversalSpec != null)
                {
                    traversalSpec.SelectSet = DynamicPropertyFilterSpecGenerator.GenerateSelectionSet(traversalSpec.SelectSet, moListIterator, --reverseCounter);
                }
                else
                {
                    traversalSpec           = new TraversalSpec();
                    traversalSpec.Type      = DynamicPropertyFilterSpecGenerator.FixTypeName(moListIterator.Current.ObjectType);
                    traversalSpec.Path      = moListIterator.Current.PropertyPath;
                    traversalSpec.Skip      = new bool?(false);
                    traversalSpec.SelectSet = DynamicPropertyFilterSpecGenerator.GenerateSelectionSet(null, moListIterator, --reverseCounter);
                    list.Add(traversalSpec);
                }
                return(list.ToArray());
            }
            if (list.Count != 0)
            {
                return(list.ToArray());
            }
            return(null);
        }
        internal static void Generate(ManagedObjectReference startingObject, string[] propertyPathList, out PropertyFilterSpec resultPropertyFilterSpec, out Dictionary <string, List <string> > currentAllowedPropertyPath)
        {
            resultPropertyFilterSpec = new PropertyFilterSpec();
            ObjectSpec objectSpec = new ObjectSpec();

            resultPropertyFilterSpec.ObjectSet = new ObjectSpec[]
            {
                objectSpec
            };
            objectSpec.Obj                   = startingObject;
            objectSpec.SelectSet             = new SelectionSpec[0];
            resultPropertyFilterSpec.PropSet = new PropertySpec[0];
            currentAllowedPropertyPath       = null;
            if (propertyPathList == null)
            {
                PropertySpec propertySpec = new PropertySpec();
                propertySpec.Type = startingObject.Type;
                propertySpec.All  = new bool?(true);
                resultPropertyFilterSpec.PropSet = new PropertySpec[]
                {
                    propertySpec
                };
                return;
            }
            currentAllowedPropertyPath = new Dictionary <string, List <string> >();
            for (int i = 0; i < propertyPathList.Length; i++)
            {
                DynamicPropertyFilterSpecGenerator.PropertyDefinition[]      array = DynamicPropertyFilterSpecGenerator.ParsePropertyPath(propertyPathList[i]);
                List <DynamicPropertyFilterSpecGenerator.PropertyDefinition> list  = new List <DynamicPropertyFilterSpecGenerator.PropertyDefinition>(array);
                DynamicPropertyFilterSpecGenerator.SetPropertyTypesAndFixCasing(array, startingObject.Type);
                DynamicPropertyFilterSpecGenerator.GenerateAllowedPropertyPath(ref currentAllowedPropertyPath, list.ToArray(), array);
                List <DynamicPropertyFilterSpecGenerator.ManagedObjectDefinition> list2 = DynamicPropertyFilterSpecGenerator.GenerateManagedObjectList(array, startingObject.Type);
                DynamicPropertyFilterSpecGenerator.GeneratePropertySet(ref resultPropertyFilterSpec, list2);
                resultPropertyFilterSpec.ObjectSet[0].SelectSet = DynamicPropertyFilterSpecGenerator.GenerateSelectionSet(resultPropertyFilterSpec.ObjectSet[0].SelectSet, list2.GetEnumerator(), list2.Count);
            }
        }