Mono.DataConverter.Align C# (CSharp) Метод

Align() статический приватный Метод

static private Align ( int current, int align ) : int
current int
align int
Результат int
		static int Align (int current, int align)
		{
			return ((current + align - 1) / align) * align;
		}
			

Usage Example

Пример #1
0
 public void Add(byte[] group)
 {
     if (this.buffer == null)
     {
         this.buffer = group;
         this.next   = group.Length;
         return;
     }
     if (this.align != 0)
     {
         if (this.align == -1)
         {
             this.next = DataConverter.Align(this.next, group.Length);
         }
         else
         {
             this.next = DataConverter.Align(this.next, this.align);
         }
         this.align = 0;
     }
     if (this.next + group.Length > this.buffer.Length)
     {
         byte[] destinationArray = new byte[Math.Max(this.next, 16) * 2 + group.Length];
         Array.Copy(this.buffer, destinationArray, this.buffer.Length);
         Array.Copy(group, 0, destinationArray, this.next, group.Length);
         this.next  += group.Length;
         this.buffer = destinationArray;
     }
     else
     {
         Array.Copy(group, 0, this.buffer, this.next, group.Length);
         this.next += group.Length;
     }
 }
All Usage Examples Of Mono.DataConverter::Align