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; }
public ByteData PullData(long offset, int size) { ISource source = this.m_contentMetaBase.GetSource(); NintendoContentMetaReader contentMetaReader = new NintendoContentMetaReader(source.PullData(0L, (int)source.Size).Buffer.Array); List <NintendoContentInfo> contentInfoList = contentMetaReader.GetContentInfoList(); for (int index = 0; index < contentInfoList.Count; ++index) { NintendoContentInfo nintendoContentInfo = contentInfoList[index]; this.m_model.ContentList[index].SetIdBytes(nintendoContentInfo.Id); this.m_model.ContentList[index].SetHashBytes(nintendoContentInfo.Hash); } this.m_model.SetDigestBytes(contentMetaReader.GetDigest()); ByteData byteData = this.m_MetaHashSource.PullData(0L, NintendoContentMeta.GetContentInfoHashSize()); this.m_MetaModel.SetIdBytes(byteData.Buffer.Array); this.m_MetaModel.SetHashBytes(byteData.Buffer.Array); byte[] bytes = this.GetBytes(); return(new MemorySource(bytes, 0, bytes.Length).PullData(offset, size)); }
public void SetHashBytes(byte[] bytes) { this.Hash = BitConverter.ToString(bytes, 0, NintendoContentMeta.GetContentInfoHashSize()).Replace("-", string.Empty).ToLower(); }
public long GetContentInfoHashSize() { return((long)NintendoContentMeta.GetContentInfoHashSize()); }