コード例 #1
0
        public static SetPropertyValue <T> CreateSetPropertyValueDelegate <TSource, T>(this PropertyInfo propertyInfo, TSource obj)
        {
            string propertyName         = propertyInfo.Name;
            string key                  = string.Format("Delegate-SetProperty-{0}-{1}", typeof(TSource).FullName, propertyName);
            SetPropertyValue <T> result = (SetPropertyValue <T>)myDelegateCache.GetOrAdd(
                key,
                newkey =>
            {
                return(Delegate.CreateDelegate(typeof(SetPropertyValue <T>), obj, propertyInfo.GetSetMethod()));
            });

            return(result);
        }
コード例 #2
0
 public void AddAction(SetPropertyValue dataLoadAction)
 {
     dataLoadActions.Add(dataLoadAction);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Kziembic/Swap
        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);
        }