Exemplo n.º 1
0
 /// <summary>
 /// Determines if this item represents the same resource as <paramref name="other"/>.
 /// </summary>
 /// <param name="other">Another <see cref="SpecificIndexEntry"/> to test for equivalence.</param>
 /// <returns>True if this item represents the same resource as <paramref name="other"/>; otherwise false.</returns>
 public bool Equals(SpecificIndexEntry other)
 {
     return(ResourceIndexEntry.Equals(other.ResourceIndexEntry) && PathPackage.Equals(other.PathPackage));
 }
Exemplo n.º 2
0
        internal static BinaryReader AddAssembly(Package package, string instanceName)
        {
            BinaryReader result = null;

            try
            {
                TGIBlock tgi   = new TGIBlock(0, null, 0x073FAA07, 0, FNV64.GetHash(instanceName));
                byte[]   array = new byte[0];
                using (FileStream fileStream = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BroadcastTemplate.dll")))
                {
                    using (BinaryReader binaryReader = new BinaryReader(fileStream))
                    {
                        array = new byte[fileStream.Length];
                        binaryReader.Read(array, 0, (int)fileStream.Length);
                    }
                }
                byte[]      array2 = Encoding.ASCII.GetBytes(instanceName);
                int         num    = 0;
                List <byte> list   = new List <byte>();
                List <byte> list2  = new List <byte>();
                for (int i = 0; i < array.Length; i++)
                {
                    byte b = array[i];
                    if (b == AssemblyTemplate[num])
                    {
                        list2.Add(b);
                        num++;
                        if (num >= AssemblyTemplate.Length)
                        {
                            list.AddRange(array2);
                            list2.Clear();
                            num = 0;
                        }
                    }
                    else
                    {
                        list.AddRange(list2);
                        list2.Clear();
                        num = 0;
                        list.Add(b);
                    }
                }
                ScriptResource.ScriptResource assembly = new ScriptResource.ScriptResource(0, null);
                using (MemoryStream s = new MemoryStream(list.ToArray()))
                {
                    result            = new BinaryReader(s);
                    assembly.Assembly = result;
                }
                ResourceIndexEntry entry = (ResourceIndexEntry)package.AddResource(tgi, null, true);
                package.ReplaceResource(entry, assembly);
                return(result);
            }
            catch
            {
                if (result != null)
                {
                    result.Close();
                }
                throw;
            }
        }