Exemple #1
0
        public void KeepCapacityOnAdd()
        {
            var pipe = new Pipe <int>(2);

            pipe.Add(0);
            pipe.Add(1);
            pipe.Add(2);
            Assert.Equal(new int[] { 2, 1 }, pipe.Select(x => x));
        }
Exemple #2
0
 internal static void FlushPipe(Pipe oldPipe, ArrayList arrayList)
 {
     foreach (object obj2 in arrayList)
     {
         oldPipe.Add(obj2);
     }
 }
Exemple #3
0
        static public void ToPipe(string path, OptionsStruct opt, Pipe pipeOut)
        {
            int  size     = 0;
            var  fi       = new FileInfo(path);
            long fileSize = fi.Length;

            size += sizeof(long); //8
            //opt.density
            size += 1;
            //opt.cellCount
            size += 1;
            //fileName length
            string name = Path.GetFileName(path);

            byte[] nameArray = System.Text.UTF8Encoding.UTF8.GetBytes(name);
            int    nameSize  = nameArray.Length;

            if (nameSize >= 256 * 256)
            {
                throw new ArgumentOutOfRangeException("File name length");
            }
            size += 2;
            size += nameSize;
            byte[] result = new byte[size];
            int    i      = 0;

            while (i < 8)
            {
                result[i] = (byte)(fileSize % 256);
                fileSize  = fileSize / 256;
                i++;
            }
            result[i] = opt.density;
            i++;
            result[i] = opt.cellCount;
            i++;
            int temp = nameSize;

            result[i] = (byte)(temp % 256);
            temp     /= 256;
            i++;
            result[i] = (byte)(temp % 256);
            i++;
            for (int j = 0; j < nameSize; j++)
            {
                result[i + j] = nameArray[j];
            }
            pipeOut.Add(result);
            pipeOut.Complete();
        }
Exemple #4
0
 internal static void WriteEnumerableToPipe(IEnumerator enumerator, Pipe pipe, ExecutionContext context, bool dispose)
 {
     try
     {
         while (MoveNext(context, enumerator))
         {
             pipe.Add(Current(enumerator));
         }
     }
     finally
     {
         if (dispose)
         {
             IDisposable disposable = enumerator as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
     }
 }