added custom parameters to ContentPipeline BuildItem
This commit is contained in:
parent
c955ca882a
commit
016694c770
@ -172,7 +172,7 @@
|
|||||||
<Compile Include="TargetPlatform.cs" />
|
<Compile Include="TargetPlatform.cs" />
|
||||||
<Compile Include="Tasks\BuildContent.cs" />
|
<Compile Include="Tasks\BuildContent.cs" />
|
||||||
<Compile Include="Tasks\BuildItem.cs" />
|
<Compile Include="Tasks\BuildItem.cs" />
|
||||||
<Compile Include="Tasks\BuildRequest.cs" />
|
<None Include="Tasks\BuildRequest.cs" />
|
||||||
<Compile Include="Tasks\ImporterManager.cs" />
|
<Compile Include="Tasks\ImporterManager.cs" />
|
||||||
<Compile Include="Tasks\ProcessorManager.cs" />
|
<Compile Include="Tasks\ProcessorManager.cs" />
|
||||||
<Compile Include="VideoContent.cs" />
|
<Compile Include="VideoContent.cs" />
|
||||||
|
@ -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
|
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()
|
public NamedValueDictionary()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
get;
|
get
|
||||||
private set;
|
{
|
||||||
|
return this.keyValues.Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public T this[string key]
|
public T this[string key]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues[key];
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
this.keyValues[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +46,7 @@ namespace ANX.Framework.Content.Pipeline
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues.Keys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +54,7 @@ namespace ANX.Framework.Content.Pipeline
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues.Values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,88 +62,91 @@ namespace ANX.Framework.Content.Pipeline
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return typeof(T);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(string key, T value)
|
public void Add(string key, T value)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
this.keyValues.Add(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
this.keyValues.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ContainsKey(string key)
|
public bool ContainsKey(string key)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator<KeyValuePair<string, T>> GetEnumerator()
|
public IEnumerator<KeyValuePair<string, T>> GetEnumerator()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(string key)
|
public bool Remove(string key)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetValue(string key, out T value)
|
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)
|
protected virtual void AddItem(string key, T value)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
this.keyValues.Add(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ClearItems()
|
protected virtual void ClearItems()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
this.keyValues.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool RemoveItem(string key)
|
protected virtual bool RemoveItem(string key)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void SetItem(string key, T value)
|
protected virtual void SetItem(string key, T value)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
this.keyValues[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<string, T>>.IsReadOnly
|
bool ICollection<KeyValuePair<string, T>>.IsReadOnly
|
||||||
{
|
{
|
||||||
get { throw new NotImplementedException(); }
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollection<KeyValuePair<string, T>>.Add(KeyValuePair<string, T> item)
|
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)
|
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)
|
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()
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<string, T>>.Remove(KeyValuePair<string, T> item)
|
bool ICollection<KeyValuePair<string, T>>.Remove(KeyValuePair<string, T> item)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return this.keyValues.Remove(item.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,19 +16,21 @@ namespace ANX.Framework.Content.Pipeline
|
|||||||
{
|
{
|
||||||
public OpaqueDataDictionary()
|
public OpaqueDataDictionary()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
// nothing to do
|
||||||
}
|
|
||||||
|
|
||||||
public string GetContentAsXml()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T GetValue<T>(string key, T defaultValue)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,9 +104,9 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
{
|
{
|
||||||
var importedObject = ImportAsset(buildItem);
|
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);
|
var buildedItem = Process(buildItem, importedObject);
|
||||||
@ -117,21 +117,21 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
|
|
||||||
private object ImportAsset(BuildItem item)
|
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);
|
ContentImporterContext context = new AnxContentImporterContext(this, item, BuildLogger);
|
||||||
BuildLogger.LogMessage("building {0} of type {1}", new object[]
|
BuildLogger.LogMessage("building {0} of type {1}", new object[]
|
||||||
{
|
{
|
||||||
item.BuildRequest.SourceFilename,
|
item.SourceFilename,
|
||||||
instance.GetType()
|
instance.GetType()
|
||||||
});
|
});
|
||||||
return instance.Import(item.BuildRequest.SourceFilename, context);
|
return instance.Import(item.SourceFilename, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private object Process(BuildItem item, object importedObject)
|
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, "");
|
ContentProcessorContext context = new AnxContentProcessorContext(item, BuildLogger, TargetPlatform, TargetProfile, "");
|
||||||
context.OutputDirectory = OutputDirectory;
|
context.OutputDirectory = OutputDirectory;
|
||||||
context.OutputFilename = item.OutputFilename;
|
context.OutputFilename = item.OutputFilename;
|
||||||
|
@ -14,7 +14,27 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
{
|
{
|
||||||
public class BuildItem
|
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;
|
get;
|
||||||
set;
|
set;
|
||||||
|
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -30,12 +30,11 @@ namespace ContentBuilder
|
|||||||
if (!arg.StartsWith("/") && !arg.StartsWith("-"))
|
if (!arg.StartsWith("/") && !arg.StartsWith("-"))
|
||||||
{
|
{
|
||||||
BuildItem buildItem = new BuildItem();
|
BuildItem buildItem = new BuildItem();
|
||||||
buildItem.BuildRequest = new BuildRequest();
|
buildItem.ImporterName = ImporterManager.GuessImporterByFileExtension(arg);
|
||||||
buildItem.BuildRequest.ImporterName = ImporterManager.GuessImporterByFileExtension(arg);
|
|
||||||
//TODO: set configured processor name
|
//TODO: set configured processor name
|
||||||
buildItem.BuildRequest.SourceFilename = arg;
|
buildItem.SourceFilename = arg;
|
||||||
buildItem.BuildRequest.AssetName = System.IO.Path.GetFileNameWithoutExtension(arg);
|
buildItem.AssetName = System.IO.Path.GetFileNameWithoutExtension(arg);
|
||||||
buildItem.OutputFilename = String.Format("{0}.xnb", buildItem.BuildRequest.AssetName);
|
buildItem.OutputFilename = String.Format("{0}.xnb", buildItem.AssetName);
|
||||||
|
|
||||||
itemsToBuild.Add(buildItem);
|
itemsToBuild.Add(buildItem);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user