示例#1
0
        public override fsResult TrySerialize(object instance, out fsData serialized, System.Type storageType)
        {
            DynamicString str = instance as DynamicString;

            if (str == null)
            {
                serialized = new fsData();
                return(fsResult.Fail("Failed to convert field to DynamicInt on serialization"));
            }
            serialized = !str.isDynamic ? new fsData(str.fixedValue) : new fsData("%" + str.dynamicKey);
            return(fsResult.Success);
        }
示例#2
0
 public string Evaluate(DynamicString dynamicStr)
 {
     if (!dynamicStr.isDynamic)
     {
         return(dynamicStr.fixedValue);
     }
     if (this._overrideMap.ContainsKey(dynamicStr.dynamicKey))
     {
         return((string)this._overrideMap[dynamicStr.dynamicKey]);
     }
     return((string)this.config.AbilitySpecials[dynamicStr.dynamicKey]);
 }
示例#3
0
        public override fsResult TryDeserialize(fsData data, ref object instance, System.Type storageType)
        {
            DynamicString str = (DynamicString)instance;

            if (!data.IsString)
            {
                return(fsResult.Fail("DynamicString fields needs to be either a '%key' or a string value."));
            }
            string asString = data.AsString;

            if (asString.StartsWith("%"))
            {
                str.isDynamic = true;
                char[] trimChars = new char[] { '%' };
                str.dynamicKey = asString.TrimStart(trimChars);
            }
            else
            {
                str.isDynamic  = false;
                str.fixedValue = asString;
            }
            return(fsResult.Success);
        }