• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ICodeWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ICodeWriter的典型用法代码示例。如果您正苦于以下问题:C# ICodeWriter类的具体用法?C# ICodeWriter怎么用?C# ICodeWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ICodeWriter类属于命名空间,在下文中一共展示了ICodeWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WritePropertyImpl

        /// <summary>
        /// 
        /// </summary>
        /// <param name="o"></param>
        /// <param name="typeName"></param>
        /// <param name="variableNameInLowerCamelCase"></param>
        /// <param name="defaultValue">Can be null</param>
        /// <param name="doesWriteGetter"></param>
        /// <param name="getterAccessibility">Can be null</param>
        /// <param name="doesWriteSetter"></param>
        /// <param name="setterAccessibility">Can be null</param>
        private static void WritePropertyImpl(ICodeWriter o, string typeName, string variableNameInLowerCamelCase, string defaultValue, bool doesWriteGetter, string getterAccessibility, bool doesWriteSetter, string setterAccessibility)
        {
            string getterAccessibilityWithSpace = "";
            string setterAccessibilityWithSpace = "";
            string defaultValueWithAssignMark = "";

            if (getterAccessibility != null)
            {
                getterAccessibilityWithSpace = getterAccessibility + " ";
            }
            if (setterAccessibility != null)
            {
                setterAccessibilityWithSpace = setterAccessibility + " ";
            }
            if (defaultValue != null)
            {
                defaultValueWithAssignMark = " = " + defaultValue;
            }

            string variableNameInUpperCamelCase = GetVariableNameInUpperCamelCase(variableNameInLowerCamelCase);

            o.BeginBlock("public {0} {1} {{", typeName, variableNameInUpperCamelCase);
            if (doesWriteGetter)
            {
                o.WriteLine("{0}get {{ return {1}; }}", getterAccessibilityWithSpace, variableNameInLowerCamelCase);
            }
            if (doesWriteSetter)
            {
                o.WriteLine("{0}set {{ {1} = value; }}", setterAccessibilityWithSpace, variableNameInLowerCamelCase);
            }
            o.EndBlock("}");
            o.WriteLine("{0} {1}{2};", typeName, variableNameInLowerCamelCase, defaultValueWithAssignMark);
        }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:44,代码来源:ClassGeneratorHelper.cs


示例2: Write

#pragma warning disable 1591
        public override void Write(ICodeWriter writer)
        {
            base.Write(writer);
            if( _extensions.Count > 0 )
            {
                writer.Newline();
                IndentMultiple(writer, 3);
                writer.WriteWithIndentation(".extend({{");
                writer.Newline();
                writer.Indent();

                foreach (var extension in _extensions)
                {
                    if (extension != _extensions[0])
                    {
                        writer.Write(",");
                        writer.Newline();
                    }
                    writer.WriteWithIndentation("{0} : {1}", extension.Name, extension.Options);
                }
                writer.Unindent();
                writer.Newline();
                writer.WriteWithIndentation("}})");
                UnindentMultiple(writer, 3);
            }
        }
开发者ID:ProCoSys,项目名称:Bifrost,代码行数:27,代码来源:Observable.cs


示例3: WriteAccessor

 public static void WriteAccessor(ICodeWriter o, string typeName, string variableNameInLowerCamelCase)
 {
     o.BeginBlock("public {0} {1} {{", typeName, GetVariableNameInUpperCamelCase(variableNameInLowerCamelCase));
     o.WriteLine("get {{ return {0}; }}", variableNameInLowerCamelCase);
     o.WriteLine("set {{ {0} = value; }}", variableNameInLowerCamelCase);
     o.EndBlock("}");
 }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:7,代码来源:ClassGeneratorHelper.cs


