protected void PrepareDataForUse(byte[] FileData)
        {
            List <Type> Compressions = new List <Type>();

            foreach (dynamic p in EveryFileExplorerUtil.Program.PluginManager.Plugins)
            {
                foreach (Type t in p.CompressionTypes)
                {
                    dynamic c = new LibEveryFileExplorer.StaticDynamic(t);
                    if (c.Identifier.IsFormat(FileData))
                    {
                        Compressions.Add(t);
                    }
                }
            }
            IsCompressed      = false;
            CompressionFormat = null;
            if (Compressions.Count == 1)
            {
                CompressionFormatBase c = (CompressionFormatBase)Compressions[0].InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, null, new object[0]);
                try
                {
                    byte[] Result = c.Decompress(FileData);
                    IsCompressed      = true;
                    CompressionFormat = c;
                    FileData          = Result;
                }
                catch { }
            }
            else if (Compressions.Count > 1)
            {
                foreach (Type t in Compressions)
                {
                    CompressionFormatBase c = (CompressionFormatBase)t.InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, null, new object[0]);
                    try
                    {
                        byte[] Result = c.Decompress(FileData);
                        IsCompressed      = true;
                        CompressionFormat = c;
                        FileData          = Result;
                        break;
                    }
                    catch { }
                }
            }
            Data = FileData;
        }
Beispiel #2
0
 protected void PrepareDataForUse(byte[] FileData)
 {
     List<Type> Compressions = new List<Type>();
     foreach (dynamic p in EveryFileExplorerUtil.Program.PluginManager.Plugins)
     {
         foreach (Type t in p.CompressionTypes)
         {
             dynamic c = new LibEveryFileExplorer.StaticDynamic(t);
             if (c.Identifier.IsFormat(FileData)) Compressions.Add(t);
         }
     }
     IsCompressed = false;
     CompressionFormat = null;
     if (Compressions.Count == 1)
     {
         CompressionFormatBase c = (CompressionFormatBase)Compressions[0].InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, null, new object[0]);
         try
         {
             byte[] Result = c.Decompress(FileData);
             IsCompressed = true;
             CompressionFormat = c;
             FileData = Result;
         }
         catch { }
     }
     else if (Compressions.Count > 1)
     {
         foreach (Type t in Compressions)
         {
             CompressionFormatBase c = (CompressionFormatBase)t.InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, null, new object[0]);
             try
             {
                 byte[] Result = c.Decompress(FileData);
                 IsCompressed = true;
                 CompressionFormat = c;
                 FileData = Result;
                 break;
             }
             catch { }
         }
     }
     Data = FileData;
 }