本文整理汇总了C#中SyntaxWriter.WriteIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxWriter.WriteIdentifier方法的具体用法?C# SyntaxWriter.WriteIdentifier怎么用?C# SyntaxWriter.WriteIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxWriter
的用法示例。
在下文中一共展示了SyntaxWriter.WriteIdentifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteNamespaceSyntax
// namespace: done
/// <inheritdoc />
public override void WriteNamespaceSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
string name = reflection.Evaluate(apiNameExpression).ToString();
writer.WriteKeyword("namespace");
writer.WriteString(" ");
writer.WriteIdentifier(name);
}
示例2: WriteFieldSyntax
/// <inheritdoc />
public override void WriteFieldSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
// !EFW - Added unsafe check
if(IsUnsupportedUnsafe(reflection, writer))
return;
string name = (string)reflection.Evaluate(apiNameExpression);
bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
bool isLiteral = (bool)reflection.Evaluate(apiIsLiteralFieldExpression);
bool isInitOnly = (bool)reflection.Evaluate(apiIsInitOnlyFieldExpression);
bool isSerialized = (bool)reflection.Evaluate(apiIsSerializedFieldExpression);
if(!isSerialized)
WriteAttribute("T:System.NonSerializedAttribute", writer);
WriteAttributes(reflection, writer);
WriteVisibility(reflection, writer);
writer.WriteString(" ");
// Java doesn't support literals as distinct from static initonly
if(isStatic)
{
writer.WriteKeyword("static");
writer.WriteString(" ");
}
if(isLiteral || isInitOnly)
{
writer.WriteKeyword("final");
writer.WriteString(" ");
}
WriteReturnValue(reflection, writer);
writer.WriteString(" ");
writer.WriteIdentifier(name);
}
示例3: WriteFieldSyntax
/// <inheritdoc />
public override void WriteFieldSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
// !EFW - Added unsafe check
if(IsUnsupportedUnsafe(reflection, writer))
return;
string name = (string)reflection.Evaluate(apiNameExpression);
bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
bool isInitOnly = (bool)reflection.Evaluate(apiIsInitOnlyFieldExpression);
bool isSerialized = (bool)reflection.Evaluate(apiIsSerializedFieldExpression);
if(!isSerialized)
WriteAttribute("T:System.NonSerializedAttribute", true, writer);
WriteAttributes(reflection, writer);
if(isStatic)
{
writer.WriteKeyword("static");
writer.WriteString(" ");
}
writer.WriteKeyword("val");
writer.WriteString(" ");
if(!isInitOnly)
{
writer.WriteKeyword("mutable");
writer.WriteString(" ");
}
WriteVisibility(reflection, writer);
writer.WriteIdentifier(name);
writer.WriteString(": ");
WriteReturnValue(reflection, writer);
}
示例4: WriteNormalMethodSyntax
/// <inheritdoc />
public override void WriteNormalMethodSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
// !EFW - Added unsafe check
if(IsUnsupportedUnsafe(reflection, writer))
return;
if(IsUnsupportedVarargs(reflection, writer))
return;
string name = (string)reflection.Evaluate(apiNameExpression);
bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
bool isVirtual = (bool)reflection.Evaluate(apiIsVirtualExpression) && !(bool)reflection.Evaluate(apiIsAbstractProcedureExpression);
int iterations = isVirtual ? 2 : 1;
for(int i = 0; i < iterations; i++)
{
WriteAttributes(reflection, writer);
WriteVisibility(reflection, writer);
if(isStatic)
{
writer.WriteKeyword("static");
writer.WriteString(" ");
}
if(isVirtual)
if(i == 0)
{
writer.WriteKeyword("abstract");
writer.WriteString(" ");
}
else
{
writer.WriteKeyword("override");
writer.WriteString(" ");
}
else
{
WriteMemberKeyword(reflection, writer);
}
writer.WriteIdentifier(name);
writer.WriteString(" : ");
WriteParameters(reflection, writer);
writer.WriteKeyword("->");
writer.WriteString(" ");
WriteReturnValue(reflection, writer);
writer.WriteString(" ");
WriteGenericTemplateConstraints(reflection, writer);
if(i == 0)
writer.WriteLine();
}
}
示例5: WritePropertySyntax
/// <inheritdoc />
public override void WritePropertySyntax(XPathNavigator reflection, SyntaxWriter writer)
{
// !EFW - Added unsafe check
if(IsUnsupportedUnsafe(reflection, writer))
return;
string name = (string)reflection.Evaluate(apiNameExpression);
bool isGettable = (bool)reflection.Evaluate(apiIsReadPropertyExpression);
bool isSettable = (bool)reflection.Evaluate(apiIsWritePropertyExpression);
bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
bool isVirtual = (bool)reflection.Evaluate(apiIsVirtualExpression) && !(bool)reflection.Evaluate(apiIsAbstractProcedureExpression);
int iterations = isVirtual ? 2 : 1;
for(int i = 0; i < iterations; i++)
{
WriteAttributes(reflection, writer);
WriteVisibility(reflection, writer);
if(isStatic)
{
writer.WriteKeyword("static");
writer.WriteString(" ");
}
if(isVirtual)
if(i == 0)
{
writer.WriteKeyword("abstract");
writer.WriteString(" ");
}
else
{
writer.WriteKeyword("override");
writer.WriteString(" ");
}
else
{
WriteMemberKeyword(reflection, writer);
}
writer.WriteIdentifier(name);
writer.WriteString(" : ");
WriteReturnValue(reflection, writer);
writer.WriteString(" ");
writer.WriteKeyword("with");
writer.WriteString(" ");
if(isGettable)
{
// !EFW - Added support for getter/setter attributes
XPathNavigator getter = reflection.SelectSingleNode(apiGetterExpression);
if(getter != null && getter.HasChildren)
{
writer.WriteLine();
writer.WriteString("\t");
this.WriteAttributes(getter, writer, "\t");
writer.WriteString("\t");
}
string getVisibility = (string)reflection.Evaluate(apiGetVisibilityExpression);
if(!String.IsNullOrEmpty(getVisibility))
{
WriteVisibility(getVisibility, writer);
}
writer.WriteKeyword("get");
}
if(isSettable)
{
if(isGettable)
writer.WriteString(", ");
// !EFW - Added support for getter/setter attributes
XPathNavigator setter = reflection.SelectSingleNode(apiSetterExpression);
if(setter != null && setter.HasChildren)
{
writer.WriteLine();
writer.WriteString("\t");
this.WriteAttributes(setter, writer, "\t");
writer.WriteString("\t");
}
string setVisibility = (string)reflection.Evaluate(apiSetVisibilityExpression);
if(!String.IsNullOrEmpty(setVisibility))
{
WriteVisibility(setVisibility, writer);
}
writer.WriteKeyword("set");
}
if(i == 0)
//.........这里部分代码省略.........
示例6: WriteClassSyntax
/// <inheritdoc />
public override void WriteClassSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
string name = (string)reflection.Evaluate(apiNameExpression);
bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractTypeExpression);
bool isSealed = (bool)reflection.Evaluate(apiIsSealedTypeExpression);
bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);
if(isSerializable)
WriteAttribute("T:System.SerializableAttribute", writer);
WriteAttributes(reflection, writer);
WriteVisibility(reflection, writer);
writer.WriteString(" ");
if(isAbstract)
{
if(isSealed)
{
// static -- VB doesn't really handle this case
writer.WriteKeyword("NotInheritable");
writer.WriteString(" ");
}
else
{
writer.WriteKeyword("MustInherit");
writer.WriteString(" ");
}
}
else if(isSealed)
{
writer.WriteKeyword("NotInheritable");
writer.WriteString(" ");
}
writer.WriteKeyword("Class");
writer.WriteString(" ");
writer.WriteIdentifier(name);
WriteGenericTemplates(reflection, writer);
WriteBaseClass(reflection, writer);
WriteImplementedInterfaces(reflection, writer);
}
示例7: WriteEnumerationSyntax
/// <inheritdoc />
public override void WriteEnumerationSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
string name = (string)reflection.Evaluate(apiNameExpression);
bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);
if(isSerializable)
WriteAttribute("T:System.SerializableAttribute", true, writer);
WriteAttributes(reflection, writer);
writer.WriteKeyword("type");
writer.WriteString(" ");
WriteVisibility(reflection, writer);
writer.WriteIdentifier(name);
}
示例8: 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();
}
}
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}
示例12: 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();
}
}
示例13: 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();
}
示例14: WriteClassSyntax
/// <inheritdoc />
public override void WriteClassSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
if(IsUnsupportedGeneric(reflection, writer))
return;
string name = reflection.Evaluate(apiNameExpression).ToString();
bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractTypeExpression);
bool isSealed = (bool)reflection.Evaluate(apiIsSealedTypeExpression);
bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);
if(isSerializable)
WriteAttribute("T:System.SerializableAttribute", writer);
WriteAttributes(reflection, writer);
WriteVisibility(reflection, writer);
writer.WriteString(" ");
if(isSealed)
{
writer.WriteKeyword("final");
writer.WriteString(" ");
}
else if(isAbstract)
{
writer.WriteKeyword("abstract");
writer.WriteString(" ");
}
writer.WriteKeyword("class");
writer.WriteString(" ");
writer.WriteIdentifier(name);
XPathNavigator baseClass = reflection.SelectSingleNode(apiBaseClassExpression);
if((baseClass != null) && !((bool)baseClass.Evaluate(typeIsObjectExpression)))
{
writer.WriteString(" ");
writer.WriteKeyword("extends");
writer.WriteString(" ");
WriteTypeReference(baseClass, writer);
}
WriteImplementedInterfaces(reflection, writer);
}
示例15: WriteEventSyntax
/// <inheritdoc />
public override void WriteEventSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
// !EFW - Added unsafe check
if(IsUnsupportedUnsafe(reflection, writer))
return;
string name = (string)reflection.Evaluate(apiNameExpression);
XPathNavigator handler = reflection.SelectSingleNode(apiHandlerOfEventExpression);
WriteAttributes(reflection, writer);
WriteProcedureModifiers(reflection, writer);
writer.WriteString("Event");
writer.WriteString(" ");
writer.WriteIdentifier(name);
writer.WriteString(" ");
writer.WriteKeyword("As");
writer.WriteString(" ");
WriteTypeReference(handler, writer);
WriteExplicitImplementations(reflection, writer);
}