void SetGlobal(string variableName, Runtime.Object value) { Runtime.Object oldValue = null; _globalVariables.TryGetValue(variableName, out oldValue); ListValue.RetainListOriginsForAssignment(oldValue, value); _globalVariables [variableName] = value; if (variableChangedEvent != null && !value.Equals(oldValue)) { if (batchObservingVariableChanges) { _changedVariables.Add(variableName); } else { variableChangedEvent(variableName, value); } } }
public void SetTemporaryVariable(string name, Runtime.Object value, bool declareNew, int contextIndex = -1) { if (contextIndex == -1) { contextIndex = currentElementIndex + 1; } var contextElement = callStack [contextIndex - 1]; if (!declareNew && !contextElement.temporaryVariables.ContainsKey(name)) { throw new StoryException("Could not find temporary variable to set: " + name); } Runtime.Object oldValue; if (contextElement.temporaryVariables.TryGetValue(name, out oldValue)) { ListValue.RetainListOriginsForAssignment(oldValue, value); } contextElement.temporaryVariables [name] = value; }
public void SetGlobal(string variableName, Runtime.Object value) { Runtime.Object oldValue = null; if (patch == null || !patch.TryGetGlobal(variableName, out oldValue)) { _globalVariables.TryGetValue(variableName, out oldValue); } ListValue.RetainListOriginsForAssignment(oldValue, value); if (patch != null) { patch.SetGlobal(variableName, value); } else { _globalVariables [variableName] = value; } if (variableChangedEvent != null && !value.Equals(oldValue)) { if (batchObservingVariableChanges) { if (patch != null) { patch.AddChangedVariable(variableName); } else if (_changedVariablesForBatchObs != null) { _changedVariablesForBatchObs.Add(variableName); } } else { variableChangedEvent(variableName, value); } } }