當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。