#region Using Statements using System; using System.Collections.Generic; using System.Linq; using System.Text; using ANX.Framework.Content.Pipeline.Tasks; using System.Xml.Linq; #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 ProjectConverter.Platforms { public class AnxContentProjectConverter : Converter { private ContentProject sourceContentProject = null; public override string Name { get { return "content2xna"; } } public override string Postfix { get { return string.Empty; } } public override string TargetFileExtension { get { return ".contentproj"; } } public override bool WriteSourceProjectToDestination { get { return true; } } protected override void PreConvert() { this.sourceContentProject = ContentProject.Load(CurrentProject.FullSourcePath); } protected override void ConvertMainPropertyGroup(XElement element) { var rootNameSpaceNode = GetOrCreateNode(element, "RootNamespace"); rootNameSpaceNode.Value = sourceContentProject.ContentRoot; } protected override void ConvertProject(XElement element) { var itemGroupName = GetXName("ItemGroup"); var includeName = XName.Get("Include"); var referenceName = GetXName("Reference"); // // add build items // foreach (var buildItem in sourceContentProject.BuildItems) { XElement buildItemElement = new XElement(itemGroupName); var compileElement = GetOrCreateNode(buildItemElement, "Compile"); compileElement.SetAttributeValue(includeName, buildItem.SourceFilename); var nameElement = GetOrCreateNode(compileElement, "Name"); nameElement.Value = buildItem.AssetName; var importerElement = GetOrCreateNode(compileElement, "Importer"); importerElement.Value = buildItem.ImporterName; var processorElement = GetOrCreateNode(compileElement, "Processor"); processorElement.Value = buildItem.ProcessorName; foreach (var processorParameter in buildItem.ProcessorParameters) { var parameterElement = GetOrCreateNode(compileElement, "ProcessorParamters_" + processorParameter.Key); parameterElement.Value = processorParameter.Value.ToString(); } element.Add(buildItemElement); } // // add references // XElement referenceItemGroup = new XElement(itemGroupName); foreach (var reference in sourceContentProject.References) { var referenceElement = new XElement(referenceName); referenceElement.SetAttributeValue(includeName, reference); referenceItemGroup.Add(referenceElement); } element.Add(referenceItemGroup); } protected override void PostConvert() { } public override string ProjectFileTemplate { get { return @" {FA6E229D-4504-47B1-8A23-2D3FCC13F778} {96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Debug x86 Library Properties v4.0 v4.0 bin\$(Platform)\$(Configuration) "; } } } }