示例4: Render

        public void Render(ICodeWriter renderer)
        {
            if (!SingleLine)
            {
                renderer.WriteLine("");
                renderer.WriteLine("{");
                renderer.PushIndent();

                foreach (ICode codeLine in codes)
                {
                    renderer.WriteLine("{0}", codeLine);
                }

                renderer.PopIndent();
                renderer.WriteLine("}");
            }
            else
            {
                renderer.Write("{ ");

                foreach (ICode codeLine in codes)
                {
                    renderer.Write("{0}", codeLine);
                }

                renderer.Write(" }");
            }
        }
开发者ID:jorgehmv,项目名称:CsBuilder,代码行数:28,代码来源:Brace.cs


示例5: Write

#pragma warning disable 1591
        public override void Write(ICodeWriter writer)
        {
            var childIndex = 0;
            var numberOfChildren = Children.Count;

            writer.Write("{{");

            if (numberOfChildren > 0)
            {
                writer.Newline();
                writer.Indent();

                foreach (var child in Children)
                {
                    child.Write(writer);
                    childIndex++;

                    if (childIndex > 0 && childIndex < numberOfChildren)
                        writer.Write(",");
                    writer.Newline();
                }

                writer.Unindent();
                writer.WriteWithIndentation("}}");
            }
            else
            {
                writer.Write("}}");
            }
        }
开发者ID:ProCoSys,项目名称:Bifrost,代码行数:31,代码来源:ObjectLiteral.cs


示例6: Write

 public void Write(ICodeWriter o)
 {
     o.WriteLine("[Transient]");
     o.BeginBlock("internal sealed class {0} : IEventFactory {{", factoryName);
     WriteRecreateEvent(o);
     o.EndBlock("}");
 }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:7,代码来源:EventFactoryGenerator.cs


示例7: Write

#pragma warning disable 1591
        public override void Write(ICodeWriter writer)
        {
            writer.WriteWithIndentation("Bifrost.namespace(\"{0}\", ", Name);
            Content.Write(writer);
            writer.WriteWithIndentation(");");
            writer.Newline();
        }
开发者ID:ProCoSys,项目名称:Bifrost,代码行数:8,代码来源:Namespace.cs


示例8: Render

        public override void Render(ICodeWriter renderer)
        {
            renderer.Write("{0}<", name);

            string placeholders = CodeUtils.Placeholders(GenericArgumentTypes.Count());
            renderer.Write(string.Format("{0}>", placeholders), GenericArgumentTypes.ToArray());
        }
开发者ID:jorgehmv,项目名称:CsBuilder,代码行数:7,代码来源:GenericType.cs


示例9: Write

#pragma warning disable 1591
        public override void Write(ICodeWriter writer)
        {
            writer.WriteWithIndentation("{0} = ", Name);
            if( Value != null ) Value.Write(writer);
            writer.Write(";");
            writer.Newline();
        }
开发者ID:LenFon,项目名称:Bifrost,代码行数:8,代码来源:AccessorAssignment.cs


示例10: WriteEvents

 private void WriteEvents(ICodeWriter o)
 {
     foreach (EventInfo ei in eventInfos)
     {
         o.WriteLine("public event GenericEventHandler<{0}> {1};", ei.Type.Name, GetHandlerName(ei.Type.Name));
     }
 }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:7,代码来源:EventHandlersGenerator.cs


示例11: WriteSerializeFieldStatementRecursive

 private static void WriteSerializeFieldStatementRecursive(ICodeWriter o, bool writeToBitstream, Type variableType, string variableName)
 {
     if (variableType.IsArray)
     {
         Type elemType = variableType.GetElementType();
         if (writeToBitstream)
         {
             WriteStreamWriteStatement(o, variableName + ".Length");
             o.BeginBlock("for (int i = 0; i < {0}.Length; i++) {{", variableName);
             WriteSerializeFieldStatementRecursive(o, writeToBitstream, elemType, variableName + "[i]");
             o.EndBlock("}");
         }
         else
         {
             string lengthVariableName = "_" + variableName + "Length";
             o.WriteLine("int {0};", lengthVariableName);
             WriteStreamReadStatement(o, "out", lengthVariableName);
             o.WriteLine("{0} = new {1}[{2}];", variableName, elemType.ToString(), lengthVariableName);
             o.BeginBlock("for (int i = 0; i < {0}; i++) {{", lengthVariableName);
             WriteSerializeFieldStatementRecursive(o, writeToBitstream, elemType, variableName + "[i]");
             o.EndBlock("}");
         }
     }
     else
     {
         WriteSerializeNonCollectionStatement(o, writeToBitstream, variableType, variableName);
     }
 }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:28,代码来源:EventClassGenerator.cs


