本文整理汇总了C#中Sce.Atf.Dom.ChildInfo类的典型用法代码示例。如果您正苦于以下问题:C# ChildInfo类的具体用法?C# ChildInfo怎么用?C# ChildInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChildInfo类属于Sce.Atf.Dom命名空间,在下文中一共展示了ChildInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestValidate
public void TestValidate()
{
DomNodeType childType = new DomNodeType("child");
DomNodeType parentType = new DomNodeType("parent");
ChildInfo childInfo = new ChildInfo("child", childType, true);
parentType.Define(childInfo);
DomNode parent = new DomNode(parentType);
IList<DomNode> childList = parent.GetChildList(childInfo);
DomNode child1 = new DomNode(childType);
DomNode child2 = new DomNode(childType);
DomNode child3 = new DomNode(childType);
ChildCountRule test = new ChildCountRule(1, 2);
// 0 children. Not valid.
Assert.False(test.Validate(parent, null, childInfo));
// 1 child. Valid.
childList.Add(child1);
Assert.True(test.Validate(parent, null, childInfo));
// 2 children. Valid.
childList.Add(child2);
Assert.True(test.Validate(parent, null, childInfo));
// 3 children. Not valid.
childList.Add(child3);
Assert.False(test.Validate(parent, null, childInfo));
// 0 children. Not valid.
childList.Clear();
Assert.False(test.Validate(parent, null, childInfo));
}
示例2: TestConstructor
public void TestConstructor()
{
DomNodeType type = new DomNodeType("child");
ChildInfo info = new ChildInfo("test", type);
DomNode test = new DomNode(type, info);
Assert.AreSame(test.Type, type);
Assert.AreSame(test.ChildInfo, info);
}
示例3: Slot
public Slot(DomNode owner, ChildInfo childInfo)
{
if (owner == null || childInfo == null)
throw new ArgumentNullException();
m_owner = owner;
m_childInfo = childInfo;
}
示例4: TestListConstructor
public void TestListConstructor()
{
DomNodeType type = new DomNodeType("child");
ChildInfo test = new ChildInfo("test", type, true);
Assert.AreEqual(test.Name, "test");
Assert.AreEqual(test.Type, type);
Assert.True(test.IsList);
}
示例5: ChildPropertyDescriptor
/// <summary>
/// Constructor</summary>
/// <param name="name">Property's display name</param>
/// <param name="childInfo">ChildInfo identifying child</param>
/// <param name="category">Category of property</param>
/// <param name="description">Description of property</param>
/// <param name="isReadOnly">Whether or not property is read-only</param>
public ChildPropertyDescriptor(
string name,
ChildInfo childInfo,
string category,
string description,
bool isReadOnly)
: this(name, childInfo, category, description, isReadOnly, null, null)
{
}
示例6: TestEquality
public void TestEquality()
{
var attrType1 = new AttributeType("xkcd", typeof(string));
var attrInfo1 = new AttributeInfo("xkcd", attrType1);
var domNodeType = new DomNodeType("WebComic", DomNodeType.BaseOfAllTypes);
var childInfo1 = new ChildInfo("xkcd", domNodeType);
attrInfo1.DefaultValue = "Firefly";
var desc1 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
int originalHashCode = desc1.GetHashCode();
// test if two identically created property descriptors compare as being equal
var desc2 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
Assert.AreEqual(desc1, desc2);
Assert.AreEqual(desc1.GetHashCode(), desc2.GetHashCode());
// test category being different; oddly, although I think they should not be considered equal,
// the .Net PropertyDescriptor ignores the difference in category name. So, I'm guessing that
// the AttributePropertyDescriptor should behave the same as PropertyDescriptor.
var desc3 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 2", "A commonly used word or phrase in the xkcd comic", true);
Assert.AreEqual(desc1, desc3);
Assert.AreEqual(desc1.GetHashCode(), desc3.GetHashCode());
// test description being different; similarly here, the .Net PropertyDescriptor doesn't care.
var desc4 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 1", "slightly different description", true);
Assert.AreEqual(desc1, desc4);
Assert.AreEqual(desc1.GetHashCode(), desc4.GetHashCode());
// test readOnly being different; ditto for read-only flag!
var desc5 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", false);
Assert.AreEqual(desc1, desc5);
Assert.AreEqual(desc1.GetHashCode(), desc5.GetHashCode());
// test that the hash code hasn't changed after using the AttributeInfo
var attrInfo2 = new AttributeInfo("xkcd", attrType1);
domNodeType.Define(attrInfo2);
Assert.AreEqual(desc1.GetHashCode(), originalHashCode);
// test that the hash code hasn't changed after creating a derived DomNodeType
var derivedDomNodeType = new DomNodeType("ScientificWebComic", domNodeType);
var derivedAttrInfo = new AttributeInfo("xkcd", attrType1);
var derivedChildInfo = new ChildInfo("xkcd", derivedDomNodeType);
derivedDomNodeType.Define(derivedAttrInfo);
Assert.AreEqual(desc1.GetHashCode(), originalHashCode);
// test that an AttributeInfo used in a derived DomNodeType doesn't change equality or hash code
var desc6 = new ChildAttributePropertyDescriptor(
"xkcd", derivedAttrInfo, derivedChildInfo, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
Assert.AreEqual(desc1, desc6);
Assert.AreEqual(desc1.GetHashCode(), desc6.GetHashCode());
}
示例7: ChildEventArgs
/// <summary>
/// Constructor</summary>
/// <param name="parent">Node's parent</param>
/// <param name="childInfo">Metadata for child</param>
/// <param name="child">Child node</param>
/// <param name="index">Node's index in parent</param>
public ChildEventArgs(
DomNode parent,
ChildInfo childInfo,
DomNode child,
int index)
{
Parent = parent;
ChildInfo = childInfo;
Child = child;
Index = index;
}
示例8: ChildAttributeCollectionPropertyDescriptor
/// <summary>
/// Constructor</summary>
/// <param name="name">Value's display name</param>
/// <param name="attributeInfos">An array of meta attributes in the collection</param>
/// <param name="childInfo">Meta element identifying child that owns the attributes</param>
/// <param name="category">Category of property</param>
/// <param name="description">Description of property</param>
/// <param name="isReadOnly">Whether or not property is read-only</param>
public ChildAttributeCollectionPropertyDescriptor(
string name,
AttributeInfo[] attributeInfos,
ChildInfo childInfo,
string category,
string description,
bool isReadOnly)
: this(name, attributeInfos, childInfo, category, description, isReadOnly, null, null)
{
}
示例9: TestChildParent
public void TestChildParent()
{
DomNodeType type = new DomNodeType("type");
ChildInfo childInfo = new ChildInfo("child", type, true);
type.Define(childInfo);
DomNode child = new DomNode(type);
DomNode parent = new DomNode(type);
parent.GetChildList(childInfo).Add(child);
Assert.AreSame(child.Parent, parent);
}
示例10: Add2DPointProperty
/// <summary>
/// Adds OSC addresses (one for the x-coordinate and one for the y-coordinate) for a list
/// of DOM children that have attributes that are arrays of floats. Each array of floats
/// represents a 2D point where the first float is the x coordinate and the second float
/// is the y coordinate.</summary>
/// <param name="childInfo">The child info which defines the list of children of a selected DomNode</param>
/// <param name="childAttributeDesc">The attribute on each child that defines the array of floats</param>
/// <param name="oscAddress">The base OSC address to use. "/x" and "/y" will be appended for
/// the x-coordinate array and the y-coordinate array, which is how Lemur sends and receives
/// 2-D point arrays.</param>
/// <returns>The base OSC address, with possible changes to make it legal.</returns>
public string Add2DPointProperty(ChildInfo childInfo, AttributePropertyDescriptor childAttributeDesc, string oscAddress)
{
oscAddress = OscServices.FixPropertyAddress(oscAddress);
var xCoordDesc = new ChildListFloatingPointArrayDesc(childInfo, childAttributeDesc, 0);
AddPropertyAddress(xCoordDesc, oscAddress + "/x");
var yCoordDesc = new ChildListFloatingPointArrayDesc(childInfo, childAttributeDesc, 1);
AddPropertyAddress(yCoordDesc, oscAddress + "/y");
return oscAddress;
}
示例11: ChildAttributePropertyDescriptor
/// <summary>
/// Constructor</summary>
/// <param name="name">Value's display name</param>
/// <param name="attributeInfo">Attribute metadata</param>
/// <param name="childInfo">ChildInfo identifying child</param>
/// <param name="category">Category of property</param>
/// <param name="description">Description of property</param>
/// <param name="isReadOnly">Whether or not property is read-only</param>
/// <param name="editor">The editor used to edit the property</param>
public ChildAttributePropertyDescriptor(
string name,
AttributeInfo attributeInfo,
ChildInfo childInfo,
string category,
string description,
bool isReadOnly,
object editor)
: this(name, attributeInfo, childInfo, category, description, isReadOnly, editor, null)
{
}
示例12: Validate
/// <summary>
/// Checks that the parent DomNode has the correct # of children of the given type</summary>
/// <param name="parent">Parent DOM node</param>
/// <param name="child">Child DOM node; ignored</param>
/// <param name="childInfo">Child relationship info</param>
/// <returns>True, iff 'parent' has a valid number of children of the type associated
/// with 'childInfo'</returns>
public override bool Validate(DomNode parent, DomNode child, ChildInfo childInfo)
{
if (childInfo.IsList)
{
IList<DomNode> childList = parent.GetChildList(childInfo);
int count = childList.Count;
return
count >= m_min &&
count <= m_max;
}
// singleton child references can always be set
return true;
}
示例13: TestDescendantGetRoot
public void TestDescendantGetRoot()
{
DomNodeType type = new DomNodeType("type");
ChildInfo childInfo = new ChildInfo("child", type, true);
type.Define(childInfo);
DomNode child = new DomNode(type);
DomNode parent = new DomNode(type);
DomNode grandparent = new DomNode(type);
parent.GetChildList(childInfo).Add(child);
grandparent.GetChildList(childInfo).Add(parent);
Assert.AreSame(child.GetRoot(), grandparent);
}
示例14: TestValidation
public void TestValidation()
{
DomNodeType type = new DomNodeType("child");
ChildInfo test = new ChildInfo("test", type);
CollectionAssert.IsEmpty(test.Rules);
var rule = new SimpleChildRule();
test.AddRule(rule);
Utilities.TestSequenceEqual(test.Rules, rule);
Assert.True(test.Validate(null, null));
Assert.True(rule.Validated);
}
示例15: TestGetPath
public void TestGetPath()
{
DomNodeType type = new DomNodeType("type");
ChildInfo childInfo = new ChildInfo("child", type, true);
type.Define(childInfo);
DomNode child = new DomNode(type);
DomNode parent = new DomNode(type);
DomNode grandparent = new DomNode(type);
parent.GetChildList(childInfo).Add(child);
grandparent.GetChildList(childInfo).Add(parent);
Utilities.TestSequenceEqual(child.GetPath(), grandparent, parent, child);
Utilities.TestSequenceEqual(parent.GetPath(), grandparent, parent);
Utilities.TestSequenceEqual(grandparent.GetPath(), grandparent);
}