本文整理汇总了C#中SyntaxWriter.WriteEndSubBlock方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxWriter.WriteEndSubBlock方法的具体用法?C# SyntaxWriter.WriteEndSubBlock怎么用?C# SyntaxWriter.WriteEndSubBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxWriter
的用法示例。
在下文中一共展示了SyntaxWriter.WriteEndSubBlock方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteAttachedEventSyntax
/// <inheritdoc />
public override void WriteAttachedEventSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
string eventName = (string)reflection.Evaluate(apiNameExpression);
string containingTypeName = (string)reflection.Evaluate(apiContainingTypeNameExpression);
XPathNavigator eventHandler = reflection.SelectSingleNode(apiHandlerOfEventExpression);
// xaml syntax block for attached event
string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading);
writer.WriteStartSubBlock(xamlBlockId);
writer.WriteString("<");
writer.WriteParameter("object ");
writer.WriteIdentifier(containingTypeName + "." + eventName);
writer.WriteString("=\"");
WriteTypeReference(eventHandler, writer);
writer.WriteString("\" .../>");
writer.WriteEndSubBlock();
}
示例2: PropertyAttributeUsage
// An Attribute Usage block
private void PropertyAttributeUsage(XPathNavigator propertyReflection, SyntaxWriter writer)
{
string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading);
string propertyName = (string)propertyReflection.Evaluate(apiNameExpression);
XPathNavigator returnType = propertyReflection.SelectSingleNode(apiReturnTypeExpression);
// start the syntax block
writer.WriteStartSubBlock(xamlBlockId);
// syntax looks like:
// <object PropertyName="linkToType" .../>
writer.WriteString("<");
writer.WriteParameter("object ");
writer.WriteIdentifier(propertyName);
writer.WriteString("=\"");
WriteTypeReference(returnType, writer);
writer.WriteString("\" .../>");
writer.WriteEndSubBlock();
}
示例3: WriteEventSyntax
/// <inheritdoc />
public override void WriteEventSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
string eventName = (string)reflection.Evaluate(apiNameExpression);
string eventVisibility = (string)reflection.Evaluate(apiVisibilityExpression);
bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractProcedureExpression);
XPathNavigator eventHandler = reflection.SelectSingleNode(apiHandlerOfEventExpression);
XPathNavigator containingType = reflection.SelectSingleNode(apiContainingTypeExpression);
string containingTypeSubgroup = (string)containingType.Evaluate(apiSubgroupExpression);
bool containingTypeIsAbstract = (bool)containingType.Evaluate(apiIsAbstractTypeExpression);
bool containingTypeIsSealed = (bool)containingType.Evaluate(apiIsSealedTypeExpression);
if(containingTypeSubgroup == "interface")
{
WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_noXamlSyntaxForInterfaceMembers, writer);
}
else if(containingTypeIsAbstract && containingTypeIsSealed)
{
// the event's containing type is static if it's abstract and sealed
// members of a static class cannot be used in XAML.
WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_nonXamlParent, writer);
}
else if(IsExcludedSubClass(containingType))
{
WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_parentIsExcludedSubClass, writer);
}
else if(!DoesParentSupportXaml(reflection))
{
WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_nonXamlParent, writer);
}
else if(eventVisibility != "public")
{
WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_notPublic, writer);
}
else if(isAbstract)
{
WriteXamlBoilerplate(XamlBoilerplateID.eventXamlSyntax_abstract, writer);
}
else
{
// start the syntax block
string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading);
writer.WriteStartSubBlock(xamlBlockId);
// syntax looks like:
// <object eventName="eventHandlerLink" .../>
writer.WriteString("<");
writer.WriteParameter("object ");
writer.WriteIdentifier(eventName);
writer.WriteString("=\"");
WriteTypeReference(eventHandler, writer);
writer.WriteString("\" .../>");
writer.WriteEndSubBlock();
}
}
示例4: PropertyElementUsageGrande
// A grandiose Property Element Usage block
// syntax looks like:
// <object>
// <object.PropertyName>
// <linkToType .../>
// </object.PropertyName>
// </object>
private void PropertyElementUsageGrande(XPathNavigator propertyReflection, SyntaxWriter writer)
{
string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlPropertyElementUsageHeading);
string propertyName = (string)propertyReflection.Evaluate(apiNameExpression);
XPathNavigator returnType = propertyReflection.SelectSingleNode(apiReturnTypeExpression);
// start the syntax block
writer.WriteStartSubBlock(xamlBlockId);
// <object>
writer.WriteString("<");
writer.WriteParameter("object");
writer.WriteString(">");
writer.WriteLine();
// <object.PropertyName>
writer.WriteString(" <");
writer.WriteParameter("object");
writer.WriteString(".");
writer.WriteIdentifier(propertyName);
writer.WriteString(">");
writer.WriteLine();
// <linkToType .../>
writer.WriteString(" <");
WriteTypeReference(returnType, writer);
writer.WriteString(" .../>");
writer.WriteLine();
// </object.PropertyName>
writer.WriteString(" </");
writer.WriteParameter("object");
writer.WriteString(".");
writer.WriteIdentifier(propertyName);
writer.WriteString(">");
writer.WriteLine();
// </object>
writer.WriteString("</");
writer.WriteParameter("object");
writer.WriteString(">");
writer.WriteEndSubBlock();
}
示例5: WriteAttachedPropertySyntax
/// <inheritdoc />
public override void WriteAttachedPropertySyntax(XPathNavigator reflection, SyntaxWriter writer)
{
string propertyName = (string)reflection.Evaluate(apiNameExpression);
string containingTypeName = (string)reflection.Evaluate(apiContainingTypeNameExpression);
bool isSettable = (bool)reflection.Evaluate(apiIsWritePropertyExpression);
XPathNavigator returnType = reflection.SelectSingleNode(apiReturnTypeExpression);
if(!isSettable)
{
WriteXamlBoilerplate(XamlBoilerplateID.propertyXamlSyntax_readOnly, writer);
}
else
{
// xaml syntax block for attached property
string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlAttributeUsageHeading);
writer.WriteStartSubBlock(xamlBlockId);
writer.WriteString("<");
writer.WriteParameter("object ");
writer.WriteIdentifier(containingTypeName + "." + propertyName);
writer.WriteString("=\"");
WriteTypeReference(returnType, writer);
writer.WriteString("\" .../>");
writer.WriteEndSubBlock();
}
}
示例6: ObjectElementUsageForClassStruct
private void ObjectElementUsageForClassStruct(XPathNavigator reflection, SyntaxWriter writer)
{
string typeName = (string)reflection.Evaluate(apiNameExpression);
bool isGeneric = (bool)reflection.Evaluate(apiIsGenericExpression);
string xamlBlockId = System.Enum.GetName(typeof(XamlHeadingID), XamlHeadingID.xamlObjectElementUsageHeading);
string contentPropertyId = (string)reflection.Evaluate(contentPropertyIdExpression);
if(String.IsNullOrEmpty(contentPropertyId))
contentPropertyId = (string)reflection.Evaluate(ancestorContentPropertyIdExpression);
// start the syntax block
writer.WriteStartSubBlock(xamlBlockId);
writer.WriteString("<");
if(isGeneric)
{
writer.WriteIdentifier(typeName);
// for generic types show the type arguments
XPathNodeIterator templates = (XPathNodeIterator)reflection.Evaluate(apiTemplatesExpression);
if(templates.Count > 0)
{
writer.WriteString(" x:TypeArguments=\"");
while(templates.MoveNext())
{
XPathNavigator template = templates.Current;
string name = template.GetAttribute("name", String.Empty);
writer.WriteString(name);
if(templates.CurrentPosition < templates.Count)
writer.WriteString(",");
}
writer.WriteString("\"");
}
}
else
{
// for non-generic types just show the name
writer.WriteIdentifier(typeName);
}
if(String.IsNullOrEmpty(contentPropertyId))
writer.WriteString(" .../>");
else
{
// close the start tag
writer.WriteString(">");
// the inner xml of the Object Element syntax for a type with a content property
// is a link to the content property
writer.WriteLine();
writer.WriteString(" ");
writer.WriteReferenceLink(contentPropertyId);
writer.WriteLine();
// write the end tag
writer.WriteString("</");
writer.WriteIdentifier(typeName);
writer.WriteString(">");
}
// end the sub block
writer.WriteEndSubBlock();
}
示例7: WriteXamlBoilerplate
private void WriteXamlBoilerplate(XamlBoilerplateID bpID, XPathNavigator typeReflection, SyntaxWriter writer)
{
string xamlBlockId = System.Enum.GetName(typeof(XamlBoilerplateID), bpID);
if(xamlBlockId != null)
{
writer.WriteStartSubBlock(xamlBlockId);
if(typeReflection != null)
WriteTypeReference(typeReflection, writer);
writer.WriteEndSubBlock();
}
}
示例8: WriteXamlXmlnsUri
private void WriteXamlXmlnsUri(string assemblyName, string namespaceName, SyntaxWriter writer)
{
Dictionary<string, List<string>> clrNamespaces;
if(xamlAssemblies.TryGetValue(assemblyName, out clrNamespaces))
{
List<string> xmlnsUriList;
if(clrNamespaces.TryGetValue(namespaceName, out xmlnsUriList))
{
foreach(string xmlnsUri in xmlnsUriList)
{
// start the syntax block
writer.WriteStartSubBlock("xamlXmlnsUri");
writer.WriteString(xmlnsUri);
writer.WriteEndSubBlock();
}
}
}
}