本文整理汇总了C#中DomNode.As方法的典型用法代码示例。如果您正苦于以下问题:C# DomNode.As方法的具体用法?C# DomNode.As怎么用?C# DomNode.As使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomNode
的用法示例。
在下文中一共展示了DomNode.As方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: New
/// <summary>
/// Creates a new UIRef adapter and underlying DomNode</summary>
/// <param name="uiObj">UIObject being referenced</param>
/// <returns>New UIRef adapter</returns>
public static UIRef New(UIObject uiObj)
{
DomNode node = new DomNode(UISchema.UIRefType.Type);
UIRef uiRef = node.As<UIRef>();
uiRef.UIObject = uiObj;
return uiRef;
}
示例2: WriteElement
// Filter out sub-circuits that are not actually needed
protected override void WriteElement(DomNode node, XmlWriter writer)
{
var subCircuit = node.As<SubCircuit>();
if (subCircuit != null && !m_usedSubCircuits.Contains(subCircuit))
return;
base.WriteElement(node, writer);
}
示例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: GetReferenceTarget
public static DomNode GetReferenceTarget(DomNode node)
{
var placementsCellRef = node.As<Placements.PlacementsCellRef>();
if (placementsCellRef != null && placementsCellRef.Target != null)
{
node = placementsCellRef.Target.As<DomNode>();
}
return node;
}
示例5: WriteElement
#pragma warning restore 618
// Filter out sub-circuits that are not actually needed
protected override void WriteElement(DomNode node, XmlWriter writer)
{
#pragma warning disable 618 //mastered sub-circuits are obsolete
var subCircuit = node.As<SubCircuit>();
if (subCircuit != null && !m_usedSubCircuits.Contains(subCircuit))
return;
#pragma warning restore 618
base.WriteElement(node, writer);
}
示例6: Create
public static AttributeOverride Create(string name, string value)
{
if (string.IsNullOrWhiteSpace(name))
throw new InvalidOperationException("name cannot be null or empty");
DomNode node = new DomNode(Schema.attributeOverrideType.Type);
AttributeOverride attrOverride = node.As<AttributeOverride>();
attrOverride.Name = name;
attrOverride.AttribValue = value;
return attrOverride;
}
示例7: TestOnChildInserted
public void TestOnChildInserted()
{
DomNode root = new DomNode(RootType);
Validator validator = root.As<Validator>();
DomNode child = new DomNode(ChildType);
root.SetChild(ChildInfo, child);
Assert.AreSame(validator.Sender, root);
ChildEventArgs e = (ChildEventArgs)validator.E;
Assert.NotNull(e);
Assert.AreSame(e.Parent, root);
}
示例8: GetScmpBlobAsLuaGlobalVar
public SledLuaVarGlobalType GetScmpBlobAsLuaGlobalVar()
{
var var = m_debugService.GetScmpBlob<Scmp.LuaVarGlobal>();
var node = new DomNode(SledLuaSchema.SledLuaVarGlobalType.Type);
var global = node.As<SledLuaVarGlobalType>();
global.DisplayName = var.Name;
global.Name = SledLuaVarBaseType.CreateFlattenedHierarchyName(var.Name, var.Hierarchy, HierarchySeparatorString);
global.What = SledLuaUtil.LuaTypeIntToString(var.What);
global.Value = var.Value;
global.KeyType = var.KeyType;
SledLuaVarBaseType.SetupTargetHierarchyFromRuntimeData(global, var.Hierarchy);
global.GenerateUniqueName();
return global;
}
示例9: 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;
}
示例10: DebugServiceDataReady
private void DebugServiceDataReady(object sender, SledDebugServiceEventArgs e)
{
var typeCode = (Scmp.LuaTypeCodes)e.Scmp.TypeCode;
switch (typeCode)
{
case Scmp.LuaTypeCodes.LuaStateBegin:
m_luaStatesCollection.ValidationBeginning();
break;
case Scmp.LuaTypeCodes.LuaStateAdd:
{
var scmp = m_debugService.GetScmpBlob<Scmp.LuaStateAdd>();
var domNode = new DomNode(SledLuaSchema.SledLuaStateType.Type);
var luaState = domNode.As<SledLuaStateType>();
luaState.Address = scmp.Address;
luaState.Name = scmp.Name;
luaState.Checked = scmp.Debugging == 1;
m_luaStatesCollection.LuaStates.Add(luaState);
}
break;
case Scmp.LuaTypeCodes.LuaStateRemove:
{
var scmp = m_debugService.GetScmpBlob<Scmp.LuaStateRemove>();
var sentinel =
m_luaStatesCollection.LuaStates.FirstOrDefault(
luaState => string.Compare(luaState.Address, scmp.Address, StringComparison.Ordinal) == 0);
if (sentinel != null)
m_luaStatesCollection.LuaStates.Remove(sentinel);
}
break;
case Scmp.LuaTypeCodes.LuaStateEnd:
m_luaStatesCollection.ValidationEnding();
break;
}
}
示例11: Remove
public void Remove(DomNode parent, DomNode child, ChildInfo chInfo)
{
NativeObjectAdapter childObject = child.As<NativeObjectAdapter>();
NativeObjectAdapter parentObject = parent.As<NativeObjectAdapter>();
object listIdObj = chInfo.GetTag(NativeAnnotations.NativeElement);
if (childObject == null || parentObject == null || listIdObj == null)
return;
uint listId = (uint)listIdObj;
uint typeId = (uint)chInfo.DefiningType.GetTag(NativeAnnotations.NativeType);
ulong parentId = parentObject.InstanceId;
ulong childId = childObject.InstanceId;
GameEngine.ObjectRemoveChild(typeId, listId, parentId, childId);
if (ManageNativeObjectLifeTime)
{
GameEngine.DestroyObject(childObject);
}
}
示例12: AddLocations
public void AddLocations(ISledLuaVarBaseType luaVar)
{
if (luaVar == null)
return;
Dictionary<string, List<SledLuaVariableParserService.VariableResult>> parsedVars;
{
var nodeType = luaVar.DomNode.Type;
if (nodeType == SledLuaSchema.SledLuaVarLocalType.Type)
parsedVars = m_luaVariableParserService.ParsedLocals;
else if (nodeType == SledLuaSchema.SledLuaVarUpvalueType.Type)
parsedVars = m_luaVariableParserService.ParsedUpvalues;
else
parsedVars = m_luaVariableParserService.ParsedGlobals;
}
if (parsedVars == null)
return;
// No locations for variable
List<SledLuaVariableParserService.VariableResult> items;
if (!parsedVars.TryGetValue(luaVar.Name, out items))
return;
// Iterate through all values belonging to this key
foreach (var result in items)
{
var domNode = new DomNode(SledSchema.SledVarLocationType.Type);
// Generate location data
var loc = domNode.As<SledVarLocationType>();
loc.File = result.File.AbsolutePath;
loc.Line = result.Line;
loc.Occurence = result.Occurence;
// Add to list
luaVar.Locations.Add(loc);
}
}
示例13: CreateDefaultNodes
public static void CreateDefaultNodes(DomNode gameRoot)
{
var ext = gameRoot.As<Game.GameExtensions>();
if (ext != null)
{
// Add default environment settings
var envFolder = ext.EnvSettingsFolder;
if (envFolder.Settings.Count == 0)
envFolder.AddChild(Environment.XLEEnvSettings.Create(envFolder.GetNameForNewChild()));
// Add placements folder with an unnamed default placement document
if (ext.PlacementsFolder == null)
{
var newNode = Placements.PlacementsFolder.CreateStarter();
if (newNode != null)
{
ext.PlacementsFolder = newNode.As<Placements.PlacementsFolder>();
}
}
}
}
示例14: GetScmpBlobAsLuaUpvalueVar
public SledLuaVarUpvalueType GetScmpBlobAsLuaUpvalueVar()
{
var var = m_debugService.GetScmpBlob<Scmp.LuaVarUpvalue>();
var node = new DomNode(SledLuaSchema.SledLuaVarUpvalueType.Type);
var upvalue = node.As<SledLuaVarUpvalueType>();
upvalue.DisplayName = var.Name;
upvalue.Name = SledLuaVarBaseType.CreateFlattenedHierarchyName(var.Name, var.Hierarchy, HierarchySeparatorString);
upvalue.What = SledLuaUtil.LuaTypeIntToString(var.What);
upvalue.Value = var.Value;
upvalue.Level = var.StackLevel;
upvalue.Index = var.Index;
upvalue.KeyType = var.KeyType;
upvalue.FunctionName = m_luaCallStackService.Get[upvalue.Level].Function;
upvalue.FunctionLineDefined = m_luaCallStackService.Get[upvalue.Level].LineDefined;
SledLuaVarBaseType.SetupTargetHierarchyFromRuntimeData(upvalue, var.Hierarchy);
upvalue.GenerateUniqueName();
return upvalue;
}
示例15: 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);
}