Example #1
0
 private static Loader Deserialize(Reader reader, IDownloaderDispatch dispatch)
 {
     List<Item[]> itemArrays = new List<Item[]>();
     List<Item> items = new List<Item>();
     while (reader.Read())
     {
         switch (reader.Token)
         {
             case Token.RandomLoadOrderAreaBegin:
             {
                 items.Clear();
                 continue;
             }
             case Token.BundleListing:
             {
                 items.Add(reader.Item);
                 continue;
             }
             case Token.RandomLoadOrderAreaEnd:
             {
                 itemArrays.Add(items.ToArray());
                 continue;
             }
             case Token.DownloadQueueEnd:
             {
                 Operation operation = new Operation();
                 int length = 0;
                 foreach (Item[] itemArray in itemArrays)
                 {
                     length = length + (int)itemArray.Length;
                 }
                 Job[] jobArray = new Job[length];
                 int num = 0;
                 foreach (Item[] itemArray1 in itemArrays)
                 {
                     Item[] itemArray2 = itemArray1;
                     for (int i = 0; i < (int)itemArray2.Length; i++)
                     {
                         Item item = itemArray2[i];
                         int num1 = num;
                         num = num1 + 1;
                         Job job = new Job()
                         {
                             _op = operation,
                             Item = item
                         };
                         jobArray[num1] = job;
                     }
                 }
                 Group group = new Group()
                 {
                     _op = operation,
                     Jobs = jobArray
                 };
                 group.Initialize();
                 Group[] groupArray = new Group[itemArrays.Count];
                 int num2 = 0;
                 int num3 = 0;
                 foreach (Item[] itemArray3 in itemArrays)
                 {
                     int length1 = (int)itemArray3.Length;
                     Job[] jobArray1 = new Job[length1];
                     for (int j = 0; j < length1; j++)
                     {
                         int num4 = num2;
                         num2 = num4 + 1;
                         jobArray1[j] = jobArray[num4];
                     }
                     groupArray[num3] = new Group();
                     groupArray[num3]._op = operation;
                     groupArray[num3].Jobs = jobArray1;
                     groupArray[num3].Initialize();
                     for (int k = 0; k < length1; k++)
                     {
                         jobArray1[k].Group = groupArray[num3];
                     }
                     num3++;
                 }
                 Loader loader = new Loader(group, jobArray, groupArray, dispatch);
                 Loader loader1 = loader;
                 operation.Loader = loader;
                 return loader1;
             }
             default:
             {
                 continue;
             }
         }
     }
     throw new InvalidProgramException();
 }
Example #2
0
 public static Loader Create(Reader reader, IDownloaderDispatch dispatch)
 {
     return Loader.Deserialize(reader, dispatch);
 }