#region Using Statements
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using ANX.Framework.NonXNA.Development;
#endregion
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.Framework.Content.Pipeline.Tasks
{
//comment by author: if you find any mistakes in my language, go fix it ;-)
[Developer("SilentWarrior/Eagle Eye Studios")]
[PercentageComplete(70)]
[TestState(TestStateAttribute.TestState.InProgress)]
public class ContentProject
{
#region Properties
///
/// Name of the Content Project
///
public String Name { get; set; }
///
/// Major version of the project format
///
public int VersionMajor { get { return 1; } }
///
/// Minor version of the project format.
/// Used to keep backwards compatibility
///
public int VersionMinor { get { return 0; } } //before you commit your changes, please increase this value by one (and if you added stuff, please check the version before you read anything out of a file).
///
/// The directory where the compiled output will be placed
///
public String OutputDirectory { get; set; }
///
/// The Content Root Directory. Default value is "Content".
///
public String ContentRoot { get; set; }
///
/// A list containing all build items of this project
///
public List BuildItems { get; private set; }
///
/// List which holds Assemblies that contain custom importers/processors
///
public List References { get; set; }
///
/// Name of the tool that generated the resulting file. Might be useful for tracking down
/// bugs in that particular application.
///
public String Creator { get; set; }
///
/// The configuration. Can be "Debug" or "Release".
///
public String Configuration { get; set; }
///
/// The platform the content will be compiled for.
///
public TargetPlatform Platform { get; set; }
#endregion
///
/// Initializes a new instance of a
///
/// Name of the project
public ContentProject(String name)
{
Name = name;
OutputDirectory = "bin";
BuildItems = new List();
References = new List();
}
#region Save
///
/// Saves the project into a file. Should be a .cproj extension.
///
/// The path to save the project
public void Save(string path)
{
if (!Directory.Exists(Path.GetDirectoryName(path)))
Directory.CreateDirectory(Path.GetDirectoryName(path));
XmlWriter writer = XmlTextWriter.Create(path, new XmlWriterSettings() {Encoding = Encoding.UTF8, Indent = true, NewLineHandling = NewLineHandling.Entitize} );
writer.WriteStartDocument();
//
writer.WriteStartElement("ContentProject");
writer.WriteStartAttribute("Version");
writer.WriteValue(VersionMajor + "." + VersionMinor);
writer.WriteEndAttribute();
writer.WriteStartAttribute("Creator");
writer.WriteValue(Creator);
writer.WriteEndAttribute();
//Name
writer.WriteStartElement("ProjectName");
writer.WriteValue(Name);
writer.WriteEndElement();
//Debug
writer.WriteStartElement("Configuration");
writer.WriteValue(Configuration);
writer.WriteEndElement();
//Windows
writer.WriteStartElement("Platform");
writer.WriteValue(Platform.ToString());
writer.WriteEndElement();
//A:\Somewhere
writer.WriteStartElement("OutputPath");
writer.WriteValue(OutputDirectory);
writer.WriteEndElement();
//Content
writer.WriteStartElement("ContentRoot");
writer.WriteValue(ContentRoot);
writer.WriteEndElement();
//
// ANX.Framework.Content.Pipeline.SomewhatImporter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=blah, ProcessorArch=MSIL
//
writer.WriteStartElement("References");
foreach (var reference in References)
{
writer.WriteStartElement("Reference");
writer.WriteValue(reference);
writer.WriteEndElement();
}
writer.WriteEndElement();
//
//
// A:\MyPicture.png
//
// True
//
//
//