本文整理汇总了C#中IASTNode.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# IASTNode.AddChild方法的具体用法?C# IASTNode.AddChild怎么用?C# IASTNode.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IASTNode
的用法示例。
在下文中一共展示了IASTNode.AddChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddImpliedFromToFromNode
private static void AddImpliedFromToFromNode(IASTNode fromClause, string collectionRole, ISessionFactoryImplementor factory)
{
SessionFactoryHelperExtensions _sessionFactoryHelper = new SessionFactoryHelperExtensions(factory);
IQueryableCollection persister = _sessionFactoryHelper.GetCollectionPersister(collectionRole);
IType collectionElementType = persister.ElementType;
if (!collectionElementType.IsEntityType)
{
throw new QueryException("collection of values in filter: this");
}
string collectionElementEntityName = persister.ElementPersister.EntityName;
ITreeAdaptor adaptor = new ASTTreeAdaptor();
IASTNode fromElement = (IASTNode)adaptor.Create(HqlParser.FILTER_ENTITY, collectionElementEntityName);
IASTNode alias = (IASTNode)adaptor.Create(HqlParser.ALIAS, "this");
fromClause.AddChild(fromElement);
fromClause.AddChild(alias);
// Show the modified AST.
if (log.IsDebugEnabled)
{
log.Debug("AddImpliedFormToFromNode() : Filter - Added 'this' as a from element...");
}
}
示例2: InsertChild
/// <summary>
/// Insert a new node into both the Tree and the Node Array. Add DOWN and UP nodes if needed.
/// </summary>
/// <param name="parent">The parent node</param>
/// <param name="child">The child node</param>
public void InsertChild(IASTNode parent, IASTNode child)
{
if (child.ChildCount > 0)
{
throw new InvalidOperationException("Currently do not support adding nodes with children");
}
int parentIndex = nodes.IndexOf(parent);
int numberOfChildNodes = NumberOfChildNodes(parentIndex);
int insertPoint;
if (numberOfChildNodes == 0)
{
insertPoint = parentIndex + 1; // We want to insert immediately after the parent
nodes.Insert(insertPoint, down);
insertPoint++; // We've just added a new node
}
else
{
insertPoint = parentIndex + numberOfChildNodes;
}
parent.AddChild(child);
nodes.Insert(insertPoint, child);
insertPoint++;
if (numberOfChildNodes == 0)
{
nodes.Insert(insertPoint, up);
}
}
示例3: HqlTreeNode
protected HqlTreeNode(int type, string text, IASTFactory factory, params HqlTreeNode[] children)
{
_node = factory.CreateNode(type, text);
_children = new List<HqlTreeNode>();
foreach (var child in children)
{
_children.Add(child);
_node.AddChild(child.AstNode);
}
}
示例4: PrepareFromClauseInputTree
void PrepareFromClauseInputTree(IASTNode fromClauseInput, ITreeNodeStream input)
{
if (IsFilter())
{
// Handle collection-fiter compilation.
// IMPORTANT NOTE: This is modifying the INPUT (HQL) tree, not the output tree!
IQueryableCollection persister = _sessionFactoryHelper.GetCollectionPersister(_collectionFilterRole);
IType collectionElementType = persister.ElementType;
if (!collectionElementType.IsEntityType)
{
throw new QueryException("collection of values in filter: this");
}
string collectionElementEntityName = persister.ElementPersister.EntityName;
IASTNode fromElement = (IASTNode)adaptor.Create(FILTER_ENTITY, collectionElementEntityName);
IASTNode alias = (IASTNode)adaptor.Create(ALIAS, "this");
fromClauseInput.AddChild(fromElement);
fromClauseInput.AddChild(alias);
// Show the modified AST.
if (log.IsDebugEnabled)
{
log.Debug("prepareFromClauseInputTree() : Filter - Added 'this' as a from element...");
}
// Create a parameter specification for the collection filter...
IType collectionFilterKeyType = _sessionFactoryHelper.RequireQueryableCollection(_collectionFilterRole).KeyType;
ParameterNode collectionFilterKeyParameter = (ParameterNode)adaptor.Create(PARAM, "?");
CollectionFilterKeyParameterSpecification collectionFilterKeyParameterSpec = new CollectionFilterKeyParameterSpecification(
_collectionFilterRole, collectionFilterKeyType, _positionalParameterCount++
);
collectionFilterKeyParameter.HqlParameterSpecification = collectionFilterKeyParameterSpec;
_parameters.Add(collectionFilterKeyParameterSpec);
}
}