#region File Description
//-----------------------------------------------------------------------------
// ContentEntry.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
#region Using Statements
using System;
using Microsoft.Xna.Framework.Content;
using System.Xml.Serialization;
#endregion
namespace RolePlayingGameData
{
///
/// A description of a piece of content and quantity for various purposes.
///
public class ContentEntry where T : ContentObject
{
///
/// The content name for the content involved.
///
private string contentName;
///
/// The content name for the content involved.
///
[ContentSerializer(Optional=true)]
public string ContentName
{
get { return contentName; }
set { contentName = value; }
}
///
/// The content referred to by this entry.
///
///
/// This will not be automatically loaded, as the content path may be incomplete.
///
private T content;
///
/// The content referred to by this entry.
///
///
/// This will not be automatically loaded, as the content path may be incomplete.
///
[ContentSerializerIgnore]
[XmlIgnore]
public T Content
{
get { return content; }
set { content = value; }
}
///
/// The quantity of this content.
///
private int count = 1;
///
/// The quantity of this content.
///
[ContentSerializer(Optional=true)]
public int Count
{
get { return count; }
set { count = value; }
}
#region Content Type Reader
///
/// Reads a ContentEntry object from the content pipeline.
///
public class ContentEntryReader : ContentTypeReader>
{
///
/// Reads a ContentEntry object from the content pipeline.
///
protected override ContentEntry Read(ContentReader input,
ContentEntry existingInstance)
{
ContentEntry member = existingInstance;
if (member == null)
{
member = new ContentEntry();
}
member.ContentName = input.ReadString();
member.Count = input.ReadInt32();
return member;
}
}
#endregion
}
}