コード例 #1
0
 public virtual bool Load(ISerializeContext ctx)
 {
     Id       = ctx.Reader.ReadMXId(Type);
     Symbol   = ctx.Reader.ReadString();
     RawFlags = ctx.Reader.ReadUInt32();
     return(true);
 }
コード例 #2
0
 /// <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);
     });
 }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: CharItem.cs プロジェクト: bennil/ioctalk
 public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value)
 {
     NullableWrite(writer, value, () =>
     {
         writer.WriteUInt8((byte)(char)value);
     });
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
ファイル: CharItem.cs プロジェクト: bennil/ioctalk
 public override object ReadValue(IStreamReader reader, ISerializeContext context)
 {
     return(NullableRead(reader, () =>
     {
         return (char)reader.ReadUInt8();
     }));
 }
コード例 #8
0
 public override bool Load(ISerializeContext ctx)
 {
     if (!base.Load(ctx))
     {
         return(false);
     }
     return(true);
 }
コード例 #9
0
 public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value)
 {
     NullableWrite(writer, value, () =>
     {
         TimeSpan time = (TimeSpan)value;
         writer.WriteInt64(time.Ticks);
     });
 }
コード例 #10
0
 public bool Load(ISerializeContext ctx)
 {
     Total  = ctx.Reader.ReadUInt32();
     Energy = ctx.Reader.ReadUInt32();
     Lost   = ctx.Reader.ReadUInt32();
     Killed = ctx.Reader.ReadUInt32();
     return(true);
 }
コード例 #11
0
 public override object ReadValue(IStreamReader reader, ISerializeContext context)
 {
     return(NullableRead(reader, () =>
     {
         long timeTicks = reader.ReadInt64();
         return TimeSpan.FromTicks(timeTicks);
     }));
 }
コード例 #12
0
 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);
     });
 }
コード例 #13
0
ファイル: DateTimeItem.cs プロジェクト: bennil/ioctalk
        public override void WriteValue(IStreamWriter writer, ISerializeContext context, object value)
        {
            NullableWrite(writer, value, () =>
            {
                DateTime dt = (DateTime)value;

                writer.WriteInt64(dt.Ticks);
            });
        }
コード例 #14
0
ファイル: DateTimeItem.cs プロジェクト: bennil/ioctalk
        public override object ReadValue(IStreamReader reader, ISerializeContext context)
        {
            return(NullableRead(reader, () =>
            {
                var ticks = reader.ReadInt64();

                return new DateTime(ticks);
            }));
        }
コード例 #15
0
ファイル: StringItem.cs プロジェクト: bennil/ioctalk
        /// <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);
            });
        }
コード例 #16
0
 public override object ReadValue(IStreamReader reader, ISerializeContext context)
 {
     return(NullableRead(reader, () =>
     {
         var guidBytes = reader.ReadBytes(16);
         Guid guid = new Guid(guidBytes.ToArray());
         return guid;
     }));
 }
コード例 #17
0
ファイル: ValueItem.cs プロジェクト: bennil/ioctalk
        /// <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));
        }
コード例 #18
0
        public override bool Load(ISerializeContext ctx)
        {
            if (!base.Load(ctx))
            {
                return(false);
            }

            Prefix = ctx.Reader.ReadString();

            return(true);
        }
コード例 #19
0
        public override bool Load(ISerializeContext ctx)
        {
            if (!base.Load(ctx))
            {
                return(false);
            }

            Location = ctx.Reader.ReadLoc();

            return(true);
        }
コード例 #20
0
        public override bool Load(ISerializeContext ctx)
        {
            if (!base.Load(ctx))
            {
                return(false);
            }

            Success          = ctx.Reader.ReadUInt32();
            BaseRestModifier = ctx.Reader.ReadUInt32();

            return(true);
        }
コード例 #21
0
ファイル: DecimalItem.cs プロジェクト: bennil/ioctalk
        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 });
            }));
        }
コード例 #22
0
        public override bool Load(ISerializeContext ctx)
        {
            if (!base.Load(ctx))
            {
                return(false);
            }

            SuccessTime = ctx.Reader.ReadUInt32();
            FailureTime = ctx.Reader.ReadUInt32();

            return(true);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
        public override bool Load(ISerializeContext ctx)
        {
            if (!base.Load(ctx))
            {
                return(false);
            }

            Energy = ctx.Version > 9
                ? ctx.Reader.ReadUInt32()
                : 180;

            return(true);
        }
コード例 #25
0
        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);
        }
コード例 #26
0
ファイル: DecimalItem.cs プロジェクト: bennil/ioctalk
        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]);
            });
        }
コード例 #27
0
        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);
        }
コード例 #28
0
ファイル: BinarySerializer.cs プロジェクト: bennil/ioctalk
        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);
        }
コード例 #29
0
        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);
        }
コード例 #30
0
        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);
        }