FlatRedBall.Glue.SaveClasses.StateSaveCategory.GetState C# (CSharp) Метод

GetState() публичный Метод

public GetState ( string stateName ) : StateSave
stateName string
Результат StateSave
        public StateSave GetState(string stateName)
        {
            foreach (StateSave stateSave in States)
            {
                if (stateSave.Name == stateName)
                {
                    return stateSave;
                }
            }
            return null;
        }

Usage Example

        public void ReactToStateSaveCategoryChangedValue(StateSaveCategory stateSaveCategory, string changedMember, object oldValue, IElement element, ref bool updateTreeView)
        {
            if(changedMember == "SharesVariablesWithOtherCategories")
            {

                string oldType;
                string newType;
                if ((bool)oldValue == true)
                {
                    oldType = "VariableState";
                    newType = stateSaveCategory.Name;
                }
                else
                {
                    oldType = stateSaveCategory.Name;
                    newType = "VariableState";
                }

                string whyIsntAllowed = GetWhySharesVariableChangeIsntAllowed(stateSaveCategory, element);

                if (!string.IsNullOrEmpty(whyIsntAllowed))
                {
                    MessageBox.Show(whyIsntAllowed);
                    stateSaveCategory.SharesVariablesWithOtherCategories = false;
                }
                else
                {

                    // See if any variables are using this.  If so, let's change them
                    // We need to see if any variables are already tunneling in to this
                    // new type.  If so, then notify the user that the variable will be removed.
                    // Otherwise, notify the user that the variable type is changing.
                    foreach (CustomVariable customVariable in element.CustomVariables)
                    {
                        if (customVariable.Type == oldType && !string.IsNullOrEmpty(customVariable.DefaultValue as string) &&
                            stateSaveCategory.GetState(customVariable.DefaultValue as string) != null)
                        {
                            // We need to do something here...
                            bool shouldChange = false;

                            #if !UNIT_TESTS
                            var dialogResult = System.Windows.Forms.MessageBox.Show("Change variable " + customVariable.Name + " to be of type " + newType + " ?  Selecting 'No' will introduce compile errors.",
                                "Change variable type?", System.Windows.Forms.MessageBoxButtons.YesNo);
                            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                            {
                                shouldChange = true;
                            }
                            #else
                            shouldChange = true;
                            #endif
                            if (shouldChange)
                            {
                                customVariable.Type = newType;
                            }
                        }
                    }
                }
            }
        }
All Usage Examples Of FlatRedBall.Glue.SaveClasses.StateSaveCategory::GetState