本文整理汇总了C#中Microsoft.Ddue.Tools.SyntaxWriter.WriteString方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxWriter.WriteString方法的具体用法?C# SyntaxWriter.WriteString怎么用?C# SyntaxWriter.WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Ddue.Tools.SyntaxWriter
的用法示例。
在下文中一共展示了SyntaxWriter.WriteString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteClassSyntax
// class: done
public override void WriteClassSyntax (XPathNavigator reflection, SyntaxWriter writer) {
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 (isAbstract) {
if (isSealed) {
writer.WriteKeyword("static");
} else {
writer.WriteKeyword("abstract");
}
writer.WriteString(" ");
} else {
if (isSealed) {
writer.WriteKeyword("sealed");
writer.WriteString(" ");
}
}
writer.WriteKeyword("class");
writer.WriteString(" ");
writer.WriteIdentifier(name);
WriteGenericTemplates(reflection, writer);
WriteBaseClassAndImplementedInterfaces(reflection, writer);
WriteGenericTemplateConstraints(reflection, writer);
}
示例2: WriteClassSyntax
// class: done
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);
}
示例3: WriteEnumerationSyntax
public override void WriteEnumerationSyntax (XPathNavigator reflection, SyntaxWriter writer) {
string name = (string)reflection.Evaluate(apiNameExpression);
WriteAttributeList(reflection, writer);
WriteAccessModifier(reflection, writer);
writer.WriteKeyword("enum");
writer.WriteString(" ");
writer.WriteString(name);
// no JScript support for underlying types
}
示例4: WriteInterfaceSyntax
public override void WriteInterfaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {
if (IsUnsupportedGeneric(reflection, writer)) return;
string name = (string)reflection.Evaluate(apiNameExpression);
WriteAttributeList(reflection, writer);
WriteAccessModifier(reflection, writer);
writer.WriteKeyword("interface");
writer.WriteString(" ");
writer.WriteString(name);
WriteInterfaceList("extends", reflection, writer);
}
示例5: WriteStructureSyntax
// structure: add base type
public override void WriteStructureSyntax (XPathNavigator reflection, SyntaxWriter writer) {
string name = (string) reflection.Evaluate(apiNameExpression);
bool isSerializable = (bool) reflection.Evaluate(apiIsSerializableTypeExpression);
if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
WriteAttributes(reflection, writer);
WriteVisibility(reflection, writer);
writer.WriteString(" ");
writer.WriteKeyword("Structure");
writer.WriteString(" ");
writer.WriteIdentifier(name);
WriteGenericTemplates(reflection, writer);
WriteImplementedInterfaces(reflection, writer);
}
示例6: WriteNamespaceSyntax
public override void WriteNamespaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {
string name = (string)reflection.Evaluate(apiNameExpression);
writer.WriteKeyword("package");
writer.WriteString(" ");
writer.WriteIdentifier(name);
}
示例7: WriteDelegateSyntax
public override void WriteDelegateSyntax(XPathNavigator reflection, SyntaxWriter writer)
{
string name = (string)reflection.Evaluate(apiNameExpression);
bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);
if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
WriteAttributes(reflection, writer);
writer.WriteKeyword("type");
writer.WriteString(" ");
writer.WriteIdentifier(name);
writer.WriteString(" = ");
writer.WriteLine();
writer.WriteString(" ");
writer.WriteKeyword("delegate");
writer.WriteString(" ");
writer.WriteKeyword("of");
writer.WriteString(" ");
WriteParameters(reflection, writer);
writer.WriteKeyword("->");
writer.WriteString(" ");
WriteReturnValue(reflection, writer);
}
示例8: WriteClassSyntax
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);
}
示例9: WriteGenericTemplates
private void WriteGenericTemplates(XPathNavigator type, SyntaxWriter writer, bool writeVariance)
{
XPathNodeIterator templates = type.Select(apiTemplatesExpression);
if (templates.Count == 0) return;
writer.WriteString("(");
writer.WriteKeyword("Of");
writer.WriteString(" ");
while (templates.MoveNext())
{
XPathNavigator template = templates.Current;
if (templates.CurrentPosition > 1) writer.WriteString(", ");
if (writeVariance)
{
bool contravariant = (bool)template.Evaluate(templateIsContravariantExpression);
bool covariant = (bool)template.Evaluate(templateIsCovariantExpression);
if (contravariant)
{
writer.WriteKeyword("In");
writer.WriteString(" ");
}
if (covariant)
{
writer.WriteKeyword("Out");
writer.WriteString(" ");
}
}
string name = template.GetAttribute("name", String.Empty);
writer.WriteString(name);
}
writer.WriteString(")");
}
示例10: WriteInterfaceSyntax
// interface: done
public override void WriteInterfaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {
string name = (string) reflection.Evaluate(apiNameExpression);
WriteAttributes(reflection, writer);
WriteVisibility(reflection, writer);
writer.WriteString(" ");
writer.WriteKeyword("Interface");
writer.WriteString(" ");
writer.WriteIdentifier(name);
WriteGenericTemplates(reflection, writer, true); // Need to write variance info for interfaces and delegates
WriteImplementedInterfaces(reflection, writer);
}
示例11: WriteClassSyntax
public override void WriteClassSyntax (XPathNavigator reflection, SyntaxWriter writer) {
if (IsUnsupportedGeneric(reflection, writer)) return;
string name = (string)reflection.Evaluate(apiNameExpression);
bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractTypeExpression);
bool isSealed = (bool)reflection.Evaluate(apiIsSealedTypeExpression);
WriteAttributeList(reflection, writer);
WriteAccessModifier(reflection, writer);
if (isSealed) {
writer.WriteKeyword("final");
writer.WriteString(" ");
} else if (isAbstract) {
writer.WriteKeyword("abstract");
writer.WriteString(" ");
}
writer.WriteKeyword("class");
writer.WriteString(" ");
writer.WriteString(name);
WriteBaseClass(reflection, writer);
WriteInterfaceList(reflection, writer);
}
示例12: WriteStructureSyntax
public override void WriteStructureSyntax (XPathNavigator reflection, SyntaxWriter writer) {
if (IsUnsupportedGeneric(reflection, writer)) return;
string name = (string) reflection.Evaluate(apiNameExpression);
bool isSerializable = (bool) reflection.Evaluate(apiIsSerializableTypeExpression);
if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
WriteAttributes(reflection, writer);
WriteVisibility(reflection, writer);
writer.WriteString(" ");
writer.WriteKeyword("final");
writer.WriteString(" ");
writer.WriteKeyword("class");
writer.WriteString(" ");
writer.WriteIdentifier(name);
writer.WriteString(" ");
writer.WriteKeyword("extends");
writer.WriteString(" ");
writer.WriteReferenceLink("T:System.ValueType");
WriteImplementedInterfaces(reflection, writer);
}
示例13: WriteXamlXmlnsUri
private void WriteXamlXmlnsUri(string assemblyName, string namespaceName, SyntaxWriter writer)
{
Dictionary<string, List<string>> clrNamespaces;
if (xamlAssemblies.TryGetValue(assemblyName.ToLower(), 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();
}
}
}
}
示例14: TypeDeclaration
private void TypeDeclaration (XPathNavigator reflection, SyntaxWriter writer, bool writeVariance) {
string name = (string)reflection.Evaluate(apiNameExpression);
XPathNavigator declaringType = reflection.SelectSingleNode(apiContainingTypeExpression);
writer.WriteKeyword("Dim");
writer.WriteString(" ");
writer.WriteParameter("instance");
writer.WriteString(" ");
writer.WriteKeyword("As");
writer.WriteString(" ");
if (declaringType != null) {
WriteTypeReference(declaringType, writer);
writer.WriteString(".");
}
if (reservedWords.ContainsKey(name)) {
writer.WriteString("[");
writer.WriteIdentifier(name);
writer.WriteString("]");
} else {
writer.WriteIdentifier(name);
}
WriteGenericTemplates(reflection, writer, writeVariance);
}
示例15: WriteValue
private void WriteValue(XPathNavigator parent, SyntaxWriter writer)
{
XPathNavigator type = parent.SelectSingleNode(attributeTypeExpression);
XPathNavigator value = parent.SelectSingleNode(valueExpression);
if (value == null) Console.WriteLine("null value");
switch (value.LocalName)
{
case "nullValue":
writer.WriteKeyword("null");
break;
case "typeValue":
writer.WriteKeyword("typeof");
writer.WriteString("(");
WriteTypeReference(value.SelectSingleNode(typeExpression), writer);
writer.WriteString(")");
break;
case "enumValue":
XPathNodeIterator fields = value.SelectChildren(XPathNodeType.Element);
while (fields.MoveNext())
{
string name = fields.Current.GetAttribute("name", String.Empty);
if (fields.CurrentPosition > 1) writer.WriteString("|");
WriteTypeReference(type, writer);
writer.WriteString(".");
writer.WriteString(name);
}
break;
case "value":
string text = value.Value;
string typeId = type.GetAttribute("api", String.Empty);
switch (typeId)
{
case "T:System.String":
writer.WriteString("\"");
writer.WriteString(text);
writer.WriteString("\"");
break;
case "T:System.Boolean":
bool bool_value = Convert.ToBoolean(text);
if (bool_value)
{
writer.WriteKeyword("true");
}
else
{
writer.WriteKeyword("false");
}
break;
case "T:System.Char":
writer.WriteString("'");
writer.WriteString(text);
writer.WriteString("'");
break;
}
break;
}
}