示例12: Render

 public override void Render(ICodeWriter renderer)
 {
     foreach (AttributeStatement attribute in attributes)
     {
         renderer.Write("{0}", attribute);
     }
     base.Render(renderer);
 }
开发者ID:jorgehmv,项目名称:CsBuilder,代码行数:8,代码来源:ParameterStatement.cs


示例13: WriteSingleton

 public static void WriteSingleton(ICodeWriter o, string className)
 {
     o.WriteLine("private static {0} instance = new {0}();", className);
     o.BeginBlock("public static {0} Instance {{", className);
     o.WriteLine("get { return instance; }");
     o.EndBlock("}");
     o.WriteLine("private {0}() {{ }}", className);
 }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:8,代码来源:ClassGeneratorHelper.cs


示例14: Render

 public override void Render(ICodeWriter renderer)
 {
     if(AccessModifier != null)
     {
         renderer.Write("{0} ", AccessModifier);
     }
     renderer.Write(snippet, name, statement);
 }
开发者ID:jorgehmv,项目名称:CsBuilder,代码行数:8,代码来源:AccesorStatement.cs


示例15: Write

 public void Write(ICodeWriter o)
 {
     o.WriteLine("[Transient]");
     o.BeginBlock("internal sealed class {0} : IEventHandlers {{", handlersName);
     WriteCallHandler(o);
     WriteEvents(o);
     o.EndBlock("}");
 }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:8,代码来源:EventHandlersGenerator.cs


示例16: Write

 public override void Write(ICodeWriter o)
 {
     WriteUsing(o);
     foreach (IGenerator generator in generators)
     {
         generator.Write(o);
     }
 }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:8,代码来源:RootGenerator.cs


示例17: Render

 public override void Render(ICodeWriter renderer)
 {
     foreach (AttributeStatement attribute in attributes)
     {
         renderer.Write("{0} ", attribute);
     }
     renderer.Write(snippet, AccessModifier, Modifier, ReturnType, name, parameterList, body);
 }
开发者ID:jorgehmv,项目名称:CsBuilder,代码行数:8,代码来源:MethodStatement.cs


示例18: Render

 public override void Render(ICodeWriter renderer)
 {
     renderer.Write("new {0}", type);
     renderer.Write(string.Format("({0})", CodeUtils.Placeholders(parameters.Count)), parameters.ToArray());
     if (initializer.HasInitiCode())
     {
         renderer.Write("{0}", initializer);
     }
 }
开发者ID:jorgehmv,项目名称:CsBuilder,代码行数:9,代码来源:NewExpression.cs


示例19: Render

        public override void Render(ICodeWriter renderer)
        {
            var bracedCode = new BracedCode(statements)
                                 {
                                     SingleLine = SingleLine
                                 };

            bracedCode.Render(renderer);
        }
开发者ID:jorgehmv,项目名称:CsBuilder,代码行数:9,代码来源:BlockStatement.cs


示例20: Render

 public override void Render(ICodeWriter renderer)
 {
     renderer.Write("{0} {1}({2})", AccessModifier, type.GetName(), parameterList);
     if (CallBaseCtor)
     {
         renderer.Write(string.Format(" : base({0})", CodeUtils.Placeholders(baseParameters.Count)), baseParameters.ToArray());
     }
     renderer.Write("{0}", body);
 }
开发者ID:jorgehmv,项目名称:CsBuilder,代码行数:9,代码来源:ConstructorStatement.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICohort类代码示例发布时间:2022-05-24
下一篇:
C# ICodeVisitor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap