public bool IsExposedVariableNameValid(string variableName, ElementSave elementSave, out string whyNotValid) { whyNotValid = null; IsNameValidCommon(variableName, out whyNotValid); if (string.IsNullOrEmpty(whyNotValid)) { IsNameAlreadyUsed(variableName, null, elementSave, out whyNotValid); } if (string.IsNullOrEmpty(whyNotValid)) { var existingVariable = elementSave.GetVariableFromThisOrBase(variableName); // there's a variable but we shouldn't consider it // unless it's "Active" - inactive variables may be // leftovers from a type change if (existingVariable != null) { var isActive = VariableSaveLogic.GetIfVariableIsActive(existingVariable, elementSave, null); if (isActive) { whyNotValid = $"The variable name {variableName} is already used"; } } } return(string.IsNullOrEmpty(whyNotValid)); }
private void DisplayCurrentInstance(List <InstanceSavePropertyDescriptor> pdc, InstanceSave instanceSave) { ElementSave elementSave = instanceSave.GetBaseElementSave(); StateSave stateToDisplay; if (elementSave != null) { if (elementSave is StandardElementSave) { // if we use the standard elements manager, we don't get any custom categories, so we need to add those: stateToDisplay = StandardElementsManager.Self.GetDefaultStateFor(elementSave.Name).Clone(); foreach (var category in elementSave.Categories) { var expectedName = category.Name + "State"; var variable = elementSave.GetVariableFromThisOrBase(expectedName); if (variable != null) { stateToDisplay.Variables.Add(variable); } } } else { stateToDisplay = GetRecursiveStateFor(elementSave); } } else { stateToDisplay = new StateSave(); } DisplayCurrentElement(pdc, elementSave, instanceSave, stateToDisplay, instanceSave.Name, AmountToDisplay.ElementAndExposedOnly); }
public void SetValue(object selectedItem, object value) { ElementSave elementSave = null; StateSave stateSave = SelectedState.Self.SelectedStateSave; //InstanceSave instanceSave = SelectedState.Self.SelectedInstance; var instanceSave = selectedItem as InstanceSave; if (instanceSave != null) { elementSave = instanceSave.ParentContainer; } else // instance is null, so assign the element { elementSave = selectedItem as ElementSave; } //////////////// Early Out///////////// if (stateSave == null || elementSave == null) { return; } ///////////////End Early Out/////////// string name = GetVariableNameConsideringSelection(instanceSave); // <None> is a reserved // value for when we want // to allow the user to reset // a value through a combo box. // If the value is "<None>" then // let's set it to null if (value is string && ((string)value) == "<None>") { value = null; } string variableType = null; var existingVariable = elementSave.GetVariableFromThisOrBase(name); if (existingVariable != null) { variableType = existingVariable.Type; } stateSave.SetValue(name, value, instanceSave, variableType); }
public override void SetValue(object component, object value) { ElementSave elementSave = SelectedState.Self.SelectedElement; StateSave stateSave = SelectedState.Self.SelectedStateSave; InstanceSave instanceSave = SelectedState.Self.SelectedInstance; //////////////// Early Out///////////// if (stateSave == null) { return; } ///////////////End Early Out/////////// string name = GetVariableNameConsideringSelection(); // <None> is a reserved // value for when we want // to allow the user to reset // a value through a combo box. // If the value is "<None>" then // let's set it to null if (value is string && ((string)value) == "<None>") { value = null; } string variableType = null; var existingVariable = elementSave.GetVariableFromThisOrBase(name); if (existingVariable != null) { variableType = existingVariable.Type; } stateSave.SetValue(name, value, instanceSave, variableType); }
private Type GetTypeFromVariableRecursively() { VariableSave variableSave = null; if (mInstanceSave != null) { variableSave = mInstanceSave.GetVariableFromThisOrBase( new ElementWithState(mInstanceSave.ParentContainer), RootVariableName); } else { variableSave = mElementSave.GetVariableFromThisOrBase( RootVariableName); } if (variableSave?.Type != null) { return(TypeManager.Self.GetTypeFromString(variableSave.Type)); } else { return(typeof(string)); } }