public void LoadFrom(VariableSet variables, string tag) { foreach (Variable fromVariable in variables._variables) { var index = _schema != null?_schema.GetIndex(fromVariable.Name) : -1; if (index >= 0) { if (tag == null || _schema[index].Definition.Tag == tag) { SetValue(index, fromVariable.Value); } } } }
public void SaveTo(VariableSet variables, string tag) { foreach (Variable fromVariable in _variables) { var index = _schema != null?_schema.GetIndex(fromVariable.Name) : -1; if (index >= 0) { if (tag == null || _schema[index].Definition.Tag == tag) { variables._variables.Add(fromVariable); } } } variables._version = _version; }
public void Setup(object owner, VariableSchema schema, VariableSet variables) { var mapping = GetMapping(owner.GetType(), schema); var listCount = mapping.Properties.Count; if (schema != null && variables != null) { listCount++; } var lists = new IMappedVariableList[listCount]; for (var i = 0; i < mapping.Properties.Count; i++) { lists[i] = new PropertyList(owner, mapping.Properties[i]); } // variable initializers may need the map set to access other variables _map = mapping.Map; _lists = lists; if (variables != null) { if (schema != null) { if (owner is IVariableListener listener) { lists[listCount - 1] = new VariableListener(listener, variables); } else { lists[listCount - 1] = variables; } variables.Setup(schema, owner as IVariableStore); } else { variables.Clear(); } } }