mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +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,28 +354,30 @@ namespace AideDeJeuLib
|
|||
static IDeserializer _Deserializer = new DeserializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build();
|
||||
static ISerializer _Serializer = new SerializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build();
|
||||
|
||||
[NotMapped]
|
||||
[IgnoreDataMember]
|
||||
public virtual OrderedDictionary Attributes
|
||||
protected OrderedDictionary Attributes { get; private set; } = new OrderedDictionary();
|
||||
//[NotMapped]
|
||||
//[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 (string.IsNullOrEmpty(AttributesDictionary))
|
||||
{
|
||||
return new OrderedDictionary();
|
||||
}
|
||||
else
|
||||
{
|
||||
//var builder = new DeserializerBuilder();
|
||||
//var deserializer = builder
|
||||
// .WithNamingConvention(new PascalCaseNamingConvention())
|
||||
// .Build();
|
||||
return _Deserializer.Deserialize<OrderedDictionary>(AttributesDictionary);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
if (Attributes == null)
|
||||
{
|
||||
AttributesDictionary = null;
|
||||
}
|
||||
|
|
@ -385,10 +387,25 @@ namespace AideDeJeuLib
|
|||
//var serializer = builder
|
||||
// .WithNamingConvention(new PascalCaseNamingConvention())
|
||||
// .Build();
|
||||
AttributesDictionary = _Serializer.Serialize(value);
|
||||
AttributesDictionary = _Serializer.Serialize(Attributes);
|
||||
}
|
||||
}
|
||||
public void LoadAttributes()
|
||||
{
|
||||
Attributes = GetAttributes();
|
||||
}
|
||||
|
||||
public OrderedDictionary GetAttributes()
|
||||
{
|
||||
if (string.IsNullOrEmpty(AttributesDictionary))
|
||||
{
|
||||
return new OrderedDictionary();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _Deserializer.Deserialize<OrderedDictionary>(AttributesDictionary);
|
||||
}
|
||||
}
|
||||
}// = new OrderedDictionary();
|
||||
|
||||
public virtual OrderedDictionary AttributesKeyValue
|
||||
{
|
||||
|
|
@ -432,6 +449,7 @@ namespace AideDeJeuLib
|
|||
{
|
||||
this.Attributes.Remove(name);
|
||||
}
|
||||
SaveAttributes();
|
||||
}
|
||||
}
|
||||
public virtual void SetAttribute(string name, string value)
|
||||
|
|
@ -451,10 +469,12 @@ namespace AideDeJeuLib
|
|||
{
|
||||
this.Attributes[name] = value;
|
||||
}
|
||||
SaveAttributes();
|
||||
}
|
||||
}
|
||||
public virtual string GetAttribute(string name)
|
||||
{
|
||||
LoadAttributes();
|
||||
if (this.Attributes.Contains(name))
|
||||
{
|
||||
return this.Attributes[name].ToString();
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
|||
{
|
||||
if (SubRace == null)
|
||||
{
|
||||
return Race.Attributes;
|
||||
return Race.GetAttributes();
|
||||
}
|
||||
var dico = new OrderedDictionary();
|
||||
foreach (DictionaryEntry attr in Race.Attributes)
|
||||
foreach (DictionaryEntry attr in Race.GetAttributes())
|
||||
{
|
||||
dico[attr.Key] = attr.Value;
|
||||
}
|
||||
foreach (DictionaryEntry attr in SubRace.Attributes)
|
||||
foreach (DictionaryEntry attr in SubRace.GetAttributes())
|
||||
{
|
||||
dico[attr.Key] = attr.Value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -475,7 +475,8 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
item.Attributes[attribute.Key] = attribute.Value;
|
||||
item.SetAttribute(attribute.Key, attribute.Value);
|
||||
//item.Attributes[attribute.Key] = attribute.Value;
|
||||
}
|
||||
}
|
||||
return item;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue