mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-18 08:10:33 +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 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))
|
|
||||||
{
|
|
||||||
return new OrderedDictionary();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//var builder = new DeserializerBuilder();
|
|
||||||
//var deserializer = builder
|
|
||||||
// .WithNamingConvention(new PascalCaseNamingConvention())
|
|
||||||
// .Build();
|
|
||||||
return _Deserializer.Deserialize<OrderedDictionary>(AttributesDictionary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == null)
|
|
||||||
{
|
{
|
||||||
AttributesDictionary = null;
|
AttributesDictionary = null;
|
||||||
}
|
}
|
||||||
|
|
@ -385,10 +387,25 @@ namespace AideDeJeuLib
|
||||||
//var serializer = builder
|
//var serializer = builder
|
||||||
// .WithNamingConvention(new PascalCaseNamingConvention())
|
// .WithNamingConvention(new PascalCaseNamingConvention())
|
||||||
// .Build();
|
// .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
|
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