Esempio n. 1
0
        private void ShowPopupsForMissingVariablesInNewType(NamedObjectSave namedObjectSave, object oldValue)
        {
            if (namedObjectSave.SourceType == SourceType.Entity)
            {
                string oldType = (string)oldValue;
                string message = namedObjectSave.GetMessageWhySwitchMightCauseProblems(oldType);

                if (message != null)
                {
                    message += "\nDo you want to change to " + namedObjectSave.SourceClassType + " anyway?";

                    DialogResult result = MessageBox.Show(message, "Change anyway?", MessageBoxButtons.YesNo);

                    if (result == DialogResult.No)
                    {
                        namedObjectSave.SourceClassType = (string)oldValue;
                        namedObjectSave.UpdateCustomProperties();
                    }
                }
            }
        }
        public void TestUpdateNamedObjectProperties()
        {
            mDerivedEntitySave.UpdateFromBaseType();

            // Test to make sure this Entity has inherited the Y variable
            if (mDerivedEntitySave.CustomVariables.Count != 1)
            {
                throw new Exception("Derived Entities are not properly inheriting SetByDerived values");
            }


            mDerivedNos.UpdateCustomProperties();

            int numberOfProperties = mDerivedNos.TypedMembers.Count;

            // It turns out it's okay for NOSs to have null InstructionSaves
            // This makes XML much smaller and makes Glue more efficient in general.
            //if (numberOfProperties == 0)
            //{
            //    throw new Exception("NamedObjectSaves that are not getting their InstructionSaves properly set");
            //}

            if (mDerivedEntitySave.GetTypedMembers().Count != 2)
            {
                throw new Exception("There are an invalid number of typed members for NamedObjectSaves which use Entities that have inheritance");
            }

            // Let's switch the derived NOS to the underived, update its properties, then switch it to the derived and see if there are any problems - there shouldn't be
            mDerivedNos.SourceClassType = mEntitySave.Name;
            mDerivedNos.UpdateCustomProperties();

            mDerivedNos.SourceClassType = mDerivedEntitySave.Name;
            string message = mDerivedNos.GetMessageWhySwitchMightCauseProblems(mEntitySave.Name);

            if (!string.IsNullOrEmpty(message))
            {
                throw new Exception("GetMessageWhySwitchMightCauseProblems is incorrectly reporting problems.  Reported problems:\n" + message);
            }
        }