コード例 #1
0
        public void CloseBuilder(ref TBuilder builder)
        {
            if (this.Disposed)
            {
                throw new ObjectDisposedException("Recycler");
            }
            if (this.OpenCount == 0)
            {
                throw new InvalidOperationException("Close was called more than Open for this Recycler");
            }
            if (!object.ReferenceEquals(builder, this.Builder))
            {
                throw new ArgumentOutOfRangeException("builder", "Was not opened by this recycler");
            }
            builder = (TBuilder)null;
            Recycler <TMessage, TBuilder> recycler = this;
            int openCount = recycler.OpenCount - 1;
            int num       = openCount;

            recycler.OpenCount = openCount;
            if (num == 0 && !this.Cleared)
            {
                this.Builder.Clear();
                this.Cleared = true;
            }
        }
コード例 #2
0
 void System.IDisposable.Dispose()
 {
     if (!this.Disposed)
     {
         this.Disposed = true;
         int count = Recycler <TMessage, TBuilder> .Recovery.Count;
         int num   = count;
         Recycler <TMessage, TBuilder> .Recovery.Count = count + 1;
         if (num != 0)
         {
             this.Next = Recycler <TMessage, TBuilder> .Recovery.Pile;
             Recycler <TMessage, TBuilder> .Recovery.Pile = this;
         }
         else
         {
             this.Next = null;
             Recycler <TMessage, TBuilder> .Recovery.Pile = this;
         }
         this.OpenCount = 0;
         if (this.Created && !this.Cleared)
         {
             this.Builder.Clear();
             this.Cleared = true;
         }
     }
 }
コード例 #3
0
        public TBuilder OpenBuilder()
        {
            Recycler <TMessage, TBuilder> recycler = this;
            int openCount = recycler.OpenCount;
            int num       = openCount;

            recycler.OpenCount = openCount + 1;
            if (num == 0)
            {
                if (this.Created)
                {
                    this.Cleared = false;
                }
                else
                {
                    this.Builder = Activator.CreateInstance <TBuilder>();
                    this.Created = true;
                }
            }
            return(this.Builder);
        }
コード例 #4
0
        public static Recycler <TMessage, TBuilder> Manufacture()
        {
            if (Recycler <TMessage, TBuilder> .Recovery.Count == 0)
            {
                return(new Recycler <TMessage, TBuilder>());
            }
            Recycler <TMessage, TBuilder> pile = Recycler <TMessage, TBuilder> .Recovery.Pile;

            if (Recycler <TMessage, TBuilder> .Recovery.Count != 1)
            {
                Recycler <TMessage, TBuilder> .Recovery.Count = Recycler <TMessage, TBuilder> .Recovery.Count - 1;
                Recycler <TMessage, TBuilder> .Recovery.Pile  = pile.Next;
                pile.Next = null;
            }
            else
            {
                Recycler <TMessage, TBuilder> .Recovery = new Recycler <TMessage, TBuilder> .Holding();
            }
            pile.Disposed = false;
            return(pile);
        }
コード例 #5
0
 void IDisposable.Dispose()
 {
     if (!this.Disposed)
     {
         this.Disposed = true;
         if (Recycler <TMessage, TBuilder> .Recovery.Count++ == 0)
         {
             this.Next = null;
             Recycler <TMessage, TBuilder> .Recovery.Pile = (Recycler <TMessage, TBuilder>) this;
         }
         else
         {
             this.Next = Recycler <TMessage, TBuilder> .Recovery.Pile;
             Recycler <TMessage, TBuilder> .Recovery.Pile = (Recycler <TMessage, TBuilder>) this;
         }
         this.OpenCount = 0;
         if (this.Created && !this.Cleared)
         {
             this.Builder.Clear();
             this.Cleared = true;
         }
     }
 }
コード例 #6
0
 // Token: 0x06003C18 RID: 15384 RVA: 0x000D6B6C File Offset: 0x000D4D6C
 public void WriteObjectSave(ref RustProto.SavedObject.Builder saveobj)
 {
     using (RustProto.Helpers.Recycler <RustProto.objectDeployable, RustProto.objectDeployable.Builder> recycler = RustProto.objectDeployable.Recycler())
     {
         RustProto.objectDeployable.Builder builder = recycler.OpenBuilder();
         builder.SetCreatorID(this.creatorID);
         builder.SetOwnerID(this.ownerID);
         saveobj.SetDeployable(builder);
     }
     using (RustProto.Helpers.Recycler <RustProto.objectICarriableTrans, RustProto.objectICarriableTrans.Builder> recycler2 = RustProto.objectICarriableTrans.Recycler())
     {
         RustProto.objectICarriableTrans.Builder builder2 = recycler2.OpenBuilder();
         global::NetEntityID netEntityID;
         if (this._carrier && (int)global::NetEntityID.Of(this._carrier, out netEntityID) != 0)
         {
             builder2.SetTransCarrierID(netEntityID.id);
         }
         else
         {
             builder2.ClearTransCarrierID();
         }
         saveobj.SetCarriableTrans(builder2);
     }
 }
コード例 #7
0
 // Token: 0x06003C84 RID: 15492 RVA: 0x000D8510 File Offset: 0x000D6710
 public void WriteObjectSave(ref RustProto.SavedObject.Builder saveobj)
 {
     using (RustProto.Helpers.Recycler <RustProto.objectFireBarrel, RustProto.objectFireBarrel.Builder> recycler = RustProto.objectFireBarrel.Recycler())
     {
         RustProto.objectFireBarrel.Builder builder = recycler.OpenBuilder();
         builder.SetOnFire(this.isOn);
         saveobj.SetFireBarrel(builder);
     }
 }