public object[] Get(object content) { var type = content.GetType(); if (!CachedKeys.ContainsKey(type)) { var context = ContextProvider.GetFor(type); CachedKeys[type] = context.Context.Model.FindEntityType(type).FindPrimaryKey().Properties.Select(p => p.PropertyInfo).ToList().AsReadOnly(); } return(CachedKeys[type].Select(p => p.GetValue(content)).ToArray()); }
public void Set(IEnumerable <object> keyValues, object content) { var type = content.GetType(); if (!CachedKeys.ContainsKey(type)) { var context = ContextProvider.GetFor(content.GetType()); CachedKeys[type] = context.Context.Model.FindEntityType(content.GetType()).FindPrimaryKey().Properties.Select(p => p.PropertyInfo).ToList().AsReadOnly(); } for (var i = 0; i < CachedKeys[type].Count(); i++) { CachedKeys[type].ElementAt(i).SetValue(content, keyValues.ElementAt(i)); } }
public void Initialize() { if (!CachedKeys.Any()) { var allKeys = Enum.GetValues(typeof(Keys)); foreach (var key in allKeys) { var name = Enum.GetName(typeof(Keys), key); //hardcode begin if (CachedKeys.ContainsKey(name)) { name = name + " (2)"; } if (CachedKeys.ContainsKey(name)) { name = name.Replace("(2)", "(3)"); } if (CachedKeys.ContainsKey(name)) { name = name.Replace("(3)", "(4)"); } if (CachedKeys.ContainsKey(name)) { name = name.Replace("(4)", "(5)"); } if (CachedKeys.ContainsKey(name)) { name = name.Replace("(5)", "(6)"); } //hardcode end CachedKeys.Add(name, (Keys)key); } } var valueType = new StateValueType(); valueType.AcceptedValues = CachedKeys.Select(x => x.Key).ToArray(); this.ValueType = valueType; }