本文整理汇总了C#中DomNode.InitializeExtensions方法的典型用法代码示例。如果您正苦于以下问题:C# DomNode.InitializeExtensions方法的具体用法?C# DomNode.InitializeExtensions怎么用?C# DomNode.InitializeExtensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomNode
的用法示例。
在下文中一共展示了DomNode.InitializeExtensions方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDuplicateNames
// Tests http://tracker.ship.scea.com/jira/browse/WWSATF-1370
// Test adding two types of extensions that have the same Name but different FullName.
public void TestDuplicateNames()
{
var domType = new DomNodeType("domType");
var extension = new ExtensionInfo<TestExtensionInfo>();
domType.Define(extension);
var domDerivedType = new DomNodeType("domDerivedType", domType);
var anotherExtension = new ExtensionInfo<AnotherName.TestExtensionInfo>();
domDerivedType.Define(anotherExtension);
var domNode = new DomNode(domDerivedType);
domNode.InitializeExtensions();
Assert.IsTrue(domNode.GetExtension(extension).GetType() == typeof(TestExtensionInfo));
Assert.IsTrue(domNode.GetExtension(anotherExtension).GetType() == typeof(AnotherName.TestExtensionInfo));
ExtensionInfo getInfo = domType.GetExtensionInfo("UnitTests.Atf.Dom.TestExtensionInfo");
Assert.IsNotNull(getInfo);
Assert.AreEqual(getInfo, extension);
getInfo = domDerivedType.GetExtensionInfo("UnitTests.Atf.Dom.TestExtensionInfo");
Assert.IsNotNull(getInfo);
Assert.AreEqual(getInfo, extension);
ExtensionInfo anotherGetInfo = domDerivedType.GetExtensionInfo("UnitTests.Atf.Dom.AnotherName.TestExtensionInfo");
Assert.IsNotNull(anotherGetInfo);
Assert.AreEqual(anotherGetInfo, anotherExtension);
}
示例2: DomNode
/// <summary>
/// Finish MEF intialization for the component by creating DomNode tree for application data.</summary>
void IInitializable.Initialize()
{
m_mainform.Shown += (sender, e) =>
{
// create root node.
var rootNode = new DomNode(Schema.gameType.Type, Schema.gameRootElement);
rootNode.SetAttribute(Schema.gameType.nameAttribute, "Game");
// create Orc game object and add it to rootNode.
var orc = CreateOrc();
rootNode.GetChildList(Schema.gameType.gameObjectChild).Add(orc);
// add a child Orc.
var orcChildList = orc.GetChildList(Schema.orcType.orcChild);
orcChildList.Add(CreateOrc("Child Orc1"));
rootNode.InitializeExtensions();
var edContext = rootNode.Cast<GameEditingContext>();
edContext.Set(orc);
// set active context and select orc object.
m_contextRegistry.ActiveContext = rootNode;
};
}
示例3: Create
public static PrefabInstance Create(IPrefab prefab)
{
DomNode instNode = new DomNode(Schema.prefabInstanceType.Type);
PrefabInstance inst = instNode.As<PrefabInstance>();
inst.m_prefab = prefab;
instNode.InitializeExtensions();
inst.Resolve(null);
return inst;
}
示例4: Create
public static TerrainGob Create(string name, string hmPath, float cellSize)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullException(name);
if (!File.Exists(hmPath))
throw new ArgumentException(hmPath + " does not exist");
Uri ur = new Uri(hmPath);
DomNode terrainNode = new DomNode(Schema.terrainGobType.Type);
terrainNode.SetAttribute(Schema.terrainGobType.cellSizeAttribute, cellSize);
terrainNode.SetAttribute(Schema.terrainGobType.heightMapAttribute, ur);
terrainNode.InitializeExtensions();
TerrainGob terrain = terrainNode.As<TerrainGob>();
terrain.Name = name;
return terrain;
}
示例5: TestDataValidator
public TestDataValidator()
{
m_childType = new DomNodeType("child");
m_parentType = new DomNodeType("parent");
m_parentType.Define(new ExtensionInfo<ValidationContext>());
m_parentType.Define(new ExtensionInfo<DataValidator>());
m_childCountRule = new ChildCountRule(2, 3);
m_childInfo = new ChildInfo("child", m_childType, true);
m_parentType.Define(m_childInfo);
m_childInfo.AddRule(m_childCountRule);
m_parent = new DomNode(m_parentType);
m_parent.InitializeExtensions();
m_validationContext = m_parent.As<ValidationContext>();
m_child1 = new DomNode(m_childType);
m_child2 = new DomNode(m_childType);
m_child3 = new DomNode(m_childType);
m_child4 = new DomNode(m_childType);
}
示例6: TestMoveDomNode
public void TestMoveDomNode()
{
var root = new DomNode(RootType.Type, RootElement);
root.InitializeExtensions();
var folderChild1 = new DomNode(FolderType.Type);
var folderChild2 = new DomNode(FolderType.Type);
var itemChild1 = new DomNode(ItemType.Type);
var itemChild2 = new DomNode(ItemType.Type);
var validationContext = root.As<ValidationContext>();
// Set up the tree:
// root
// folder
// item
// folder1
// item
validationContext.RaiseBeginning();
root.SetAttribute(RootType.NameAttribute, "root");
itemChild1.SetAttribute(ItemType.NameAttribute, "item");
itemChild2.SetAttribute(ItemType.NameAttribute, "item");
folderChild1.SetAttribute(FolderType.NameAttribute, "folder");
folderChild2.SetAttribute(FolderType.NameAttribute, "folder");
folderChild1.GetChildList(FolderType.ItemChild).Add(itemChild1);
folderChild2.GetChildList(FolderType.ItemChild).Add(itemChild2);
root.GetChildList(RootType.FolderChild).Add(folderChild1);
root.GetChildList(RootType.FolderChild).Add(folderChild2);
// renames all folders and items with unique paths
validationContext.RaiseEnding();
validationContext.RaiseEnded();
// Move item from first folder to second folder
// root
// folder
// folder1
// item
// item1
validationContext.RaiseBeginning();
itemChild1.RemoveFromParent();
folderChild2.GetChildList(FolderType.ItemChild).Add(itemChild1);
validationContext.RaiseEnding();
validationContext.RaiseEnded();
Assert.DoesNotThrow(() => ValidateSubtree(folderChild2));
// Make sure that the existing child wasn't renamed. Only the moved child should be renamed.
Assert.True((string)itemChild2.GetAttribute(ItemType.NameAttribute) == "item");
// Rename 'item_1' to 'item'.
validationContext.RaiseBeginning();
itemChild1.SetAttribute(ItemType.NameAttribute, "item");
validationContext.RaiseEnding();
validationContext.RaiseEnded();
Assert.DoesNotThrow(() => ValidateSubtree(folderChild2));
// Make sure that the existing child wasn't renamed. Only the moved child should be renamed.
Assert.True((string)itemChild2.GetAttribute(ItemType.NameAttribute) == "item");
// Rename the root.
validationContext.RaiseBeginning();
root.SetAttribute(RootType.NameAttribute, "new_root");
validationContext.RaiseEnding();
validationContext.RaiseEnded();
Assert.DoesNotThrow(() => ValidateSubtree(root));
Assert.True((string)root.GetAttribute(RootType.NameAttribute) == "new_root");
}
示例7: Create
public static DecorationMap Create(Uri maskuri)
{
DomNode node = new DomNode(Schema.decorationMapType.Type);
node.SetAttribute(Schema.decorationMapType.maskAttribute, maskuri);
node.InitializeExtensions();
DecorationMap map = node.As<DecorationMap>();
map.Name = "DecorationMap";
return map;
}
示例8: Clone
/// <summary>
/// Clones this control point</summary>
/// <returns>Cloned control point</returns>
public IControlPoint Clone()
{
DomNode node = new DomNode(UISchema.controlPointType.Type);
// clone local attributes
foreach (AttributeInfo attributeInfo in DomNode.Type.Attributes)
{
object value = DomNode.GetLocalAttribute(attributeInfo);
if (value != null)
node.SetAttribute(attributeInfo, attributeInfo.Type.Clone(value));
}
node.InitializeExtensions();
return node.As<IControlPoint>();
}
示例9: CreateControlPoint
/// <summary>
/// Creates a control point</summary>
/// <returns>Control point</returns>
public IControlPoint CreateControlPoint()
{
DomNode node = new DomNode(UISchema.controlPointType.Type);
node.InitializeExtensions();
IControlPoint cpt = node.As<IControlPoint>();
cpt.TangentInType = CurveTangentTypes.Spline;
cpt.TangentIn = new Vec2F(0.5f, 0.5f);
cpt.TangentOutType = CurveTangentTypes.Spline;
cpt.TangentOut = new Vec2F(0.5f, 0.5f);
return cpt;
}
示例10: CreateControlPoint
/// <summary>
/// Creates a control point</summary>
/// <returns>Control point</returns>
public IControlPoint CreateControlPoint()
{
DomNode node = new DomNode(Schema.controlPointType.Type);
node.InitializeExtensions();
IControlPoint cpt = node.As<IControlPoint>();
cpt.Name = "ControlPoint";
return cpt;
}
示例11: OpenUntitled
public static XLEPlacementDocument OpenUntitled()
{
var rootNode = new DomNode(Schema.placementsDocumentType.Type, Schema.placementsDocumentRootElement);
var doc = rootNode.As<XLEPlacementDocument>();
// Initialize Dom extensions now that the data is complete
rootNode.InitializeExtensions();
var docRegistry = GetDocRegistry();
if (docRegistry != null) docRegistry.Add(doc);
doc.Dirty = true;
return doc;
}