コード例 #1
0
        public static void InitializeDefaultAndComponentVariables(this ComponentSave componentSave)
        {
            // June 27, 2012
            // We used to pass
            // null here because
            // passing a non-null
            // variable meant replacing
            // the existing StateSave with
            // the argument StateSave.  However,
            // now when the type of a Component is
            // changed, old values are not removed, but
            // are rather preserved so that changing the
            // type doesn't wipe out old values.
            //componentSave.Initialize(null);

            StateSave defaultStateSave = null;

            // We used to call initialize with the default state for the given component base type (which is usually a container)
            // But this copies all the variables from the container to this, which seems redundant...why do we do this if it inherits
            // from a container which has its own state? Most of the time the user won't change the defaults and it just adds bloat.
            //StandardElementSave ses = ObjectFinder.Self.GetRootStandardElementSave(componentSave);
            //if (ses != null)
            //{
            //    defaultStateSave = ses.DefaultState;
            //}

            componentSave.Initialize(new StateSave {
                Name = "Default"
            });

            componentSave.Initialize(StandardElementsManager.Self.DefaultStates["Component"]);
        }
コード例 #2
0
        public static void InitializeDefaultAndComponentVariables(this ComponentSave componentSave)
        {
            // June 27, 2012
            // We used to pass
            // null here because
            // passing a non-null
            // variable meant replacing
            // the existing StateSave with
            // the argument StateSave.  However,
            // now when the type of a Component is
            // changed, old values are not removed, but
            // are rather preserved so that changing the
            // type doesn't wipe out old values.
            //componentSave.Initialize(null);

            StateSave           defaultStateSave = null;
            StandardElementSave ses = ObjectFinder.Self.GetRootStandardElementSave(componentSave);

            if (ses != null)
            {
                defaultStateSave = ses.DefaultState;
            }

            componentSave.Initialize(defaultStateSave);

            componentSave.Initialize(StandardElementsManager.Self.DefaultStates["Component"]);
        }