public TradingStrategyForSave(TradingStrategy strategy)
        {
            BindingFlags flags = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] fieldArray = strategy.GetType().GetFields(flags);

            BindingFlags flagsStrategySave = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] StrategySaveFieldArray = this.GetType().GetFields(flagsStrategySave);


            try
            {
                foreach (FieldInfo field in fieldArray)
                {
                    foreach (FieldInfo SaveField in StrategySaveFieldArray)
                    {
                        if (field.Name == SaveField.Name)
                        {
                            SaveField.SetValue(this, field.GetValue(strategy));
                        }
                    }
                }

                foreach (var item in strategy.tradingItemList)
                {
                    tradingSaveItemList.Add(new TradingItemForSave(item, this));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #2
0
        public TradingItemForSave(TradingItem item, TradingStrategyForSave ts)
        {
            this.tsSave = (ts);
            BindingFlags flags = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] fieldArray = item.GetType().GetFields(flags);

            BindingFlags flagsStrategySave = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] ItemSaveFieldArray = this.GetType().GetFields(flagsStrategySave);


            foreach (FieldInfo field in fieldArray)
            {
                foreach (FieldInfo SaveField in ItemSaveFieldArray)
                {
                    if (field.Name == SaveField.Name)
                    {
                        SaveField.SetValue(this, field.GetValue(item));
                    }
                }
            }
        }
Exemple #3
0
        public TrailingPercentageItemForSave(TrailingItem itemTrail, TradingStrategy ts)
        {
            strategySave = new TradingStrategyForSave(ts);

            BindingFlags flags = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] fieldArray = itemTrail.GetType().GetFields(flags);

            BindingFlags flagsStrategySave = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] StrategySaveFieldArray = this.GetType().GetFields(flagsStrategySave);

            foreach (FieldInfo field in fieldArray)
            {
                foreach (FieldInfo SaveField in StrategySaveFieldArray)
                {
                    if (field.Name == SaveField.Name)
                    {
                        SaveField.SetValue(this, field.GetValue(itemTrail));
                    }
                }
            }
        }