private T GetPlayerAttributeValue <T>(PlayerAccountAttributeType attributeType) { var attribute = _playerData.Attributes.FirstOrDefault(a => a.AttributeType == attributeType); if (attribute == null) { return(default(T)); } var converter = TypeDescriptor.GetConverter(typeof(T)); return((T)converter.ConvertFromInvariantString(attribute.Value)); }
private void SetpLayerAttributeValue(PlayerAccountAttributeType attributeType, object value, PlayerData playerData) { var attribute = playerData.Attributes.FirstOrDefault(a => a.AttributeType == attributeType); if (attribute == null) { attribute = new PlayerAccountAttribute(); attribute.AttributeType = attributeType; playerData.Attributes = playerData.Attributes.Concat(new PlayerAccountAttribute[] { attribute }).ToArray(); } if (value != null) { attribute.Value = value.ToString(); } else { attribute.Value = ""; } }
private void SetPlayerAttributeValue(PlayerAccountAttributeType attributeType, object value, [CallerMemberName] string propertyName = null) { SetPlayerAttributes(new PlayerAccountAttribute[] { new PlayerAccountAttribute(attributeType, value) }, new string[] { propertyName }); }
private DateTime?GetDateAttributeValue(PlayerAccountAttributeType attributeType) { return(DateTimeValueEditor.TryParse(GetPlayerAttributeValue <string>(attributeType), new DateTimeValueEditor()).Value); }
public PlayerAccountAttribute(PlayerAccountAttributeType type, object value) { AttributeType = type; Value = value?.ToString() ?? ""; }