public byte GetContentMetaAttributes()
 {
     foreach (string contentTypeDirective in this.ContentTypeDirectives)
     {
         if (this.m_Document.Descendants((XName)contentTypeDirective).Any <XElement>())
         {
             return((byte)ContentMetaAttributeExtension.FromStringList(this.m_Document.Descendants((XName)contentTypeDirective).Elements <XElement>((XName)"ContentMetaAttribute").Select <XElement, string>((Func <XElement, string>)(attribute => attribute.Value))));
         }
     }
     return(0);
 }
Exemple #2
0
        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()]));
        }