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


C# CodeWriter.WriteCtor方法代码示例

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


在下文中一共展示了CodeWriter.WriteCtor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteDataContextCtor

 protected virtual bool WriteDataContextCtor(CodeWriter writer, Database schema, Type contextBaseType,
     ParameterDefinition[] parameters, string[] baseCallParameterNames, Type[] baseCallParameterTypes,
     GenerationContext context)
 {
     // if we have a contextBaseType, then check that we can do it
     if (contextBaseType != null)
     {
         var ctor = contextBaseType.GetConstructor(baseCallParameterTypes);
         if (ctor == null)
             return false;
     }
     using (writer.WriteCtor(SpecificationDefinition.Public, schema.Class, parameters, baseCallParameterNames))
     {
         writer.WriteLine(writer.GetStatement(writer.GetMethodCallExpression("OnCreated")));
     }
     writer.WriteLine();
     return true;
 }
开发者ID:nlhepler,项目名称:mono,代码行数:18,代码来源:CodeGenerator.Context.Ctor.cs

示例2: WriteClassCtor

 /// <summary>
 /// Writes class ctor.
 /// EntitySet initializations
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="table"></param>
 /// <param name="schema"></param>
 /// <param name="context"></param>
 protected virtual void WriteClassCtor(CodeWriter writer, Table table, Database schema, GenerationContext context)
 {
     using (writer.WriteRegion("ctor"))
     using (writer.WriteCtor(SpecificationDefinition.Public, table.Type.Name, new ParameterDefinition[0], null))
     {
         // children are EntitySet
         foreach (var child in GetClassChildren(table))
         {
             // if the association has a storage, we use it. Otherwise, we use the property name
             var entitySetMember = child.Storage ?? child.Member;
             writer.WriteLine(writer.GetStatement(
                 writer.GetAssignmentExpression(
                     entitySetMember,
                     writer.GetNewExpression(writer.GetMethodCallExpression(
                         writer.GetGenericName(TypeExtensions.GetShortName(typeof(EntitySet<>)), child.Type),
                         GetChildAttachMethodName(child),
                         GetChildDetachMethodName(child)
                     ))
                 )
                 ));
         }
         // the parents are the entities referenced by a FK. So a "parent" is an EntityRef
         foreach (var parent in GetClassParents(table))
         {
             var entityRefMember = parent.Storage;
             writer.WriteLine(writer.GetStatement(
                 writer.GetAssignmentExpression(
                     entityRefMember,
                     writer.GetNewExpression(writer.GetMethodCallExpression(
                     writer.GetGenericName(TypeExtensions.GetShortName(typeof(EntityRef<>)), parent.Type)
                     ))
                 )
             ));
         }
         writer.WriteLine(writer.GetStatement(writer.GetMethodCallExpression("OnCreated")));
     }
 }
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:45,代码来源:CodeGenerator.Class.cs


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