1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Microsoft.Xna.Framework.Graphics
{
public class EffectTechniqueCollection : IEnumerable<EffectTechnique>
{
// Modified to be a list instead of dictionary object because a dictionary does not guarantee
// the order is kept as it is a hash key.
internal List <EffectTechnique> _techniques = new List<EffectTechnique> ();
//Dictionary<string, EffectTechnique> _techniques = new Dictionary<string, EffectTechnique>();
public EffectTechnique this[int index]
{
get { return _techniques [index]; }
set { _techniques [index] = value; }
}
public EffectTechnique this[string name]
{
get {
foreach (EffectTechnique technique in _techniques) {
if (technique.Name == name)
return technique;
}
return null;
}
set {
var technique = this[name];
if (technique != null)
technique = value;
else
_techniques.Add(value);
}
}
public IEnumerator<EffectTechnique> GetEnumerator()
{
return _techniques.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return _techniques.GetEnumerator();
}
}
}
|