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


C# IClassMap.GetName方法代码示例

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


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

示例1: GenerateFactoryMethod

        public static CodeMemberMethod GenerateFactoryMethod(IClassMap classMap, IList propertyMaps)
        {
            CodeMemberMethod methodMember = new CodeMemberMethod() ;
            methodMember.Name = GetFactoryMethodName(classMap);

            CodeTypeReference typeReference = new CodeTypeReference(classMap.GetName());
            methodMember.ReturnType = typeReference;

            methodMember.Attributes = MemberAttributes.Public;

            foreach(IPropertyMap propertyMap in propertyMaps)
            {
                CodeParameterDeclarationExpression parameter = new CodeParameterDeclarationExpression(new CodeTypeReference(propertyMap.DataType), MakeCamelCase(propertyMap.Name));
                methodMember.Parameters.Add(parameter);
            }

            CodeThisReferenceExpression thisExp = new CodeThisReferenceExpression();
            CodeFieldReferenceExpression contextVar = new CodeFieldReferenceExpression(thisExp, "context");

            CodeTypeOfExpression typeOfExp = new CodeTypeOfExpression(typeReference) ;
            CodeMethodInvokeExpression newObjectInit = new CodeMethodInvokeExpression(contextVar, "CreateObject", new CodeExpression[] { typeOfExp } ) ;

            CodeCastExpression castExp = new CodeCastExpression(typeReference, newObjectInit) ;

            CodeVariableDeclarationStatement newObjectVarDecl = new CodeVariableDeclarationStatement(classMap.GetName(), MakeCamelCase(classMap.GetName()), castExp) ;
            CodeVariableReferenceExpression newObjectVar = new CodeVariableReferenceExpression(MakeCamelCase(classMap.GetName()));

            methodMember.Statements.Add(newObjectVarDecl);

            foreach(IPropertyMap propertyMap in propertyMaps)
            {
                CodeArgumentReferenceExpression argExp = new CodeArgumentReferenceExpression(MakeCamelCase(propertyMap.Name));
                CodeVariableReferenceExpression propExp = new CodeVariableReferenceExpression(MakeCamelCase(classMap.Name) + "." + propertyMap.Name);
                CodeAssignStatement assignStatement = new CodeAssignStatement(propExp, argExp);
                methodMember.Statements.Add(assignStatement);
            }

            CodeMethodInvokeExpression commitCtx = new CodeMethodInvokeExpression(contextVar, "Commit", new CodeExpression[] {} ) ;

            methodMember.Statements.Add(commitCtx);

            CodeMethodReturnStatement returnStmt = new CodeMethodReturnStatement(newObjectVar) ;

            methodMember.Statements.Add(returnStmt);

            return methodMember;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:47,代码来源:CodeDomGenerator.cs

示例2: GetFactoryMethodName

		public static string GetFactoryMethodName(IClassMap classMap)
		{		
			string name = "Create" + classMap.GetName() ;

			return name;
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:6,代码来源:CodeDomGenerator.cs

示例3: GetFactoryClassName

		public static string GetFactoryClassName(IClassMap classMap)
		{		
			string name = classMap.GetName() + "Factory" ;

			return name;
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:6,代码来源:CodeDomGenerator.cs

示例4: GenerateRepositoryGetByIdentityMethod

        public static void GenerateRepositoryGetByIdentityMethod(IClassMap classMap, CodeTypeDeclaration classDecl, bool tryMethod)
        {
            IList propertyMaps = classMap.GetIdentityPropertyMaps();

            CodeMemberMethod methodMember = new CodeMemberMethod() ;
            if (tryMethod)
                methodMember.Name = GetRepositoryGetByIdentityMethodName(classMap);
            else
                methodMember.Name = GetRepositoryTryGetByIdentityMethodName(classMap);

            CodeTypeReference typeReference = new CodeTypeReference(classMap.GetName());
            methodMember.ReturnType = typeReference;

            methodMember.Attributes = MemberAttributes.Public;

            foreach(IPropertyMap propertyMap in propertyMaps)
            {
                CodeParameterDeclarationExpression parameter = new CodeParameterDeclarationExpression(new CodeTypeReference(propertyMap.DataType), MakeCamelCase(propertyMap.Name));
                methodMember.Parameters.Add(parameter);
            }

            CodeThisReferenceExpression thisExp = new CodeThisReferenceExpression();
            CodeFieldReferenceExpression contextVar = new CodeFieldReferenceExpression(thisExp, "context");

            CodeVariableDeclarationStatement dummyObjectVarDecl = new CodeVariableDeclarationStatement(classMap.GetName(), "identityObject") ;
            CodeVariableReferenceExpression dummyObjectVar = new CodeVariableReferenceExpression("identityObject");

            CodeObjectCreateExpression dummyObjectCreateExpr = new CodeObjectCreateExpression(typeReference, new CodeExpression[] {} );

            CodeAssignStatement assignDummyStatement = new CodeAssignStatement(dummyObjectVar, dummyObjectCreateExpr);

            methodMember.Statements.Add(dummyObjectVarDecl);
            methodMember.Statements.Add(assignDummyStatement);

            foreach(IPropertyMap propertyMap in propertyMaps)
            {
                CodeArgumentReferenceExpression argExp = new CodeArgumentReferenceExpression(MakeCamelCase(propertyMap.Name));
                CodeVariableReferenceExpression propExp = new CodeVariableReferenceExpression("identityObject" + "." + propertyMap.Name);
                CodeAssignStatement assignStatement = new CodeAssignStatement(propExp, argExp);
                methodMember.Statements.Add(assignStatement);
            }

            CodeTypeOfExpression typeOfExp = new CodeTypeOfExpression(typeReference) ;
            CodeMethodInvokeExpression newObjectInit = null;
            if (tryMethod)
                newObjectInit = new CodeMethodInvokeExpression(contextVar, "GetObjectById", new CodeExpression[] { dummyObjectVar, typeOfExp } ) ;
            else
                newObjectInit = new CodeMethodInvokeExpression(contextVar, "TryGetObjectById", new CodeExpression[] { dummyObjectVar, typeOfExp } ) ;

            CodeCastExpression castExp = new CodeCastExpression(typeReference, newObjectInit) ;

            CodeVariableDeclarationStatement newObjectVarDecl = new CodeVariableDeclarationStatement(classMap.GetName(), MakeCamelCase(classMap.GetName()), castExp) ;
            CodeVariableReferenceExpression newObjectVar = new CodeVariableReferenceExpression(MakeCamelCase(classMap.GetName()));

            methodMember.Statements.Add(newObjectVarDecl);

            CodeMethodReturnStatement returnStmt = new CodeMethodReturnStatement(newObjectVar) ;

            methodMember.Statements.Add(returnStmt);

            classDecl.Members.Add(methodMember);
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:62,代码来源:CodeDomGenerator.cs

示例5: GenerateRepositoryUpdateObjectMethod

        public static void GenerateRepositoryUpdateObjectMethod(IClassMap classMap, CodeTypeDeclaration classDecl)
        {
            IList propertyMaps = classMap.GetAllPropertyMaps();
            IList idPropertyMaps = classMap.GetIdentityPropertyMaps();

            CodeMemberMethod methodMember = new CodeMemberMethod() ;
            methodMember.Name = GetRepositoryUpdateObjectMethodName(classMap);

            CodeTypeReference typeReference = new CodeTypeReference(classMap.GetName());
            methodMember.ReturnType = typeReference;

            methodMember.Attributes = MemberAttributes.Public;

            foreach(IPropertyMap propertyMap in propertyMaps)
            {
                if (!propertyMap.IsCollection)
                {
                    CodeParameterDeclarationExpression parameter = new CodeParameterDeclarationExpression(new CodeTypeReference(propertyMap.DataType), MakeCamelCase(propertyMap.Name));
                    methodMember.Parameters.Add(parameter);
                }
            }

            CodeThisReferenceExpression thisExp = new CodeThisReferenceExpression();
            CodeFieldReferenceExpression contextVar = new CodeFieldReferenceExpression(thisExp, "context");

            CodeExpression[] createParams = new CodeExpression[idPropertyMaps.Count];

            int i = 0;
            foreach(IPropertyMap idPropertyMap in idPropertyMaps)
            {
                CodeArgumentReferenceExpression argExp = new CodeArgumentReferenceExpression(MakeCamelCase(idPropertyMap.Name));
                createParams[i] = argExp;
                i++;
            }

            CodeMethodInvokeExpression newObjectInit = new CodeMethodInvokeExpression(thisExp, GetRepositoryGetByIdentityMethodName(classMap), createParams ) ;

            CodeVariableDeclarationStatement newObjectVarDecl = new CodeVariableDeclarationStatement(classMap.GetName(), MakeCamelCase(classMap.GetName()), newObjectInit) ;
            CodeVariableReferenceExpression newObjectVar = new CodeVariableReferenceExpression(MakeCamelCase(classMap.GetName()));

            methodMember.Statements.Add(newObjectVarDecl);

            foreach(IPropertyMap propertyMap in propertyMaps)
            {
                if (!propertyMap.IsIdentity)
                {
                    if (!propertyMap.IsCollection)
                    {
                        CodeArgumentReferenceExpression argExp = new CodeArgumentReferenceExpression(MakeCamelCase(propertyMap.Name));
                        CodeVariableReferenceExpression propExp = new CodeVariableReferenceExpression(MakeCamelCase(classMap.Name) + "." + propertyMap.Name);
                        CodeAssignStatement assignStatement = new CodeAssignStatement(propExp, argExp);
                        methodMember.Statements.Add(assignStatement);
                    }
                }
            }

            CodeMethodInvokeExpression commitCtx = new CodeMethodInvokeExpression(contextVar, "Commit", new CodeExpression[] {} ) ;

            methodMember.Statements.Add(commitCtx);

            CodeMethodReturnStatement returnStmt = new CodeMethodReturnStatement(newObjectVar) ;

            methodMember.Statements.Add(returnStmt);

            classDecl.Members.Add(methodMember);
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:66,代码来源:CodeDomGenerator.cs

示例6: GenerateRepositoryGetAllObjectsMethod

        public static void GenerateRepositoryGetAllObjectsMethod(IClassMap classMap, CodeTypeDeclaration classDecl)
        {
            CodeMemberMethod methodMember = new CodeMemberMethod() ;
            methodMember.Name = GetRepositoryGetAllObjectsMethodName(classMap);

            CodeTypeReference typeReference = new CodeTypeReference(classMap.GetName());
            CodeTypeReference listTypeReference = new CodeTypeReference(typeof(IList));
            methodMember.ReturnType = listTypeReference;

            methodMember.Attributes = MemberAttributes.Public;

            CodeThisReferenceExpression thisExp = new CodeThisReferenceExpression();
            CodeFieldReferenceExpression contextVar = new CodeFieldReferenceExpression(thisExp, "context");

            CodeTypeOfExpression typeOfExp = new CodeTypeOfExpression(typeReference) ;

            CodeMethodInvokeExpression listInit = new CodeMethodInvokeExpression(contextVar, "GetObjects", new CodeExpression[] { typeOfExp } ) ;

            CodeVariableDeclarationStatement listVarDecl = new CodeVariableDeclarationStatement(typeof(IList), "list", listInit) ;
            CodeVariableReferenceExpression listVar = new CodeVariableReferenceExpression("list");

            methodMember.Statements.Add(listVarDecl);

            CodeMethodReturnStatement returnStmt = new CodeMethodReturnStatement(listVar) ;

            methodMember.Statements.Add(returnStmt);

            classDecl.Members.Add(methodMember);
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:29,代码来源:CodeDomGenerator.cs

示例7: GenerateRepositoryDeleteObjectMethod

        public static void GenerateRepositoryDeleteObjectMethod(IClassMap classMap, CodeTypeDeclaration classDecl)
        {
            CodeMemberMethod methodMember = new CodeMemberMethod() ;
            methodMember.Name = GetRepositoryDeleteObjectMethodName(classMap);

            CodeTypeReference typeReference = new CodeTypeReference(classMap.GetName());

            methodMember.Attributes = MemberAttributes.Public;

            CodeParameterDeclarationExpression parameter = new CodeParameterDeclarationExpression(typeReference, MakeCamelCase(classMap.GetName()));
            methodMember.Parameters.Add(parameter);

            CodeArgumentReferenceExpression argExp = new CodeArgumentReferenceExpression(MakeCamelCase(classMap.GetName()));

            CodeThisReferenceExpression thisExp = new CodeThisReferenceExpression();
            CodeFieldReferenceExpression contextVar = new CodeFieldReferenceExpression(thisExp, "context");

            CodeMethodInvokeExpression deleteCall = new CodeMethodInvokeExpression(contextVar, "DeleteObject", new CodeExpression[] { argExp } ) ;

            methodMember.Statements.Add(deleteCall);

            CodeMethodInvokeExpression commitCtx = new CodeMethodInvokeExpression(contextVar, "Commit", new CodeExpression[] {} ) ;

            methodMember.Statements.Add(commitCtx);

            classDecl.Members.Add(methodMember);
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:27,代码来源:CodeDomGenerator.cs

示例8: GetDLinqClassName

        public static string GetDLinqClassName(IClassMap classMap)
        {
            string name = classMap.GetName() ;

            return name;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:6,代码来源:CodeDomGenerator.cs

示例9: GetClassDeclaration

 private string GetClassDeclaration(IClassMap classMap, ICodeMap codeMap)
 {
     if (codeMap.CodeLanguage == CodeLanguage.CSharp)
         return "public class " + classMap.GetName();
     if (codeMap.CodeLanguage == CodeLanguage.VB)
         return "Public Class " + classMap.GetName();
     throw new IAmOpenSourcePleaseImplementMeException("");
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:8,代码来源:ModelToCodeTransformer.cs

示例10: ClassMapToCodeNamespace

        private CodeNamespace ClassMapToCodeNamespace(IClassMap classMap)
        {
            CodeNamespace domainNamespace = new CodeNamespace(classMap.GetFullNamespace()) ;
            CodeTypeDeclaration classDecl = new CodeTypeDeclaration(classMap.GetName()) ;

            if (classMap.ClassType == ClassType.Default || classMap.ClassType == ClassType.Class)
            {
                classDecl.IsClass = true;

                IClassMap super = classMap.GetInheritedClassMap();

                if (super != null)
                {
                    CodeTypeReference superDecl = new CodeTypeReference(super.GetFullName()) ;
                    classDecl.BaseTypes.Add(superDecl);
                }

                foreach (IPropertyMap propertyMap in classMap.PropertyMaps)
                {
                    classDecl.Members.Add(PropertyMapToCodeMemberField(propertyMap));
                    classDecl.Members.Add(PropertyMapToCodeMemberProperty(propertyMap));
                }

            }
            else if (classMap.ClassType == ClassType.Enum)
            {
                classDecl.IsEnum = true;

                foreach (IEnumValueMap enumValueMap in classMap.GetEnumValueMaps())
                {
                    classDecl.Members.Add(EnumValueMapToCodeMemberField(enumValueMap));
                }
            }

            domainNamespace.Types.Add(classDecl);

            return domainNamespace;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:38,代码来源:ModelToCodeTransformer.cs


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