#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.Graphics
{
public class MaterialContent : ContentItem
{
public MaterialContent()
{
Textures = new TextureReferenceDictionary();
}
public TextureReferenceDictionary Textures
{
get;
private set;
}
//description from msdn
///
/// Gets a reference type from the collection.
///
/// Type of the related opaque data.
/// Key of the property being retrieved.
/// The related opaque data.
protected T GetReferenceTypeProperty(string key) where T : class
{
object result;
if (this.OpaqueData.TryGetValue(key, out result) && result is T)
return (T)result;
else
return null;
}
///
/// Gets a value from the collection.
///
/// Key of the texture being retrieved.
/// Reference to a texture from the collection.
protected ExternalReference GetTexture(String key)
{
ExternalReference result;
if (Textures.TryGetValue(key, out result))
return result;
else
return null;
}
///
/// Gets a value type from the collection.
///
/// Type of the value being retrieved.
/// Key of the value type being retrieved.
/// Index of the value type beng retrieved.
protected Nullable GetValueTypeProperty(string key) where T : struct
{
object result;
if (this.OpaqueData.TryGetValue(key, out result) && result is T)
return (T?)result;
else
return null;
}
///
/// Sets a value in the contained object.
/// If null is passed, the value is removed.
///
/// Type of the element being set.
/// Name of the key being modified.
/// Value being set.
protected void SetProperty(string key, T value)
{
if (value == null)
this.OpaqueData.Remove(key);
else
this.OpaqueData[key] = value;
}
///
/// Sets a value in the contained TextureReferenceDictionary object.
/// If null is passed, the value is removed.
///
///
/// The value differs depending on the type of attached dictionary.
///
/// If attached to a dictionary (which becomes a object at run time),
/// the value for the Texture key is used as the texture for the runtime object. Other keys are ignored.
///
/// If attached to a dictionary, key names are the texture names used by the effect. These names are dependent upon the author of the effect object.
///
/// Name of the key being modified.
/// Value being set.
protected void SetTexture(String key, ExternalReference value)
{
if (value == null)
Textures.Remove(key);
else
Textures[key] = value;
}
}
}