예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ContentManifestGroup"/> class.
        /// </summary>
        /// <param name="manifest">The content manifest that owns the group.</param>
        /// <param name="element">The XML element that defines the content manifest group.</param>
        internal ContentManifestGroup(ContentManifest manifest, XElement element)
        {
            Contract.Require(manifest, nameof(manifest));
            Contract.Require(element, nameof(element));

            var name = element.AttributeValueString("Name");

            if (String.IsNullOrEmpty(name))
            {
                throw new InvalidDataException(UltravioletStrings.InvalidContentManifestGroupName);
            }

            var directory = element.AttributeValueString("Directory");

            var typeName = element.AttributeValueString("Type");

            if (String.IsNullOrEmpty(typeName))
            {
                throw new InvalidDataException(UltravioletStrings.InvalidContentManifestGroupType.Format(name));
            }

            var type = FindTypeByName(typeName);

            this.Manifest  = manifest;
            this.Name      = name;
            this.Type      = type ?? throw new InvalidDataException(UltravioletStrings.InvalidContentManifestGroupType.Format(name));
            this.Directory = directory;

            var assets = element.Elements("Asset");

            foreach (var asset in assets)
            {
                AddInternal(new ContentManifestAsset(this, asset));
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ContentManifestGroup"/> class.
        /// </summary>
        /// <param name="manifest">The content manifest that owns the group.</param>
        /// <param name="desc">The manifest group description.</param>
        internal ContentManifestGroup(ContentManifest manifest, ContentManifestGroupDescription desc)
        {
            Contract.Require(manifest, nameof(manifest));
            Contract.Require(desc, nameof(desc));

            if (String.IsNullOrEmpty(desc.Name))
            {
                throw new InvalidDataException(UltravioletStrings.InvalidContentManifestGroupName);
            }

            if (String.IsNullOrEmpty(desc.Type))
            {
                throw new InvalidDataException(UltravioletStrings.InvalidContentManifestGroupType.Format(desc.Name));
            }

            var type = Type.GetType(desc.Type, false);

            if (type == null)
            {
                throw new InvalidDataException(UltravioletStrings.InvalidContentManifestGroupType.Format(desc.Name));
            }

            this.Manifest  = manifest;
            this.Name      = desc.Name;
            this.Type      = type;
            this.Directory = desc.Directory;

            if (desc.Assets != null)
            {
                foreach (var asset in desc.Assets)
                {
                    AddInternal(new ContentManifestAsset(this, asset));
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Adds a step to the content loader which loads the specified content manifest
        /// into the content manager's asset cache.
        /// </summary>
        /// <param name="manifest">The content manifest to load.</param>
        public void AddStep(ContentManifest manifest)
        {
            Contract.Require(manifest, nameof(manifest));

            AddStepInternal(() => { content.Load(manifest); });
        }