Ejemplo n.º 1
0
        private static byte[] MakeApplicationControlPropertyBytes(string metaPath)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(metaPath);
            XmlNode xmlNode = xmlDocument.SelectSingleNode("//Application");
            ApplicationControlPropertyModel controlPropertyModel = (ApplicationControlPropertyModel) new XmlSerializer(typeof(ApplicationControlPropertyModel)).Deserialize(XmlReader.Create((TextReader) new StringReader(xmlNode == null ? "<Application></Application>" : xmlNode.OuterXml)));
            DotMetaReader dotMetaReader = new DotMetaReader(metaPath);
            long          applicationId = (long)dotMetaReader.GetApplicationId();
            long          aocBaseId     = (long)IdConverter.ConvertToAocBaseId(dotMetaReader.GetCoreId());

            return(controlPropertyModel.MakePropertyBytes((ulong)applicationId, (ulong)aocBaseId));
        }
Ejemplo n.º 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()]));
        }