public StateReferencingInstanceMember(InstanceSavePropertyDescriptor ispd, StateSave stateSave, string variableName, InstanceSave instanceSave, ElementSave elementSave) : base(variableName, stateSave) { mInstanceSave = instanceSave; mStateSave = stateSave; mVariableName = variableName; mPropertyDescriptor = ispd; mElementSave = elementSave; this.CustomGetEvent += GetEvent; this.CustomSetEvent += SetEvent; this.CustomGetTypeEvent += GetTypeEvent; this.SortValue = int.MaxValue; if (instanceSave != null) { this.Instance = instanceSave; } else { this.Instance = elementSave; } DisplayName = RootVariableName; TryAddExposeVariableMenuOptions(instanceSave); // This could be slow since we have to check it for every variable in an object. // Maybe we'll want to pass this in to the function? StandardElementSave standardElement = null; if (instanceSave != null) { standardElement = ObjectFinder.Self.GetRootStandardElementSave(instanceSave); } else { standardElement = ObjectFinder.Self.GetRootStandardElementSave(elementSave); } VariableSave standardVariable = null; if (standardElement != null) { standardVariable = standardElement.DefaultState.Variables.FirstOrDefault(item => item.Name == RootVariableName); } if (standardVariable != null) { this.SortValue = standardVariable.DesiredOrder; } }
public StateReferencingInstanceMember(InstanceSavePropertyDescriptor ispd, StateSave stateSave, StateSaveCategory stateSaveCategory, string variableName, InstanceSave instanceSave, ElementSave elementSave) : base(variableName, stateSave) { StateSaveCategory = stateSaveCategory; mInstanceSave = instanceSave; mStateSave = stateSave; mVariableName = variableName; mPropertyDescriptor = ispd; mElementSave = elementSave; if (ispd.IsReadOnly) { // don't assign it (can't null it) //this.CustomSetEvent = null; } else { this.CustomSetEvent += HandleCustomSet; } this.CustomGetEvent += HandleCustomGet; this.CustomGetTypeEvent += HandleCustomGetType; this.SortValue = int.MaxValue; if (instanceSave != null) { this.Instance = instanceSave; } else { this.Instance = elementSave; } var alreadyHasSpaces = RootVariableName?.Contains(" "); if (alreadyHasSpaces == false) { DisplayName = ToolsUtilities.StringFunctions.InsertSpacesInCamelCaseString(RootVariableName); } else { DisplayName = RootVariableName; } TryAddExposeVariableMenuOptions(instanceSave); // This could be slow since we have to check it for every variable in an object. // Maybe we'll want to pass this in to the function? StandardElementSave standardElement = null; if (instanceSave != null) { standardElement = ObjectFinder.Self.GetRootStandardElementSave(instanceSave); } else { standardElement = ObjectFinder.Self.GetRootStandardElementSave(elementSave); } VariableSave standardVariable = null; if (standardElement != null) { standardVariable = standardElement.DefaultState.Variables.FirstOrDefault(item => item.Name == RootVariableName); } if (standardVariable != null) { this.SortValue = standardVariable.DesiredOrder; } }