added custom parameters to ContentPipeline BuildItem

This commit is contained in:
Glatzemann 2012-08-27 05:33:46 +00:00
parent c955ca882a
commit 016694c770
7 changed files with 75 additions and 70 deletions

View File

@ -172,7 +172,7 @@
<Compile Include="TargetPlatform.cs" />
<Compile Include="Tasks\BuildContent.cs" />
<Compile Include="Tasks\BuildItem.cs" />
<Compile Include="Tasks\BuildRequest.cs" />
<None Include="Tasks\BuildRequest.cs" />
<Compile Include="Tasks\ImporterManager.cs" />
<Compile Include="Tasks\ProcessorManager.cs" />
<Compile Include="VideoContent.cs" />

View File

@ -15,26 +15,30 @@ namespace ANX.Framework.Content.Pipeline
{
public class NamedValueDictionary<T> : IDictionary<string, T>, ICollection<KeyValuePair<string, T>>, IEnumerable<KeyValuePair<string, T>>, IEnumerable
{
private Dictionary<string, T> keyValues = new Dictionary<string, T>();
public NamedValueDictionary()
{
throw new NotImplementedException();
// nothing to do
}
public int Count
{
get;
private set;
get
{
return this.keyValues.Count;
}
}
public T this[string key]
{
get
{
throw new NotImplementedException();
return this.keyValues[key];
}
set
{
throw new NotImplementedException();
this.keyValues[key] = value;
}
}
@ -42,7 +46,7 @@ namespace ANX.Framework.Content.Pipeline
{
get
{
throw new NotImplementedException();
return this.keyValues.Keys;
}
}
@ -50,7 +54,7 @@ namespace ANX.Framework.Content.Pipeline
{
get
{
throw new NotImplementedException();
return this.keyValues.Values;
}
}
@ -58,88 +62,91 @@ namespace ANX.Framework.Content.Pipeline
{
get
{
throw new NotImplementedException();
return typeof(T);
}
}
public void Add(string key, T value)
{
throw new NotImplementedException();
this.keyValues.Add(key, value);
}
public void Clear()
{
throw new NotImplementedException();
this.keyValues.Clear();
}
public bool ContainsKey(string key)
{
throw new NotImplementedException();
return this.keyValues.ContainsKey(key);
}
public IEnumerator<KeyValuePair<string, T>> GetEnumerator()
{
throw new NotImplementedException();
return this.keyValues.GetEnumerator();
}
public bool Remove(string key)
{
throw new NotImplementedException();
return this.keyValues.Remove(key);
}
public bool TryGetValue(string key, out T value)
{
throw new NotImplementedException();
return this.keyValues.TryGetValue(key, out value);
}
protected virtual void AddItem(string key, T value)
{
throw new NotImplementedException();
this.keyValues.Add(key, value);
}
protected virtual void ClearItems()
{
throw new NotImplementedException();
this.keyValues.Clear();
}
protected virtual bool RemoveItem(string key)
{
throw new NotImplementedException();
return this.keyValues.Remove(key);
}
protected virtual void SetItem(string key, T value)
{
throw new NotImplementedException();
this.keyValues[key] = value;
}
bool ICollection<KeyValuePair<string, T>>.IsReadOnly
{
get { throw new NotImplementedException(); }
get
{
return false;
}
}
void ICollection<KeyValuePair<string, T>>.Add(KeyValuePair<string, T> item)
{
throw new NotImplementedException();
this.keyValues.Add(item.Key, item.Value);
}
bool ICollection<KeyValuePair<string, T>>.Contains(KeyValuePair<string, T> item)
{
throw new NotImplementedException();
return this.keyValues.ContainsKey(item.Key);
}
void ICollection<KeyValuePair<string, T>>.CopyTo(KeyValuePair<string, T>[] array, int arrayIndex)
{
throw new NotImplementedException();
((ICollection<KeyValuePair<string, T>>)this.keyValues).CopyTo(array, arrayIndex);
}
IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
return this.keyValues.GetEnumerator();
}
bool ICollection<KeyValuePair<string, T>>.Remove(KeyValuePair<string, T> item)
{
throw new NotImplementedException();
return this.keyValues.Remove(item.Key);
}
}
}

