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); }
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]); }
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); }