当前位置: 首页>>代码示例>>C#>>正文


C# CodeGen.WriteIndent方法代码示例

本文整理汇总了C#中CodeGen.WriteIndent方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.WriteIndent方法的具体用法?C# CodeGen.WriteIndent怎么用?C# CodeGen.WriteIndent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeGen的用法示例。


在下文中一共展示了CodeGen.WriteIndent方法的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();
        }
开发者ID:NathanAUS,项目名称:Win2D,代码行数:35,代码来源:Program.cs

示例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();
            }
        }
开发者ID:NathanAUS,项目名称:Win2D,代码行数:82,代码来源:Program.cs


注:本文中的CodeGen.WriteIndent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。