private void TestByteSerialization(SpecCase x)
 {
     var stream = new ByteStream(0, true);
     var a = new ItemCountDefinition() {
         TypeName = "some type",
         SubtypeName = "some subtype",
         Count = 47
     };
     a.AddToByteSteam(stream);
     stream = new ByteStream(stream.Data, stream.Data.Length);
     var a2 = new ItemCountDefinition(stream);
     x.Assert(a2.TypeName == "some type",
         "Name serializes/deserializes correctly.");
     x.Assert(a2.SubtypeName == "some subtype",
         "SubtypeName serializes/deserializes correctly.");
     x.Assert(a2.Count == 47,
         "Count serializes/deserializes correctly.");
 }
Example #2
0
 public ItemCount(ItemCountDefinition definition)
 {
     Amount = (MyFixedPoint)definition.Count;
     Item = new PhysicalItemType(definition.TypeName, definition.SubtypeName);
 }
Example #3
0
        public ItemCountAggregateDefinition GetDefinition()
        {
            var result = new ItemCountAggregateDefinition();

            foreach (var kvp in Counts) {
                if (kvp.Value <= 0) continue;
                var item = new PhysicalItemType(kvp.Key);
                var countDef = new ItemCountDefinition() {
                    TypeName = item.TypeName,
                    SubtypeName = item.SubtypeName,
                    Count = (double)kvp.Value,
                };
                result.Counts.Add(countDef);
            }

            return result;
        }