本文整理汇总了C#中ParameterCollection.RemoveSource方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterCollection.RemoveSource方法的具体用法?C# ParameterCollection.RemoveSource怎么用?C# ParameterCollection.RemoveSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterCollection
的用法示例。
在下文中一共展示了ParameterCollection.RemoveSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCollections1
public void TestCollections1()
{
//
// => Initialize
//
// --------------- ---------------
// | P = 1,1,1 | (Root1) | P = 3,3,3 | (Root2)
// | V = 2,2,2 | | |
// --------------- ---------------
//
// ---------------
// | | (Child)
// | |
// ---------------
var root1Collection = new ParameterCollection("Root1");
var root2Collection = new ParameterCollection("Root2");
var childCollection = new ParameterCollection("Child");
var paramV = new ParameterKey<Vector3>("View");
var paramP = new ParameterKey<Vector3>("Proj");
root1Collection.Set(paramP, new Vector3(1, 1, 1));
root1Collection.Set(paramV, new Vector3(2, 2, 2));
root2Collection.Set(paramP, new Vector3(3, 3, 3));
//
// => Add source Roo1 and Root2 to Child
//
// --------------- ---------------
// | P = 1,1,1 | (Root1) | P = 3,3,3 | (Root2)
// | V = 2,2,2 | | |
// --------------- ---------------
// | /
// --------------- /
// | P = ^,^,^ | (Child) /
// | V = ^,^,^ |
// ---------------
// P = 3,3,3
// V = 2,2,2
childCollection.AddSources(root1Collection, root2Collection);
Assert.AreEqual(childCollection.Count, 2);
Assert.AreEqual(childCollection.Get(paramP), new Vector3(3, 3, 3));
Assert.AreEqual(childCollection.Get(paramV), new Vector3(2, 2, 2));
//
// => Add source Roo1 and Root2 to Child
//
// --------------- ---------------
// | P = 1,1,1 | (Root1) | | (Root2)
// | V = 2,2,2 | | V = 3,3,3 |
// --------------- ---------------
// | /
// --------------- /
// | P = ^,^,^ | (Child) /
// | V = ^,^,^ |
// ---------------
// P = 1,1,1
// V = 3,3,3
root2Collection.Remove(paramP);
root2Collection.Set(paramV, new Vector3(3,3,3));
Assert.AreEqual(childCollection.Count, 2);
Assert.AreEqual(childCollection.Get(paramP), new Vector3(1, 1, 1));
Assert.AreEqual(childCollection.Get(paramV), new Vector3(3, 3, 3));
//
// => Remove source Root1 for Child
//
// --------------- ---------------
// | P = 1,1,1 | (Root1) | | (Root2)
// | V = 2,2,2 | | V = 3,3,3 |
// --------------- ---------------
// /
// --------------- /
// | | (Child) /
// | V = ^,^,^ |
// ---------------
// V = 3,3,3
childCollection.RemoveSource(root1Collection);
Assert.AreEqual(childCollection.Count, 1);
Assert.AreEqual(childCollection.Get(paramV), new Vector3(3, 3, 3));
//
// => Inherit Root1 from Child
//
// --------------- ---------------
// | | (Child) ------| | (Root2)
// | V = ^,^,^ | | V = 3,3,3 |
// --------------- ---------------
// |
// ---------------
// | P = 1,1,1 | (Root1)
// | V = 2,2,2 |
// ---------------
root1Collection.AddSources(childCollection);
Assert.AreEqual(root1Collection.Count, 2);
Assert.AreEqual(root1Collection.Get(paramP), new Vector3(1, 1, 1));
Assert.AreEqual(root1Collection.Get(paramV), new Vector3(2, 2, 2));
}
示例2: TestCollectionsBasicValues
//.........这里部分代码省略.........
// ---------------
// | V = 1,1,1 | (Root)
// | P = 1,1,1 |
// ---------------
// |
// ---------------
// | V = ^,^,^ | (Child)
// | P = ^,^,^ |
// ---------------
var paramV = new ParameterKey<Vector3>("View");
var paramP = new ParameterKey<Vector3>("Proj");
rootCollection.Set(paramV, new Vector3(1, 1, 1));
rootCollection.Set(paramP, new Vector3(1, 1, 1));
// Verify collection.Count
Assert.AreEqual(childCollection.Count, 2);
// Verify collection.Contains
Assert.AreEqual(childCollection.ContainsKey(paramV), true);
Assert.AreEqual(childCollection.ContainsKey(paramP), true);
//
// => Set V in Root, Get from Child
//
// ---------------
// | V = 2,2,2 | (Root)
// | P = 1,1,1 |
// ---------------
// |
// ---------------
// | V = ^,^,^ | (Child)
// | P = ^,^,^ |
// ---------------
// Verify the Get and returned value
Assert.AreEqual(childCollection.Get(paramV), new Vector3(1, 1, 1));
rootCollection.Set(paramV, new Vector3(2,2,2));
Assert.AreEqual(childCollection.Get(paramV), new Vector3(2, 2, 2));
//
// => Remove P from Root
//
// ---------------
// | V = 2,2,2 | (Root)
// | |
// ---------------
// |
// ---------------
// | V = ^,^,^ | (Child)
// ---------------
rootCollection.Remove(paramP);
Assert.AreEqual(childCollection.Count, 1);
//
// => Overrides V in Child (3,3,3)
//
// ---------------
// | V = 2,2,2 | (Root)
// | |
// ---------------
// |
// ---------------
// | V = 3,3,3 | (Child)
// ---------------
childCollection.Set(paramV, new Vector3(3, 3, 3));
Assert.AreEqual(childCollection.Get(paramV), new Vector3(3, 3, 3));
Assert.AreEqual(rootCollection.Get(paramV), new Vector3(2, 2, 2));
//
// => Reset Key V on Child
//
// ---------------
// | V = 2,2,2 | (Root)
// | |
// ---------------
// |
// ---------------
// | V = ^,^,^ | (Child)
// ---------------
childCollection.Reset(paramV);
Assert.AreEqual(childCollection.Get(paramV), new Vector3(2, 2, 2));
Assert.AreEqual(rootCollection.Get(paramV), new Vector3(2, 2, 2));
// Check that we cannot dipose a collction used as a source
//Assert.Throws(typeof (InvalidOperationException), () => rootCollection.Release() );
//
// => Remove Root source from Child
//
// ---------------
// | V = 2,2,2 | (Root)
// | |
// ---------------
//
// ---------------
// | | (Child)
// ---------------
// Remove child using root and verify collection.Count
childCollection.RemoveSource(rootCollection);
Assert.AreEqual(childCollection.Count, 0);
}