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; }
private static ContentMetaDescriptor ExtractContentMetaDescriptor(string type, string metaPath, List <NintendoContentInfo> contentInfoList) { ulong applicationId = 0; byte attributes = 0; NintendoExtendedHeader extendedHeader = (NintendoExtendedHeader)null; List <NintendoContentMetaInfo> contentMetaInfoList = new List <NintendoContentMetaInfo>(); uint num1 = NintendoContentMetaBase.GetDefaultDownloadSystemVersion(); ulong id; uint version; if (type.Equals("SystemUpdate")) { ContentMetaModel contentMeta1 = NintendoContentMetaBase.GetDeserializedModel <SystemUpdateModel>(metaPath, false).ContentMeta; if (contentMeta1.Type != "SystemUpdate") { throw new ArgumentException("The content meta type is not SystemUpdate."); } id = contentMeta1.GetUInt64Id(); version = contentMeta1.Version; foreach (ContentMetaModel contentMeta2 in contentMeta1.ContentMetaList) { contentMetaInfoList.Add(new NintendoContentMetaInfo(contentMeta2.Type, contentMeta2.GetUInt64Id(), contentMeta2.Version, (byte)ContentMetaAttributeExtension.FromStringList((IEnumerable <string>)contentMeta2.AttributeList))); } } else { DotMetaReader dotMetaReader = new DotMetaReader(metaPath); id = dotMetaReader.GetContentMetaId(); version = dotMetaReader.GetVersion(); attributes = dotMetaReader.GetContentMetaAttributes(); num1 = dotMetaReader.GetRequiredDownloadSystemVersion().GetValueOrDefault(num1); if (!(type == "Application")) { if (!(type == "AddOnContent")) { if (type == "Patch") { applicationId = dotMetaReader.GetApplicationId(); uint?requiredSystemVersion1 = dotMetaReader.GetRequiredSystemVersion(); uint requiredSystemVersion2 = requiredSystemVersion1.HasValue ? requiredSystemVersion1.Value : NintendoContentMeta.GetRequiredSystemVersion(); extendedHeader = (NintendoExtendedHeader) new NintendoPatchExtendedHeader(dotMetaReader.GetApplicationId(), requiredSystemVersion2); version = NintendoContentMetaBase.ShiftVersion(version, "Patch"); } } else { applicationId = dotMetaReader.GetApplicationId(); extendedHeader = (NintendoExtendedHeader) new NintendoAddOnContentExtendedHeader(dotMetaReader.GetApplicationId(), dotMetaReader.GetRequiredApplicationVersion(), dotMetaReader.GetAddOnContentTag()); version = NintendoContentMetaBase.ShiftVersion(version, "AddOnContent"); } } else { long num2 = (long)id + 2048L; uint?requiredSystemVersion = dotMetaReader.GetRequiredSystemVersion(); int num3 = requiredSystemVersion.HasValue ? (int)requiredSystemVersion.Value : (int)NintendoContentMeta.GetRequiredSystemVersion(); extendedHeader = (NintendoExtendedHeader) new NintendoApplicationExtendedHeader((ulong)num2, (uint)num3); version = NintendoContentMetaBase.ShiftVersion(version, "Application"); } } return(new ContentMetaDescriptor(type, id, version, attributes, applicationId, num1, contentInfoList, contentMetaInfoList, extendedHeader, new byte[NintendoContentMeta.GetDigestSize()])); }
public void SetDigestBytes(byte[] bytes) { this.Digest = BitConverter.ToString(bytes, 0, NintendoContentMeta.GetDigestSize()).Replace("-", string.Empty).ToLower(); }
public long GetDigestSize() { return((long)NintendoContentMeta.GetDigestSize()); }