public TResult Map <TItem>(TItem[] collection, Expression <Func <TItem, object> > keyExpression, Expression <Func <TItem, object> > valueExpression, TResult result)
 {
     foreach (TItem item in collection)
     {
         object key = item.GetPropertyValue(keyExpression);
         if (_mappingDictionary.ContainsKey((object)key))
         {
             object value = item.GetPropertyValue(valueExpression);
             Expression <Func <TResult, object> > mapping = _mappingDictionary[key];
             result.SetPropertyValue(mapping, value);
         }
     }
     return(result);
 }
示例#2
0
 public void setExpression(string expressionName)
 {
     if ((expressions.ContainsKey(expressionName)))
     {
         expressionSprite.sprite = expressions[expressionName];
     }
     else
     {
         Debug.LogError("Unknown Expression " + expressionName);
     }
 }
 public TResult Map <TKey, TValue>(Dictionary <TKey, TValue> dictionary, TResult result)
 {
     Dictionary <TKey, TValue> .KeyCollection keys = dictionary.Keys;
     foreach (TKey key in keys)
     {
         if (_mappingDictionary.ContainsKey(key))
         {
             TValue value = dictionary[key];
             Expression <Func <TResult, object> > mapping = _mappingDictionary[key];
             result.SetPropertyValue(mapping, value);
         }
     }
     return(result);
 }
        public TResult Map(ulong number, TResult result)
        {
            ulong remain = number;
            int   digit  = 0;

            while (remain > 0)
            {
                ulong mod = remain % 2;
                if (mod == 1 && _mappingDictionary.ContainsKey(digit))
                {
                    Expression <Func <TResult, bool> > mapping = _mappingDictionary[digit];
                    result.SetPropertyValue(mapping, true);
                }
                remain /= 2;
                digit  += 1;
            }
            return(result);
        }