本文整理汇总了C#中CodeGen.Write方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.Write方法的具体用法?C# CodeGen.Write怎么用?C# CodeGen.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.Write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutputClassMethodMockDeclarations
static void OutputClassMethodMockDeclarations(CodeGen.Formatter output, CodeGen.Interface classData, Dictionary<string, CodeGen.QualifiableType> typeDictionary)
{
foreach (CodeGen.Interface.Method m in classData.Methods)
{
if (m.IsOverload) continue;
output.WriteIndent();
output.Write("CALL_COUNTER_WITH_MOCK(" + m.Name + "Method, ");
if (m.ReturnsHResult())
{
output.Write("HRESULT");
}
else
{
output.Write(typeDictionary[m.NativeReturnType].NativeName);
}
output.Write("(");
for (int i=0; i<m.Parameters.Count; i++)
{
output.Write(GetParameterTypeNameIncludingIndirection(m.Parameters[i], typeDictionary));
if(m.Parameters[i].IsArray)
{
output.Write(", UINT32");
}
if (i < m.Parameters.Count - 1) output.Write(", ");
}
output.Write("));");
output.WriteLine();
}
output.WriteLine();
}
示例2: OutputClassMethodDefinitions
static void OutputClassMethodDefinitions(CodeGen.Formatter output, CodeGen.Interface classData, Dictionary<string, CodeGen.QualifiableType> typeDictionary)
{
output.WriteLine("//");
output.WriteLine("// " + classData.NativeName);
output.WriteLine("//");
output.WriteLine();
foreach (CodeGen.Interface.Method m in classData.Methods)
{
if (m.IsOverload) continue;
output.WriteIndent();
if (m.ReturnsHResult())
{
output.Write("STDMETHOD(" + m.Name + ")(");
}
else
{
output.Write("STDMETHOD_(" + typeDictionary[m.NativeReturnType].NativeName + ", " + m.Name + ")(");
}
output.Indent();
for (int i = 0; i < m.Parameters.Count; i++)
{
output.WriteLine();
string parameterString = GetParameterTypeNameIncludingIndirection(m.Parameters[i], typeDictionary) + " " + m.Parameters[i].Name;
output.WriteIndent();
output.Write(parameterString);
if(m.Parameters[i].IsArray)
{
output.Write(",");
output.WriteLine();
output.WriteIndent();
output.Write("UINT32 " + m.Parameters[i].Name + "Count");
}
if(i < m.Parameters.Count - 1)
{
output.Write(",");
}
}
string constString = m.IsConst ? " const" : "";
output.Write(")" + constString + " override");
output.WriteLine();
output.Unindent();
output.WriteLine("{");
output.Indent();
output.WriteIndent();
if (m.NativeReturnType != "void")
{
output.Write("return ");
}
output.Write(m.Name + "Method.WasCalled(");
for (int i = 0; i < m.Parameters.Count; i++)
{
output.Write(m.Parameters[i].Name);
if(m.Parameters[i].IsArray)
{
output.Write(", " + m.Parameters[i].Name + "Count");
}
if (i < m.Parameters.Count - 1) output.Write(", ");
}
output.Write(");");
output.WriteLine();
output.Unindent();
output.WriteLine("}");
output.WriteLine();
}
}