View File

@ -16,19 +16,21 @@ namespace ANX.Framework.Content.Pipeline
{
public OpaqueDataDictionary()
{
throw new NotImplementedException();
}
public string GetContentAsXml()
{
throw new NotImplementedException();
// nothing to do
}
public T GetValue<T>(string key, T defaultValue)
{
throw new NotImplementedException();
object retValue = null;
if (base.TryGetValue(key, out retValue))
{
if (retValue is T)
{
return (T)retValue;
}
}
return defaultValue;
}
}
}

View File

@ -104,9 +104,9 @@ namespace ANX.Framework.Content.Pipeline.Tasks
{
var importedObject = ImportAsset(buildItem);
if (String.IsNullOrEmpty(buildItem.BuildRequest.ProcessorName))
if (String.IsNullOrEmpty(buildItem.ProcessorName))
{
buildItem.BuildRequest.ProcessorName = ProcessorManager.GetProcessorForType(importedObject.GetType());
buildItem.ProcessorName = ProcessorManager.GetProcessorForType(importedObject.GetType());
}
var buildedItem = Process(buildItem, importedObject);
@ -117,21 +117,21 @@ namespace ANX.Framework.Content.Pipeline.Tasks
private object ImportAsset(BuildItem item)
{
IContentImporter instance = this.ImporterManager.GetInstance(item.BuildRequest.ImporterName);
IContentImporter instance = this.ImporterManager.GetInstance(item.ImporterName);
ContentImporterContext context = new AnxContentImporterContext(this, item, BuildLogger);
BuildLogger.LogMessage("building {0} of type {1}", new object[]
{
item.BuildRequest.SourceFilename,
item.SourceFilename,
instance.GetType()
});
return instance.Import(item.BuildRequest.SourceFilename, context);
return instance.Import(item.SourceFilename, context);
}
private object Process(BuildItem item, object importedObject)
{
if (String.IsNullOrEmpty(item.BuildRequest.ProcessorName) == false)
if (String.IsNullOrEmpty(item.ProcessorName) == false)
{
IContentProcessor instance = this.ProcessorManager.GetInstance(item.BuildRequest.ProcessorName);
IContentProcessor instance = this.ProcessorManager.GetInstance(item.ProcessorName);
ContentProcessorContext context = new AnxContentProcessorContext(item, BuildLogger, TargetPlatform, TargetProfile, "");
context.OutputDirectory = OutputDirectory;
context.OutputFilename = item.OutputFilename;

View File

@ -14,7 +14,27 @@ namespace ANX.Framework.Content.Pipeline.Tasks
{
public class BuildItem
{
public BuildRequest BuildRequest
public readonly OpaqueDataDictionary ProcessorParameters = new OpaqueDataDictionary();
public String SourceFilename
{
get;
set;
}
public String AssetName
{
get;
set;
}
public string ImporterName
{
get;
set;
}
public string ProcessorName
{
get;
set;

View File

@ -1,23 +0,0 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#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
{
public class BuildRequest
{
public String SourceFilename;
public String AssetName;
public string ImporterName;
public string ProcessorName;
}
}

View File

@ -30,12 +30,11 @@ namespace ContentBuilder
if (!arg.StartsWith("/") && !arg.StartsWith("-"))
{
BuildItem buildItem = new BuildItem();
buildItem.BuildRequest = new BuildRequest();
buildItem.BuildRequest.ImporterName = ImporterManager.GuessImporterByFileExtension(arg);
buildItem.ImporterName = ImporterManager.GuessImporterByFileExtension(arg);
//TODO: set configured processor name
buildItem.BuildRequest.SourceFilename = arg;
buildItem.BuildRequest.AssetName = System.IO.Path.GetFileNameWithoutExtension(arg);
buildItem.OutputFilename = String.Format("{0}.xnb", buildItem.BuildRequest.AssetName);
buildItem.SourceFilename = arg;
buildItem.AssetName = System.IO.Path.GetFileNameWithoutExtension(arg);
buildItem.OutputFilename = String.Format("{0}.xnb", buildItem.AssetName);
itemsToBuild.Add(buildItem);
}