Beispiel #1
0
        public override Object ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
        {
            if (typeof(String).Equals(reader.ValueType))
            {
                switch ((String)reader.Value)
                {
                case "none":
                case "empty":
                    return(new SkillMap());
                }
                throw new ArgumentOutOfRangeException();
            }
            else
            {
                var json       = JObject.Load(reader);
                var dictionary = new Dictionary <String, Dictionary <String, Int32> >();
                var map        = new SkillMap();
                serializer.Populate(json.CreateReader(), dictionary);

                foreach (var entry in dictionary)
                {
                    if (map.Contains(entry.Key))
                    {
                        throw new ArgumentException();
                    }
                    var e = EnumArray <BattleSkill, Int32> .Parse(entry.Value);

                    map.Add(entry.Key, e);
                }

                return(map);
            }
            throw new NotSupportedException();
        }
Beispiel #2
0
 public EnumArrayItem(EnumArray <TEnum, TValue> collection, Int32 position)
 {
     if (collection.IsNull())
     {
         throw new ArgumentNullException(nameof(collection));
     }
     this.collection = collection;
     this.position   = position;
 }
Beispiel #3
0
 public EnumArray <BattleSkill, Int32> this[String key]
 {
     get
     {
         var skills = default(EnumArray <BattleSkill, Int32>);
         if (this.TryGetValue(key, out skills))
         {
             return(skills);
         }
         // Create new entry.
         skills = new EnumArray <BattleSkill, Int32>();
         this.Add(key, skills);
         return(skills);
     }
 }
Beispiel #4
0
 public void Add(String key, EnumArray <BattleSkill, Int32> skills)
 {
     this.map.Add(key, skills);
     this.CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
     skills.CollectionChanged += (s, e) => this.CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
 }
Beispiel #5
0
 public Boolean TryGetValue(String key, out EnumArray <BattleSkill, Int32> skills) => this.map.TryGetValue(key, out skills);