本文整理汇总了C#中Spark.Parser.Markup.ElementNode类的典型用法代码示例。如果您正苦于以下问题:C# ElementNode类的具体用法?C# ElementNode怎么用?C# ElementNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ElementNode类属于Spark.Parser.Markup命名空间,在下文中一共展示了ElementNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateExtension
public ISparkExtension CreateExtension(VisitorContext context, ElementNode node)
{
if(_serviceProvider==null)
{
return null;
}
var componentFactory = (IViewComponentFactory)_serviceProvider.GetService(typeof(IViewComponentFactory));
if (componentFactory == null || componentFactory.Registry == null)
return null;
ViewComponentInfo viewComponentInfo;
lock (_cachedViewComponent)
{
if (!_cachedViewComponent.TryGetValue(node.Name, out viewComponentInfo))
{
if (componentFactory.Registry.HasViewComponent(node.Name))
{
viewComponentInfo = new ViewComponentInfo(componentFactory.Create(node.Name));
_cachedViewComponent.Add(node.Name, viewComponentInfo);
}
else
{
_cachedViewComponent.Add(node.Name, null);
}
}
}
if (viewComponentInfo != null)
{
return new ViewComponentExtension(node, viewComponentInfo);
}
return null;
}
示例2: GetApplicableReplacements
private static IEnumerable<IReplacement> GetApplicableReplacements(ElementNode node)
{
var result = new List<IReplacement>();
result.AddRange(UriReplacementSpecifications.GetMatching(node));
result.AddRange(FormReplacementSpecifications.GetMatching(node));
return result;
}
示例3: Transform
protected void Transform(ElementNode elementNode, IList<Node> body)
{
foreach (IReplacement replacement in replacements)
{
replacement.DoReplace(elementNode);
}
}
示例4: CreateExtension
public ISparkExtension CreateExtension(VisitorContext context, ElementNode node)
{
if (node.Name == "unittest")
return new TestExtension();
return null;
}
示例5: DoReplace
public void DoReplace(ElementNode node, IList<Node> body)
{
string propertyExpression = node.GetAttributeValue("for");
Node checkedSnippet = propertyExpression.GetCheckedSnippet();
node.RemoveAttributesByName("checked");
node.Attributes.Add(new AttributeNode("checked", new List<Node>(){checkedSnippet}));
}
示例6: AddAttribute
protected static void AddAttribute(ElementNode elementNode, string attributeName, Node childNode)
{
elementNode.RemoveAttributesByName(attributeName);
elementNode.Attributes.Add(new AttributeNode(attributeName, new List<Node>
{
childNode
}));
}
示例7: NonVoidElementDoesNotSelfClose
public void NonVoidElementDoesNotSelfClose()
{
var elt = new ElementNode("span", new AttributeNode[]{ }, true);
var visitor = new ChunkBuilderVisitor(new VisitorContext());
visitor.Accept(elt);
Assert.AreEqual(1, visitor.Chunks.Count());
Assert.AreEqual("<span></span>", ((SendLiteralChunk)visitor.Chunks[0]).Text);
}
示例8: RemoteAndEvalUriSnippet
private Node RemoteAndEvalUriSnippet(ElementNode elementNode)
{
string attribValue = elementNode.GetAttributeValue(replacementSpecification.OriginalAttributeName);
elementNode.RemoveAttributesByName(replacementSpecification.OriginalAttributeName);
return
attribValue.GetCreateUriSnippet(
IsTypeReplacement());
}
示例9: ExtractFakeAttribute
private AttributeNode ExtractFakeAttribute(ElementNode node, string name, string fakeName)
{
var attribute = node.Attributes.SingleOrDefault(x => AttrName(x) == name);
if (attribute == null)
return null;
node.Attributes.Remove(attribute);
return new AttributeNode(fakeName, '"', attribute.Nodes);
}
示例10: GetMiscReplacements
private static IEnumerable<IReplacement> GetMiscReplacements(ElementNode node)
{
IEnumerable<IReplacement> result =
TextAreaSpecs.Where(x => x.IsMatch(node)).Select(x => new TextAreaValueReplacement(x)).Cast<IReplacement>();
result =
result.Union(
SelectSpecs.Where(x => x.IsMatch(node)).Select(x => new SelectSelectedValueReplacement(x)).Cast<IReplacement>());
return result;
}
示例11: CreateExtension
public ISparkExtension CreateExtension(VisitorContext context, ElementNode node)
{
IEnumerable<IReplacement> replacements = GetApplicableReplacements(node);
if (replacements.Any())
{
return new SparkExtension(node, replacements);
}
return null;
}
示例12: CreateElementTransformer
public ISparkElementTransformer CreateElementTransformer(ElementNode elementNode)
{
var sparkElementWrapper = new SparkElementWrapper(elementNode);
if(!_elementTransformerService.IsTransformable(sparkElementWrapper))
{
return new NullSparkElementTransformer();
}
return new SparkElementTransformer(_elementTransformerService.GetTransformerFor(sparkElementWrapper));
}
示例13: CreateElementTransformer
public ISparkElementTransformer CreateElementTransformer(ElementNode elementNode)
{
var tag = new Tag(elementNode.Name, elementNode.Attributes.Select(x=>new TagAttribute(x.Name, x.Value)).ToArray());
if(!_elementTransformerService.IsTransformable(tag))
{
return new NullSparkElementTransformer();
}
return new SparkElementTransformer(_elementTransformerService.GetTransformerFor(tag));
}
示例14: CreateExtension
public ISparkExtension CreateExtension(VisitorContext context, ElementNode node)
{
ISparkElementTransformer elementTransformer = _sparkElementTransformerService.CreateElementTransformer(node);
if(elementTransformer is NullSparkElementTransformer)
{
return null;
}
return new SparkOverrideExtension(node, elementTransformer);
}
示例15: DoReplace
public void DoReplace(ElementNode node)
{
RemoveReplacedAttribute(node);
Node uriSnippet = RemoteAndEvalUriSnippet(node);
node.Attributes.Add(new AttributeNode(replacementSpecification.NewAttributeName, new List<Node>()
{
uriSnippet
}));
}