public ModelProperties Clone() { ModelPropertiesCommon model = new ModelPropertiesCommon(); model.ModelType = modelType; model.Name = name; model.Type = type; foreach (KeyValuePair <string, ModelProperty> kvp in properties) { model.AddProperty(kvp.Key, kvp.Value.Clone()); } foreach (KeyValuePair <string, ModelProperties> kvp in models) { model.AddModel(kvp.Key, kvp.Value.Clone()); } return(model); }
private void HandleModel(ModelPropertiesCommon properties, XmlReader reader, TickZoom.Api.ModelType modelType) { string tagName = reader.Name; properties.ModelType = modelType; properties.Name = reader.GetAttribute("name"); properties.Type = reader.GetAttribute("type"); log.Debug("Handle " + properties.ModelType + " " + reader.GetAttribute("name")); if (reader.IsEmptyElement) { return; } log.Indent(); while (reader.Read()) { // Print out info on node switch (reader.NodeType) { case XmlNodeType.Element: if ("property".Equals(reader.Name)) { string name = reader.GetAttribute("name"); string value = reader.GetAttribute("value"); string start = reader.GetAttribute("start"); string end = reader.GetAttribute("end"); string increment = reader.GetAttribute("increment"); string optimize = reader.GetAttribute("optimize"); if ("true".ToLower().Equals(optimize)) { properties.AddProperty(name, value, start, end, increment, optimize); } else { properties.AddProperty(name, value); } log.Debug("Property " + name + " = " + value); } else if ("strategy".Equals(reader.Name)) { ModelPropertiesCommon newProperties = new ModelPropertiesCommon(); String name = reader.GetAttribute("name"); HandleModel(newProperties, reader, TickZoom.Api.ModelType.Strategy); properties.AddModel(name, newProperties); } else if ("indicator".Equals(reader.Name)) { ModelPropertiesCommon newProperties = new ModelPropertiesCommon(); String name = reader.GetAttribute("name"); HandleModel(newProperties, reader, TickZoom.Api.ModelType.Indicator); properties.AddModel(name, newProperties); } else if ("propertyset".Equals(reader.Name)) { ModelPropertiesCommon newProperties = new ModelPropertiesCommon(); String name = reader.GetAttribute("name"); HandleModel(newProperties, reader, TickZoom.Api.ModelType.Model); properties.AddModel(name, newProperties); } else { Error(reader, "unexpected tag " + reader.Name); } break; case XmlNodeType.EndElement: if (tagName.Equals(reader.Name)) { log.Outdent(); return; } else { Error(reader, "End of " + tagName + " was expected instead of end of " + reader.Name); } break; } } Error(reader, "Unexpected end of file"); return; }