private void HandleProject(XmlReader reader)
        {
            log.Debug("Handle Starter properties");
            log.Indent();
            while (reader.Read())
            {
                // Print out info on node
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if ("property".Equals(reader.Name))
                    {
                        HandleProperty(this, reader.GetAttribute("name"), reader.GetAttribute("value"));
                    }
                    else if ("propertyset".Equals(reader.Name))
                    {
                        string name = reader.GetAttribute("name");
                        if ("starter".Equals(name))
                        {
                            HandleObject(Starter, reader);
                        }
                        else if ("chart".Equals(name))
                        {
                            HandleObject(Chart, reader);
                        }
                        else if ("data".Equals(name))
                        {
                            HandleObject(Starter.SymbolProperties, reader);
                        }
                        else if ("engine".Equals(name))
                        {
                            HandleObject(Engine, reader);
                        }
                    }
                    if ("strategy".Equals(reader.Name))
                    {
                        ModelPropertiesCommon properties = new ModelPropertiesCommon();
                        HandleModel(properties, reader, TickZoom.Api.ModelType.Strategy);
                        Model = properties;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if ("projectproperties".Equals(reader.Name))
                    {
                        log.Outdent();
                        return;
                    }
                    else
                    {
                        Error(reader, "End of " + reader.Name + " tag in xml was unexpected");
                    }
                    break;
                }
            }
            Error(reader, "End of file unexpected");
        }
Ejemplo n.º 2
0
        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;
        }