本文整理汇总了C#中Microsoft.Ddue.Tools.SyntaxWriter.WriteParameter方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxWriter.WriteParameter方法的具体用法?C# SyntaxWriter.WriteParameter怎么用?C# SyntaxWriter.WriteParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Ddue.Tools.SyntaxWriter
的用法示例。
在下文中一共展示了SyntaxWriter.WriteParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: WriteOperatorSyntax
//.........这里部分代码省略.........
break;
case "Modulus":
identifier = "Mod";
type = 2;
break;
case "IntegerDivision":
identifier = @"\";
type = 2;
break;
// binary logical operators
case "BitwiseAnd":
identifier = "And";
type = 2;
break;
case "BitwiseOr":
identifier = "Or";
type = 2;
break;
case "ExclusiveOr":
identifier = "Xor";
type = 2;
break;
// bit-array operators
case "OnesComplement":
identifier = "~";
type = -1;
break;
case "LeftShift":
identifier = "<<";
type = 2;
break;
case "RightShift":
identifier = ">>";
type = 2;
break;
// concatenation
case "Concatenate":
identifier = "&";
type = 2;
break;
case "Assign":
identifier = "=";
type = 2;
break;
// didn't recognize an operator
default:
identifier = null;
type = 0;
break;
}
}
if (identifier == null) {
writer.WriteMessage("UnsupportedOperator_" + Language);
} else {
XPathNodeIterator parameters = reflection.Select(apiParametersExpression);
if (parameters.Count != Math.Abs(type)) {
writer.WriteMessage("UnsupportedOperator_" + Language);
return;
} //throw new InvalidOperationException("An operator has the wrong number of parameters.");
WriteParameterDeclarations(reflection, writer);
ParameterDeclaration("returnValue", returnType, writer);
writer.WriteLine();
writer.WriteParameter("returnValue");
writer.WriteString(" = ");
switch (type) {
case -1:
writer.WriteIdentifier(identifier);
parameters.MoveNext();
writer.WriteParameter((string)parameters.Current.Evaluate(parameterNameExpression));
break;
case +1:
parameters.MoveNext();
writer.WriteParameter((string)parameters.Current.Evaluate(parameterNameExpression));
writer.WriteIdentifier(identifier);
break;
case 2:
writer.WriteString("(");
// parameter 1
parameters.MoveNext();
writer.WriteParameter((string)parameters.Current.Evaluate(parameterNameExpression));
writer.WriteString(" ");
writer.WriteIdentifier(identifier);
writer.WriteString(" ");
// parameter 2
parameters.MoveNext();
writer.WriteParameter((string)parameters.Current.Evaluate(parameterNameExpression));
writer.WriteString(")");
break;
}
}
}
示例3: WriteAttachedEventSyntax
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.WriteString(" ");
writer.WriteIdentifier(containingTypeName + "." + eventName);
writer.WriteString("=\"");
WriteTypeReference(eventHandler, writer);
writer.WriteString(string.Format("\" .../>"));
writer.WriteEndSubBlock();
}
示例4: 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.WriteString(" ");
writer.WriteIdentifier(propertyName);
writer.WriteString("=\"");
WriteTypeReference(returnType, writer);
writer.WriteString("\" .../>");
writer.WriteEndSubBlock();
}
示例5: WriteAttachedPropertySyntax
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.WriteString(" ");
writer.WriteIdentifier(containingTypeName + "." + propertyName);
writer.WriteString("=\"");
WriteTypeReference(returnType, writer);
writer.WriteString("\" .../>");
writer.WriteEndSubBlock();
}
}
示例6: WriteParameters
private void WriteParameters (XPathNodeIterator parameters, XPathNavigator reflection, SyntaxWriter writer) {
while (parameters.MoveNext()) {
XPathNavigator parameter = parameters.Current;
string name = (string) parameter.Evaluate(parameterNameExpression);
XPathNavigator type = parameter.SelectSingleNode(parameterTypeExpression);
bool isIn = (bool) parameter.Evaluate(parameterIsInExpression);
bool isOut = (bool) parameter.Evaluate(parameterIsOutExpression);
bool isRef = (bool) parameter.Evaluate(parameterIsRefExpression);
// bool isParamArray = (bool) parameter.Evaluate(parameterIsParamArrayExpression);
writer.WriteString("\t");
if (isIn) WriteAttribute("T:System.Runtime.InteropServices.InAttribute", writer, false);
if (isOut) WriteAttribute("T:System.Runtime.InteropServices.OutAttribute", writer, false);
if (isRef) {
writer.WriteString("/** @ref */");
}
WriteTypeReference(type, writer);
writer.WriteString(" ");
writer.WriteParameter(name);
if (parameters.CurrentPosition < parameters.Count) writer.WriteString(",");
writer.WriteLine();
}
}
示例7: WritePropertySyntax
public override void WritePropertySyntax (XPathNavigator reflection, SyntaxWriter writer) {
if (IsUnsupportedUnsafe(reflection, writer)) return;
if (IsUnsupportedExplicit(reflection, writer)) return;
string name = (string) reflection.Evaluate(apiNameExpression);
bool isGettable = (bool) reflection.Evaluate(apiIsReadPropertyExpression);
bool isSettable = (bool) reflection.Evaluate(apiIsWritePropertyExpression);
if (isGettable) {
writer.WriteString("/** @property */");
writer.WriteLine();
// write getter method
WriteAttributes(reflection, writer);
WriteProcedureModifiers(reflection, writer);
WriteReturnValue(reflection, writer);
writer.WriteString(" ");
writer.WriteIdentifier("get_" + name);
WriteMethodParameters(reflection, writer);
writer.WriteLine();
}
if (isSettable) {
writer.WriteString("/** @property */");
writer.WriteLine();
// write setter method
WriteAttributes(reflection, writer);
WriteProcedureModifiers(reflection, writer);
writer.WriteString(" ");
writer.WriteKeyword("void");
writer.WriteString(" ");
writer.WriteIdentifier("set_" + name);
// parameters
writer.WriteString("(");
WriteReturnValue(reflection, writer);
writer.WriteString(" ");
writer.WriteParameter("value");
writer.WriteString(")");
// end parameters
writer.WriteLine();
}
}
示例8: WriteEventSyntax
public override void WriteEventSyntax (XPathNavigator reflection, SyntaxWriter writer) {
string name = (string) reflection.Evaluate(apiNameExpression);
XPathNavigator handler = reflection.SelectSingleNode(apiHandlerOfEventExpression);
WriteAttributes(reflection, writer);
WriteProcedureVisibility(reflection, writer);
WritePrefixProcedureModifiers(reflection, writer);
writer.WriteString(" ");
writer.WriteKeyword("event");
writer.WriteString(" ");
WriteTypeReference(handler, writer);
writer.WriteString(" ");
writer.WriteIdentifier(name);
writer.WriteString(" {");
writer.WriteLine();
writer.WriteString("\t");
writer.WriteKeyword("void");
writer.WriteString(" ");
writer.WriteKeyword("add");
writer.WriteString(" (");
WriteTypeReference(handler, writer);
writer.WriteString(" ");
writer.WriteParameter("value");
writer.WriteString(")");
writer.WriteString(";");
writer.WriteLine();
writer.WriteString("\t");
writer.WriteKeyword("void");
writer.WriteString(" ");
writer.WriteKeyword("remove");
writer.WriteString(" (");
WriteTypeReference(handler, writer);
writer.WriteString(" ");
writer.WriteParameter("value");
writer.WriteString(")");
writer.WriteString(";");
writer.WriteLine();
writer.WriteString("}");
}
示例9: WriteParameter
// JScript has no in, out, optional, or reference parameters
private void WriteParameter (XPathNavigator parameter, SyntaxWriter writer) {
string name = (string)parameter.Evaluate(parameterNameExpression);
XPathNavigator type = parameter.SelectSingleNode(parameterTypeExpression);
bool isParamArray = (bool)parameter.Evaluate(parameterIsParamArrayExpression);
if (isParamArray) {
writer.WriteString("... ");
}
writer.WriteParameter(name);
writer.WriteString(" : ");
WriteTypeReference(type, writer);
}
示例10: WritePropertySyntax
public override void WritePropertySyntax (XPathNavigator reflection, SyntaxWriter writer) {
if (IsUnsupportedUnsafe(reflection, writer)) return;
if (IsUnsupportedExplicit(reflection, writer)) return;
if (reflection.Select(apiParametersExpression).Count > 0) {
writer.WriteMessage("UnsupportedIndex_" + Language);
return;
}
string name = (string)reflection.Evaluate(apiNameExpression);
bool isGettable = (bool)reflection.Evaluate(apiIsReadPropertyExpression);
bool isSettable = (bool)reflection.Evaluate(apiIsWritePropertyExpression);
XPathNavigator type = reflection.SelectSingleNode(apiReturnTypeExpression);
if (isGettable) {
WriteAttributeList(reflection, writer);
string getVisibility = (string)reflection.Evaluate(apiGetVisibilityExpression);
if (!String.IsNullOrEmpty(getVisibility))
{
WriteVisibility(getVisibility, writer);
writer.WriteString(" ");
}
WriteProcedureModifiers(reflection, writer);
writer.WriteKeyword("function get");
writer.WriteString(" ");
writer.WriteIdentifier(name);
writer.WriteString(" () : ");
WriteTypeReference(type, writer);
writer.WriteLine();
}
if (isSettable) {
WriteAttributeList(reflection, writer);
string setVisibility = (string)reflection.Evaluate(apiSetVisibilityExpression);
if (!String.IsNullOrEmpty(setVisibility))
{
WriteVisibility(setVisibility, writer);
writer.WriteString(" ");
}
WriteProcedureModifiers(reflection, writer);
writer.WriteKeyword("function set");
writer.WriteString(" ");
writer.WriteIdentifier(name);
writer.WriteString(" (");
writer.WriteParameter("value");
writer.WriteString(" : ");
WriteTypeReference(type, writer);
writer.WriteString(")");
}
}
示例11: ParameterDeclaration
private void ParameterDeclaration (string name, XPathNavigator type, SyntaxWriter writer) {
writer.WriteKeyword("Dim");
writer.WriteString(" ");
writer.WriteParameter(name);
writer.WriteString(" ");
writer.WriteKeyword("As");
writer.WriteString(" ");
string typeName = (string) type.Evaluate(apiNameExpression);
if (reservedWords.ContainsKey(typeName)) {
writer.WriteString("[");
WriteTypeReference(type, writer);
writer.WriteString("]");
} else {
WriteTypeReference(type, writer);
}
writer.WriteLine();
}
示例12: WriteParameters
private void WriteParameters(XPathNodeIterator parameters, XPathNavigator reflection, SyntaxWriter writer)
{
while (parameters.MoveNext())
{
XPathNavigator parameter = parameters.Current;
string name = (string)parameter.Evaluate(parameterNameExpression);
writer.WriteParameter(name);
if (parameters.CurrentPosition < parameters.Count)
{
writer.WriteString(", ");
if (writer.Position > maxPosition)
{
writer.WriteString("_");
writer.WriteLine();
writer.WriteString("\t");
}
}
}
}
示例13: WriteEventSyntax
public override void WriteEventSyntax (XPathNavigator reflection, SyntaxWriter writer) {
bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
bool isFamily = (bool)reflection.Evaluate(apiIsFamilyMemberExpression);
XPathNavigator declaringType = reflection.SelectSingleNode(apiContainingTypeExpression);
XPathNavigator handler = reflection.SelectSingleNode(apiHandlerOfEventExpression);
if (!(isStatic | isFamily)) ParameterDeclaration("instance", declaringType, writer);
ParameterDeclaration("handler", handler, writer);
// adder
writer.WriteLine();
writer.WriteKeyword("AddHandler");
writer.WriteString(" ");
WriteMemberName(reflection, writer);
writer.WriteString(", ");
writer.WriteParameter("handler");
writer.WriteLine();
}
示例14: WritePropertySyntax
public override void WritePropertySyntax (XPathNavigator reflection, SyntaxWriter writer) {
if (IsUnsupportedUnsafe(reflection, writer)) return;
bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
bool isFamily = (bool)reflection.Evaluate(apiIsFamilyMemberExpression);
XPathNavigator declaringType = reflection.SelectSingleNode(apiContainingTypeExpression);
XPathNavigator propertyType = reflection.SelectSingleNode(apiReturnTypeExpression);
bool getter = (bool)reflection.Evaluate(apiIsReadPropertyExpression);
bool setter = (bool)reflection.Evaluate(apiIsWritePropertyExpression);
if (!(isStatic || isFamily)) ParameterDeclaration("instance", declaringType, writer);
WriteParameterDeclarations(reflection, writer);
ParameterDeclaration("value", propertyType, writer);
// get value
if (getter) {
string getVisibility = (string)reflection.Evaluate(apiGetVisibilityExpression);
if (string.IsNullOrEmpty(getVisibility) || (getVisibility != "assembly" &&
getVisibility != "private" && getVisibility != "family and assembly"))
{
writer.WriteLine();
writer.WriteParameter("value");
writer.WriteString(" = ");
WriteMemberName(reflection, writer);
WritePropertyParameters(reflection, writer);
writer.WriteLine();
}
}
// set value
if (setter) {
string setVisibility = (string)reflection.Evaluate(apiSetVisibilityExpression);
if (string.IsNullOrEmpty(setVisibility) || (setVisibility != "assembly" &&
setVisibility != "private" && setVisibility != "family and assembly"))
{
writer.WriteLine();
WriteMemberName(reflection, writer);
WritePropertyParameters(reflection, writer);
writer.WriteString(" = ");
writer.WriteParameter("value");
}
}
}
示例15: WriteCastSyntax
public override void WriteCastSyntax (XPathNavigator reflection, SyntaxWriter writer) {
XPathNavigator parameter = reflection.SelectSingleNode(apiParametersExpression);
if (parameter == null) return;
XPathNavigator inputType = parameter.SelectSingleNode(typeExpression);
XPathNavigator outputType = reflection.SelectSingleNode(apiReturnTypeExpression);
if ((inputType == null) || (outputType == null)) return;
ParameterDeclaration("input", inputType, writer);
ParameterDeclaration("output", outputType, writer);
writer.WriteLine();
writer.WriteParameter("output");
writer.WriteString(" = ");
writer.WriteKeyword("CType");
writer.WriteString("(");
writer.WriteParameter("input");
writer.WriteString(", ");
WriteTypeReference(outputType, writer);
writer.WriteString(")");
}