public bool TryInject(IUiInjectionSource source, string sourceFullPath, ArchiveEntryInjectionData data, ArchiveEntry entry)
        {
            Dictionary <string, string> sourceEntries;

            using (Stream input = source.TryOpen(sourceFullPath))
            {
                if (input != null)
                {
                    string        entryName;
                    ZtrTextReader reader = new ZtrTextReader(input, StringsZtrFormatter.Instance);
                    sourceEntries = reader.Read(out entryName).ToDictionary(e => e.Key, e => e.Value);
                    using (Stream output = data.OuputStreamFactory(entry))
                        Inject(data.Listing, entry, sourceEntries, output);

                    return(true);
                }
            }

            sourceEntries = source.TryProvideStrings();
            if (sourceEntries == null)
            {
                return(false);
            }

            using (Stream output = data.OuputStreamFactory(entry))
                Inject(data.Listing, entry, sourceEntries, output);

            return(true);
        }
예제 #2
0
 public UiArchiveInjector(ArchiveListing listing, ArchiveEntry[] leafs, bool? conversion, bool? compression, IUiInjectionSource source)
 {
     _listing = listing;
     _leafs = leafs;
     _source = source;
     _conversion = conversion;
     _compression = compression;
     _injectionData = new ArchiveEntryInjectionData(_listing, OpenOutputStream);
     _injectors = ProvideInjectors();
 }
예제 #3
0
 public UiArchiveInjector(ArchiveListing listing, ArchiveEntry[] leafs, bool?conversion, bool?compression, IUiInjectionSource source)
 {
     _listing       = listing;
     _leafs         = leafs;
     _source        = source;
     _conversion    = conversion;
     _compression   = compression;
     _injectionData = new ArchiveEntryInjectionData(_listing, OpenOutputStream);
     _injectors     = ProvideInjectors();
 }
예제 #4
0
        public bool TryInject(IUiInjectionSource source, string sourceFullPath, ArchiveEntryInjectionData data, ArchiveEntry entry)
        {
            using (Stream input = source.TryOpen(sourceFullPath))
            {
                if (input == null)
                    return false;

                using (Stream output = data.OuputStreamFactory(entry))
                input.CopyToStream(output, (int)input.Length, data.Buffer);

                return true;
            }
        }
예제 #5
0
        public bool TryInject(IUiInjectionSource source, string sourceFullPath, ArchiveEntryInjectionData data, ArchiveEntry entry)
        {
            using (Stream input = source.TryOpen(sourceFullPath))
            {
                if (input == null)
                {
                    return(false);
                }

                using (Stream output = data.OuputStreamFactory(entry))
                    input.CopyToStream(output, (int)input.Length, data.Buffer);

                return(true);
            }
        }
        public bool TryInject(IUiInjectionSource source, string sourceFullPath, ArchiveEntryInjectionData data, ArchiveEntry entry)
        {
            Dictionary<string, string> sourceEntries;
            using (Stream input = source.TryOpen(sourceFullPath))
            {
                if (input != null)
                {
                    string entryName;
                    ZtrTextReader reader = new ZtrTextReader(input, StringsZtrFormatter.Instance);
                    sourceEntries = reader.Read(out entryName).ToDictionary(e => e.Key, e => e.Value);
                    using (Stream output = data.OuputStreamFactory(entry))
                        Inject(data.Listing, entry, sourceEntries, output);

                    return true;
                }
            }

            MemoryInjectionSource memorySource = source as MemoryInjectionSource;
            if (memorySource == null)
                return false;

            sourceEntries = memorySource.TryProvideStrings();
            if (sourceEntries == null)
                return false;

            using (Stream output = data.OuputStreamFactory(entry))
                Inject(data.Listing, entry, sourceEntries, output);

            return true;
        }