private List <IParameter> BuildParametersList()
        {
            if (model.Parameters == null)
            {
                return(new List <IParameter>());
            }

            return(model.Parameters.Select(p => MetaParameterFactory.Create(p)).ToList());
        }
        public IMetaSource Create(Source source)
        {
            if (source == null)
            {
                return(new MainInstrumentSource());
            }

            switch (source.SourceType)
            {
            case Source.INDICATOR:
            {
                if (source.IndicatorSource == null)
                {
                    var sourceBuilder = new SourceParser(model);
                    if (source.IndicatorSourceId != null)
                    {
                        source.IndicatorSource = sourceBuilder.Parse(source.IndicatorSourceId);
                    }
                    else
                    {
                        source.IndicatorSource = new FormulaItem()
                        {
                            ValueType  = FormulaItem.STREAM,
                            StreamType = FormulaItem.INSTRUMENT
                        };
                    }
                }
                var newSource = new IndicatorSource()
                {
                    Name   = source.Name,
                    Id     = source.Id,
                    Source = Create(source.IndicatorSource)
                };
                if (source.Parameters != null)
                {
                    foreach (var param in source.Parameters)
                    {
                        newSource.Parameters.Add(MetaParameterFactory.Create(param));
                    }
                }
                return(newSource);
            }

            case Source.INSTRUMENT:
            {
                return(new InstrumentSource()
                    {
                        Id = source.Id,
                        PriceType = ParsePriceType(source.PriceType),
                        Timeframe = source.Timeframe
                    });
            }

            default:
                throw new NotImplementedException();
            }
        }
        public static MetaModule Create(Module module)
        {
            var newModule = new MetaModule()
            {
                Name = module.Name
            };

            if (module.Parameters != null)
            {
                foreach (var param in module.Parameters)
                {
                    newModule.Parameters.Add(MetaParameterFactory.Create(param));
                }
            }
            return(newModule);
        }