FlatRedBall.Glue.GuiDisplay.AvailableStates.FillPossibleStatesFor C# (CSharp) Method

FillPossibleStatesFor() private static method

private static FillPossibleStatesFor ( List listToFill, IElement currentElement, CustomVariable customVariable ) : CustomVariable
listToFill List
currentElement IElement
customVariable FlatRedBall.Glue.SaveClasses.CustomVariable
return FlatRedBall.Glue.SaveClasses.CustomVariable
        private static CustomVariable FillPossibleStatesFor(List<string> listToFill, IElement currentElement, CustomVariable customVariable)
        {

            IElement sourceElement = null;

            customVariable = customVariable.GetDefiningCustomVariable();

            if (!string.IsNullOrEmpty(customVariable.SourceObject))
            {
                NamedObjectSave namedObjectSave = currentElement.GetNamedObjectRecursively(customVariable.SourceObject);

                sourceElement = ObjectFinder.Self.GetEntitySave(namedObjectSave.SourceClassType);
                if (sourceElement == null)
                {
                    sourceElement = ObjectFinder.Self.GetScreenSave(namedObjectSave.SourceClassType);
                }
            }
            else
            {
                sourceElement = currentElement;
            }


            IEnumerable<StateSave> whatToLoopThrough = null;

            if (customVariable != null)
            {
                StateSaveCategory category = sourceElement.GetStateCategoryRecursively(customVariable.Type);

                if (category != null)
                {
                    whatToLoopThrough = category.States;
                }
            }

            listToFill.Add("<NONE>");

            if (whatToLoopThrough == null)
            {
                foreach (StateSave state in sourceElement.GetUncategorizedStatesRecursively())
                {
                    listToFill.Add(state.Name);

                }
                foreach (StateSaveCategory ssc in sourceElement.StateCategoryList)
                {
                    if (ssc.SharesVariablesWithOtherCategories == true)
                    {
                        foreach (StateSave stateInCategory in ssc.States)
                        {
                            listToFill.Add(stateInCategory.Name);

                        }
                    }
                }

            }
            else
            {
                // We are looping through a category
                foreach (StateSave stateSave in whatToLoopThrough)
                {
                    listToFill.Add(stateSave.Name);
                }
            }
            return customVariable;
        }

Same methods

AvailableStates::FillPossibleStatesFor ( List listToFill, string selectedItemName, NamedObjectSave currentNamedObject ) : void