public virtual bool Load(ISerializeContext ctx) { Id = ctx.Reader.ReadMXId(Type); Symbol = ctx.Reader.ReadString(); RawFlags = ctx.Reader.ReadUInt32(); return(true); }
/// <summary> /// Writes the value. /// </summary> /// <param name="writer">The writer.</param> /// <param name="value">The value.</param> public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { NullableWrite(writer, value, () => { writer.WriteInt64((long)value); }); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } OccupyingRace = ctx.Reader.ReadRace(); Race = ctx.Reader.ReadRace(); UnitType = ctx.Reader.ReadUnitType(); Total = ctx.Reader.ReadUInt32(); Min = ctx.Reader.ReadUInt32(); Max = ctx.Reader.ReadUInt32(); StrategicalSuccess = ctx.Reader.ReadUInt32(); OwnerSuccess = ctx.Reader.ReadUInt32(); EnemySuccess = ctx.Reader.ReadUInt32(); Influence = ctx.Reader.ReadUInt32(); Respawn = ctx.Reader.ReadUInt32(); Occupier = ctx.ReadEntity <ICharacter>(); Owner = ctx.ReadEntity <ICharacter>(); Terrain = ctx.Reader.ReadTerrain(); Killed = ctx.Reader.ReadUInt32(); Lost = 0; return(true); }
public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { NullableWrite(writer, value, () => { writer.WriteUInt8((byte)(char)value); }); }
public Type DetermineTargetType(Type interfaceType, ISerializeContext context) { if (interfaceType.Equals(typeof(ITestInterfaceBase))) { return(typeof(TestInterfaceImpl1)); } else if (interfaceType.Equals(typeof(IDeepTestInterface1))) { return(typeof(TestInterfaceImpl1)); } else if (interfaceType.Equals(typeof(ITestInterfaceWithoutSetProperties))) { return(typeof(TestImplementationWithoutSetProperties)); } else if (interfaceType.Equals(typeof(IPerformanceData))) { return(typeof(PerformanceData)); } //else if (interfaceType.Equals(typeof(IGenericMessage))) //{ // return typeof(GenericMessage); //} return(null); }
private void AddProperties(Type t, HashSet <string> existingProperties, ISerializeContext ctx) { foreach (var prop in t.GetProperties(BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.Public)) { if (existingProperties.Contains(prop.Name)) { continue; } if (prop.GetIndexParameters().Length > 0) { // ignore index properties continue; } if (!prop.CanRead || !prop.CanWrite) { continue; } if (prop.PropertyType.Equals(type)) { // ignore same nested types because of recursive endless loop continue; } IValueItem item = ValueItem.CreateValueItem(prop, ctx); items.Add(item); existingProperties.Add(prop.Name); } }
public override object ReadValue(IStreamReader reader, ISerializeContext context) { return(NullableRead(reader, () => { return (char)reader.ReadUInt8(); })); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } return(true); }
public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { NullableWrite(writer, value, () => { TimeSpan time = (TimeSpan)value; writer.WriteInt64(time.Ticks); }); }
public bool Load(ISerializeContext ctx) { Total = ctx.Reader.ReadUInt32(); Energy = ctx.Reader.ReadUInt32(); Lost = ctx.Reader.ReadUInt32(); Killed = ctx.Reader.ReadUInt32(); return(true); }
public override object ReadValue(IStreamReader reader, ISerializeContext context) { return(NullableRead(reader, () => { long timeTicks = reader.ReadInt64(); return TimeSpan.FromTicks(timeTicks); })); }
public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { NullableWrite(writer, value, () => { Guid guid = (Guid)value; var seg = new ArraySegment <byte>(guid.ToByteArray()); writer.WriteBytes(seg); }); }
public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { NullableWrite(writer, value, () => { DateTime dt = (DateTime)value; writer.WriteInt64(dt.Ticks); }); }
public override object ReadValue(IStreamReader reader, ISerializeContext context) { return(NullableRead(reader, () => { var ticks = reader.ReadInt64(); return new DateTime(ticks); })); }
/// <summary> /// Writes the value. /// </summary> /// <param name="writer">The writer.</param> /// <param name="value">The value.</param> public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { NullableWrite(writer, value, () => { string stringValue = (string)value; writer.WriteString(stringValue); }); }
public override object ReadValue(IStreamReader reader, ISerializeContext context) { return(NullableRead(reader, () => { var guidBytes = reader.ReadBytes(16); Guid guid = new Guid(guidBytes.ToArray()); return guid; })); }
/// <summary> /// Creates the value item. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <returns>IValueItem.</returns> /// <exception cref="System.NotSupportedException"></exception> public static IValueItem CreateValueItem(PropertyInfo prop, ISerializeContext ctx) { var type = prop.PropertyType; var name = prop.Name; var getter = prop.GenerateGetterFunc(); var setter = prop.GenerateSetterAction(); return(CreateValueItem(prop.DeclaringType, type, name, getter, setter, ctx)); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } Prefix = ctx.Reader.ReadString(); return(true); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } Location = ctx.Reader.ReadLoc(); return(true); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } Success = ctx.Reader.ReadUInt32(); BaseRestModifier = ctx.Reader.ReadUInt32(); return(true); }
public override object ReadValue(IStreamReader reader, ISerializeContext context) { return(NullableRead(reader, () => { int i1 = reader.ReadInt32(); int i2 = reader.ReadInt32(); int i3 = reader.ReadInt32(); int i4 = reader.ReadInt32(); return new decimal(new int[] { i1, i2, i3, i4 }); })); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } SuccessTime = ctx.Reader.ReadUInt32(); FailureTime = ctx.Reader.ReadUInt32(); return(true); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } Priority = ctx.Reader.ReadInt32(); Mission = ctx.ReadEntity <IMission>(); String = ctx.Reader.ReadUInt32(); return(true); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } Energy = ctx.Version > 9 ? ctx.Reader.ReadUInt32() : 180; return(true); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } PersonalPronoun = ctx.Reader.ReadString(); PossessivePronoun = ctx.Reader.ReadString(); SingularPronoun = ctx.Reader.ReadString(); return(true); }
public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value) { NullableWrite(writer, value, () => { decimal decVal = (decimal)value; int[] bits = Decimal.GetBits(decVal); writer.WriteInt32(bits[0]); writer.WriteInt32(bits[1]); writer.WriteInt32(bits[2]); writer.WriteInt32(bits[3]); }); }
public bool Load(ISerializeContext context) { var count = context.Reader.ReadUInt32(); Entries = Enumerable.Range(0, (int)count) .Select(_ => Create(context)) .Where(s => s is not null) .Cast <DatabaseString>() .ToList().AsReadOnly(); _symbolMap = Entries.ToDictionary(s => s.Symbol, s => s); _idMap = Entries.ToDictionary(s => s.Id, s => s); return(true); }
public IValueItem GetByType(Type type, ISerializeContext ctx) { IValueItem result; if (globalStructureMapping.TryGetValue(type, out result)) { return(result); } var newItemStructure = ValueItem.CreateValueItem(null, type, null, null, null, ctx); RegisterTypeMapping(type, newItemStructure); return(newItemStructure); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } Name = ctx.Reader.ReadString(); CarriedBy = ctx.ReadEntity <IItem>(); Description = ctx.Reader.ReadString(); Kills = ctx.Reader.ReadThingType(); UseDescription = ctx.Reader.ReadUInt32(); return(true); }
public override bool Load(ISerializeContext ctx) { if (!base.Load(ctx)) { return(false); } Preposition = ctx.Reader.ReadString(); Description = ctx.Reader.ReadString(); Success = ctx.Reader.ReadUInt32(); Visibility = ctx.Reader.ReadUInt32(); Obstruction = ctx.Reader.ReadUInt32(); MovementCost = ctx.Reader.ReadInt32(); return(true); }