Esempio n. 1
0
        static void GetAllCombinations(Swap us, string[] fields, RateInfo[] rateInfos)
        {
            var    listToBeChanged = GetOriginalRateInfos(us);
            double count           = Math.Pow(2, listToBeChanged.Count);

            for (int i = 1; i <= count - 1; i++)
            {
                string str = Convert.ToString(i, 2).PadLeft(listToBeChanged.Count, '0');
                for (int j = 0; j < str.Length; j++)
                {
                    if (str[j] == '1')
                    {
                        SetFieldValue(fields[j], us, rateInfos[j]);
                        listToBeChanged[j] = rateInfos[j];
                    }
                }

                using (us.GetContext(State.Default))
                {
                    SetToDefault(us);
                }

                listToBeChanged = GetOriginalRateInfos(us);
                Console.WriteLine();
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string[]   FieldsConst = new string[] { FIELD1, FIELD2, FIELD3, FIELD4, FIELD5, FIELD6, FIELD7, FIELD8, FIELD9 };
            RateInfo[] newRates    = new RateInfo[]
            {
                new RateInfo {
                    Value = 1
                },
                new RateInfo {
                    Value = 2
                },
                new RateInfo {
                    Value = 3
                },
                new RateInfo {
                    Value = 4
                },
                new RateInfo {
                    Value = 5
                },
                new RateInfo {
                    Value = 6
                },
                new RateInfo {
                    Value = 7
                },
                new RateInfo {
                    Value = 8
                },
                new RateInfo {
                    Value = 9
                }
            };

            Swap                    us           = new Swap();
            SetPropertyValue        setSwapValue = new SetPropertyValue(SetFieldValue);
            GetPropertyValue <Swap> getSwapValue = new GetPropertyValue <Swap>(GetFieldValue);

            using (us.GetContext(State.Default))
            {
                SetToDefault(us);
            }

            List <RateInfo> rateInfos = GetOriginalRateInfos(us);
            List <Dictionary <FieldName, RateInfo> > productsCombination = new List <Dictionary <FieldName, RateInfo> >();

            GetCombination(us, rateInfos, ref productsCombination);

            foreach (var combination in productsCombination)
            {
                foreach (var item in combination)
                {
                    Console.Write($"{item.Key} " + $"{item.Value.Value}, ");
                }
                Console.WriteLine();
            }

            // Myślę że trzeba tu tylko jeszcze wrzucić wartości do jakichś słowników i będzie to co trzeba.
            // Tylko
            GetAllCombinations(us, FieldsConst, newRates);
        }