internal NintendoContentMetaBaseSource(NintendoContentMetaBase contentMetaBase, bool isUpdateDigest)
        {
            this.m_isUpdateDigest  = isUpdateDigest;
            this.m_contentMetaBase = contentMetaBase;
            byte[]         bytes  = contentMetaBase.GetBytes();
            ISource        source = (ISource) new MemorySource(bytes, 0, bytes.Length);
            List <ISource> list   = contentMetaBase.GetContentSourceList().Select <Tuple <ISource, NintendoContentInfo>, ISource>((Func <Tuple <ISource, NintendoContentInfo>, ISource>)(tuple => tuple.Item1)).ToList <ISource>();

            for (int index = 0; index < list.Count; ++index)
            {
                long    contentInfoIdDataSize = contentMetaBase.GetContentInfoIdDataSize();
                long    infoIdDataOffset      = contentMetaBase.GetContentInfoIdDataOffset(index);
                ISource baseSource            = (ISource) new AdaptedSource(source, (ISource) new SubSource(list[index], 0L, contentInfoIdDataSize), infoIdDataOffset, contentInfoIdDataSize);
                long    contentInfoHashSize   = contentMetaBase.GetContentInfoHashSize();
                long    contentInfoHashOffset = contentMetaBase.GetContentInfoHashOffset(index);
                source = (ISource) new AdaptedSource(baseSource, list[index], contentInfoHashOffset, contentInfoHashSize);
            }
            if (isUpdateDigest)
            {
                long digestSize   = contentMetaBase.GetDigestSize();
                long digestOffset = contentMetaBase.GetDigestOffset();
                source = (ISource) new AdaptedSource(source, (ISource) new Sha256StreamHashSource((ISource) new SubSource(source, 0L, digestOffset)), digestOffset, digestSize);
            }
            this.m_source = source;
            this.Size     = this.m_source.Size;
        }
        public NintendoContentMetaXmlSource(NintendoContentMetaBase contentMetaBase, ISource metaHashSource, long metaSize)
        {
            this.m_contentMetaBase = contentMetaBase;
            this.m_MetaHashSource  = metaHashSource;
            NintendoContentMetaReader contentMetaReader = new NintendoContentMetaReader(contentMetaBase.GetBytes());
            ContentMetaModel          contentMetaModel1 = this.PrepareContentMetaModel(contentMetaBase.GetContentMetaDescryptor());

            contentMetaModel1.Type = contentMetaReader.GetType();
            contentMetaModel1.SetUInt64Id(contentMetaReader.GetId());
            contentMetaModel1.Version       = contentMetaReader.GetVersion();
            contentMetaModel1.AttributeList = ((ContentMetaAttribute)contentMetaReader.GetAttributes()).ToStringList();
            contentMetaModel1.RequiredDownloadSystemVersion = contentMetaReader.GetRequiredDownloadSystemVersion();
            byte[] bytes1 = new byte[NintendoContentMeta.GetDigestSize()];
            contentMetaModel1.SetDigestBytes(bytes1);
            List <NintendoContentInfo> contentInfoList = contentMetaReader.GetContentInfoList();

            if (contentInfoList.Count > 0)
            {
                contentMetaModel1.ContentList = new List <ContentModel>();
                foreach (NintendoContentInfo nintendoContentInfo in contentInfoList)
                {
                    ContentModel contentModel = new ContentModel();
                    contentModel.Type = nintendoContentInfo.Type;
                    contentModel.Size = nintendoContentInfo.Size;
                    byte[] bytes2 = new byte[NintendoContentMeta.GetContentInfoHashSize()];
                    contentModel.SetIdBytes(bytes2);
                    contentModel.SetHashBytes(bytes2);
                    contentMetaModel1.ContentList.Add(contentModel);
                }
            }
            contentMetaModel1.ContentList = contentMetaModel1.ContentList ?? new List <ContentModel>();
            this.m_MetaModel = new ContentModel();
            contentMetaModel1.ContentList.Add(this.m_MetaModel);
            this.m_MetaModel.Type = "Meta";
            this.m_MetaModel.Size = metaSize;
            byte[] bytes3 = new byte[NintendoContentMeta.GetContentInfoHashSize()];
            this.m_MetaModel.SetIdBytes(bytes3);
            this.m_MetaModel.SetHashBytes(bytes3);
            List <NintendoContentMetaInfo> contentMetaInfoList = contentMetaReader.GetContentMetaInfoList();

            if (contentMetaInfoList.Count > 0)
            {
                contentMetaModel1.ContentMetaList = new List <ContentMetaModel>();
                foreach (NintendoContentMetaInfo nintendoContentMetaInfo in contentMetaInfoList)
                {
                    ContentMetaModel contentMetaModel2 = new ContentMetaModel();
                    contentMetaModel2.Type = nintendoContentMetaInfo.Type;
                    contentMetaModel2.SetUInt64Id(nintendoContentMetaInfo.Id);
                    contentMetaModel2.Version       = nintendoContentMetaInfo.Version;
                    contentMetaModel2.AttributeList = ((ContentMetaAttribute)nintendoContentMetaInfo.Attributes).ToStringList();
                    contentMetaModel1.ContentMetaList.Add(contentMetaModel2);
                }
            }
            this.m_model = contentMetaModel1;
            this.Size    = (long)this.GetBytes().Length;
        }
        internal NintendoContentMetaArchiveSource(NintendoContentMetaBase contentMeta, int keyEncryptionKeyIndex, KeyConfiguration config, bool isProdEncryption, bool isGameCard)
        {
            NintendoContentMetaReader contentMetaReader = new NintendoContentMetaReader(contentMeta.GetBytes());
            ISource source1 = contentMeta.GetSource();
            PartitionFileSystemInfo partitionFileSystemInfo = new PartitionFileSystemInfo();

            partitionFileSystemInfo.version = 0;
            partitionFileSystemInfo.entries.Add(new PartitionFileSystemInfo.EntryInfo()
            {
                type   = "source",
                name   = contentMeta.GetEntryName(),
                offset = 0UL,
                size   = (ulong)source1.Size
            });
            PartitionFileSystemMeta           partitionFileSystemMeta = new PartitionFileSystemMeta();
            List <ConcatenatedSource.Element> elements       = new List <ConcatenatedSource.Element>();
            PartitionFileSystemInfo           fileSystemInfo = partitionFileSystemInfo;

            byte[] buffer = partitionFileSystemMeta.Create(fileSystemInfo);
            ConcatenatedSource.Element element1 = new ConcatenatedSource.Element((ISource) new MemorySource(buffer, 0, buffer.Length), "meta", 0L);
            ConcatenatedSource.Element element2 = new ConcatenatedSource.Element(source1, "body", element1.Source.Size);
            elements.Add(element1);
            elements.Add(element2);
            ISource source2 = (ISource) new ConcatenatedSource(elements);

            this.m_source = (ISource) new NintendoContentArchiveSource(new NintendoContentFileSystemInfo()
            {
                distributionType          = isGameCard ? (byte)1 : (byte)0,
                contentType               = (byte)1,
                keyGeneration             = (byte)0,
                programId                 = contentMetaReader.GetId(),
                contentIndex              = 0U,
                keyAreaEncryptionKeyIndex = (byte)keyEncryptionKeyIndex,
                isProdEncryption          = isProdEncryption,
                fsEntries                 =
                {
                    new NintendoContentFileSystemInfo.EntryInfo()
                    {
                        type            = "source",
                        formatType      = "PartitionFs",
                        sourceInterface = (SourceInterface) new CliCompatibleSource(source2),
                        version         = (ushort)2,
                        hashType        = (byte)0,
                        encryptionType  = (byte)0
                    }
                },
                numFsEntries = 1
            }, config, false);
            this.Size = this.m_source.Size;
        }