Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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 = "";
            }
        }
Ejemplo n.º 3
0
 private void SetPlayerAttributeValue(PlayerAccountAttributeType attributeType, object value, [CallerMemberName] string propertyName = null)
 {
     SetPlayerAttributes(new PlayerAccountAttribute[] { new PlayerAccountAttribute(attributeType, value) }, new string[] { propertyName });
 }
Ejemplo n.º 4
0
 private DateTime?GetDateAttributeValue(PlayerAccountAttributeType attributeType)
 {
     return(DateTimeValueEditor.TryParse(GetPlayerAttributeValue <string>(attributeType), new DateTimeValueEditor()).Value);
 }
Ejemplo n.º 5
0
 public PlayerAccountAttribute(PlayerAccountAttributeType type, object value)
 {
     AttributeType = type;
     Value         = value?.ToString() ?? "";
 }