Пример #1
0
        public override void Deserialize(MyObjectBuilder_ComponentBase builder)
        {
            base.Deserialize(builder);
            MyObjectBuilder_InventoryAggregate aggregate = builder as MyObjectBuilder_InventoryAggregate;

            if ((aggregate != null) && (aggregate.Inventories != null))
            {
                foreach (MyObjectBuilder_InventoryBase base2 in aggregate.Inventories)
                {
                    MyComponentBase component = MyComponentFactory.CreateInstanceByTypeId(base2.TypeId);
                    component.Deserialize(base2);
                    this.AddComponent(component);
                }
            }
        }
Пример #2
0
        public override MyObjectBuilder_ComponentBase Serialize(bool copy = false)
        {
            MyObjectBuilder_InventoryAggregate aggregate = base.Serialize(false) as MyObjectBuilder_InventoryAggregate;
            ListReader <MyComponentBase>       reader    = this.m_children.Reader;

            if (reader.Count > 0)
            {
                aggregate.Inventories = new List <MyObjectBuilder_InventoryBase>(reader.Count);
                using (List <MyComponentBase> .Enumerator enumerator = reader.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        MyObjectBuilder_InventoryBase item = enumerator.Current.Serialize(false) as MyObjectBuilder_InventoryBase;
                        if (item != null)
                        {
                            aggregate.Inventories.Add(item);
                        }
                    }
                }
            }
            return(aggregate);
        }