Example #1
0
 public static IDictionary<string, object> Copy(this IDictionary<string, object> context)
 {
     var result = new Dictionary<string, object>();
     foreach (var key in context)
     {
         result.Set(key.Key, key.Value);
     }
     return result;
 }
Example #2
0
        public object Execute(IDictionary<string, object> context, params object[] parameters)
        {
            var result = new Dictionary<string, object>();

            for (var i = 0; i < parameters.Length; i += 2)
            {
                result.Set((parameters[i] as Variable).Name, parameters[i + 1].Evaluate(context));
            }

            return result;
        }
        public static Dictionary<string, string> GetParams(object obj)
        {
            var dic = new Dictionary<string, string>();
            var props = obj.GetType().GetProperties().Where(p => p.GetCustomAttributes(typeof(ParamAttribute), true).Length > 0);
            foreach (var p in props) {
                var pa = (ParamAttribute)p.GetCustomAttributes(typeof(ParamAttribute), true).First();
                var pms = pa.GetParams(obj, p);
                if (pms != null) {
                    foreach (var pm in pms) {
                        dic.Set(pm.Key, pm.Value);
                    }
                }
            }

            return dic;
        }
Example #4
0
        /// <summary>
        /// Metoda napelniajaca klase AlreadySetLetters literami znajdujacymi sie na planszy.
        /// </summary>
        /// <param name="ASL"></param>
        /// <param name="ConsideredContainer"></param>
        /// <param name="FirstIndex"></param>
        public void FillAlreadySetLetters(Dictionary.Dictionary.AlreadySetLetters ASL, Container ConsideredContainer, int FirstIndex)
        {
            int LettersLeft = Configuration.MaxLetterNumber;

            for(int i = 0; LettersLeft != 0; ++i)
            {
                Cell TempCell = ConsideredContainer.Get(FirstIndex + i);

                if(TempCell == null)
                {
                    return;
                }

                if(TempCell.IsVisited())
                {
                    ASL.Set(i, TempCell.GetTile().GetLetter());
                }
                else
                {
                    --LettersLeft;
                }
            }
        }
 public void SetTest()
 {
     var initialDict = new Dictionary<string, int>
         {
             {"a", 0},
             {"b", 0},
             {"c", 0}
         };
     var newDict = new Dictionary<string, int>
         {
             {"a", 2},
             {"b", 3},
             {"c", 4}
         };
     initialDict.Set(newDict);
     initialDict["a"].ShouldEqual(2);
     initialDict["b"].ShouldEqual(3);
     initialDict["c"].ShouldEqual(4);
 }