mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 15:36:07 +00:00 
			
		
		
		
	Correctifs attributes (à revérifier)
This commit is contained in:
		
							parent
							
								
									4234becc93
								
							
						
					
					
						commit
						d326c371ad
					
				
					 3 changed files with 55 additions and 34 deletions
				
			
		|  | @ -354,41 +354,58 @@ namespace AideDeJeuLib | ||||||
|         static IDeserializer _Deserializer = new DeserializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build(); |         static IDeserializer _Deserializer = new DeserializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build(); | ||||||
|         static ISerializer _Serializer = new SerializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build(); |         static ISerializer _Serializer = new SerializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build(); | ||||||
| 
 | 
 | ||||||
|         [NotMapped] |         protected OrderedDictionary Attributes { get; private set; } = new OrderedDictionary(); | ||||||
|         [IgnoreDataMember] |         //[NotMapped] | ||||||
|         public virtual OrderedDictionary Attributes |         //[IgnoreDataMember] | ||||||
|  |         //protected virtual OrderedDictionary Attributes | ||||||
|  |         //{ | ||||||
|  |         //    get | ||||||
|  |         //    { | ||||||
|  |         //        if (string.IsNullOrEmpty(AttributesDictionary)) | ||||||
|  |         //        { | ||||||
|  |         //            return new OrderedDictionary(); | ||||||
|  |         //        } | ||||||
|  |         //        else | ||||||
|  |         //        { | ||||||
|  |         //            //var builder = new DeserializerBuilder(); | ||||||
|  |         //            //var deserializer = builder | ||||||
|  |         //            //    .WithNamingConvention(new PascalCaseNamingConvention()) | ||||||
|  |         //            //    .Build(); | ||||||
|  |         //            return _Deserializer.Deserialize<OrderedDictionary>(AttributesDictionary); | ||||||
|  |         //        } | ||||||
|  |         //    } | ||||||
|  |         //}// = new OrderedDictionary(); | ||||||
|  |         public void SaveAttributes() | ||||||
|         { |         { | ||||||
|             get |             if (Attributes == null) | ||||||
|             { |             { | ||||||
|                 if (string.IsNullOrEmpty(AttributesDictionary)) |                 AttributesDictionary = null; | ||||||
|                 { |  | ||||||
|                     return new OrderedDictionary(); |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     //var builder = new DeserializerBuilder(); |  | ||||||
|                     //var deserializer = builder |  | ||||||
|                     //    .WithNamingConvention(new PascalCaseNamingConvention()) |  | ||||||
|                     //    .Build(); |  | ||||||
|                     return _Deserializer.Deserialize<OrderedDictionary>(AttributesDictionary); |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|             set |             else | ||||||
|             { |             { | ||||||
|                 if (value == null) |                 //var builder = new SerializerBuilder(); | ||||||
|                 { |                 //var serializer = builder | ||||||
|                     AttributesDictionary = null; |                 //    .WithNamingConvention(new PascalCaseNamingConvention()) | ||||||
|                 } |                 //    .Build(); | ||||||
|                 else |                 AttributesDictionary = _Serializer.Serialize(Attributes); | ||||||
|                 { |  | ||||||
|                     //var builder = new SerializerBuilder(); |  | ||||||
|                     //var serializer = builder |  | ||||||
|                     //    .WithNamingConvention(new PascalCaseNamingConvention()) |  | ||||||
|                     //    .Build(); |  | ||||||
|                     AttributesDictionary = _Serializer.Serialize(value); |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|         }// = new OrderedDictionary(); |         } | ||||||
|  |         public void LoadAttributes() | ||||||
|  |         { | ||||||
|  |             Attributes = GetAttributes(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public OrderedDictionary GetAttributes() | ||||||
|  |         { | ||||||
|  |             if (string.IsNullOrEmpty(AttributesDictionary)) | ||||||
|  |             { | ||||||
|  |                 return new OrderedDictionary(); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 return _Deserializer.Deserialize<OrderedDictionary>(AttributesDictionary); | ||||||
|  |             } | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         public virtual OrderedDictionary AttributesKeyValue |         public virtual OrderedDictionary AttributesKeyValue | ||||||
|         { |         { | ||||||
|  | @ -432,6 +449,7 @@ namespace AideDeJeuLib | ||||||
|                 { |                 { | ||||||
|                     this.Attributes.Remove(name); |                     this.Attributes.Remove(name); | ||||||
|                 } |                 } | ||||||
|  |                 SaveAttributes(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         public virtual void SetAttribute(string name, string value) |         public virtual void SetAttribute(string name, string value) | ||||||
|  | @ -451,10 +469,12 @@ namespace AideDeJeuLib | ||||||
|                 { |                 { | ||||||
|                     this.Attributes[name] = value; |                     this.Attributes[name] = value; | ||||||
|                 } |                 } | ||||||
|  |                 SaveAttributes(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         public virtual string GetAttribute(string name) |         public virtual string GetAttribute(string name) | ||||||
|         { |         { | ||||||
|  |             LoadAttributes(); | ||||||
|             if (this.Attributes.Contains(name)) |             if (this.Attributes.Contains(name)) | ||||||
|             { |             { | ||||||
|                 return this.Attributes[name].ToString(); |                 return this.Attributes[name].ToString(); | ||||||
|  |  | ||||||
|  | @ -39,14 +39,14 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|             { |             { | ||||||
|                 if (SubRace == null) |                 if (SubRace == null) | ||||||
|                 { |                 { | ||||||
|                     return Race.Attributes; |                     return Race.GetAttributes(); | ||||||
|                 } |                 } | ||||||
|                 var dico = new OrderedDictionary(); |                 var dico = new OrderedDictionary(); | ||||||
|                 foreach (DictionaryEntry attr in Race.Attributes) |                 foreach (DictionaryEntry attr in Race.GetAttributes()) | ||||||
|                 { |                 { | ||||||
|                     dico[attr.Key] = attr.Value; |                     dico[attr.Key] = attr.Value; | ||||||
|                 } |                 } | ||||||
|                 foreach (DictionaryEntry attr in SubRace.Attributes) |                 foreach (DictionaryEntry attr in SubRace.GetAttributes()) | ||||||
|                 { |                 { | ||||||
|                     dico[attr.Key] = attr.Value; |                     dico[attr.Key] = attr.Value; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  | @ -475,7 +475,8 @@ namespace AideDeJeu.ViewModels | ||||||
|                         } |                         } | ||||||
|                         else |                         else | ||||||
|                         { |                         { | ||||||
|                             item.Attributes[attribute.Key] = attribute.Value; |                             item.SetAttribute(attribute.Key, attribute.Value); | ||||||
|  |                             //item.Attributes[attribute.Key] = attribute.Value; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     return item; |                     return item; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez