Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
        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;
        }