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


C# IPropertyMap.GetFieldName方法代码示例

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


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

示例1: GetFieldInfo

		/// <summary>
		/// Fetches a FieldInfo for a specific property in a given type
		/// </summary>
		/// <param name="propertyMap"></param>
		/// <param name="type"></param>
		/// <param name="propertyName"></param>
		/// <returns></returns>
		//[DebuggerStepThrough()]
		public static FieldInfo GetFieldInfo(IPropertyMap propertyMap, Type type, string propertyName)
		{
			Hashtable fieldLookup = FieldLookup(type);
			if (fieldLookup != null)
			{
				if (!fieldLookup.ContainsKey(propertyName))
				{
					FieldInfo fieldInfo = type.GetField(propertyMap.GetFieldName(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
				
					if (fieldInfo == null) //field was not found in this type
						fieldInfo = GetFieldInfo(propertyMap, type.BaseType, propertyName); //fetch the field from the base class

					lock(syncRoot)
					{
						if (!fieldLookup.ContainsKey(propertyName))
						{
							fieldLookup.Add(propertyName, fieldInfo); //cache the field info with this type , even if the field was found in a super class
						}
					}
				}				
				return fieldLookup[propertyName] as FieldInfo;
			}
			return null;
		}
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:32,代码来源:ReflectionHelper.cs

示例2: GenerateDLinqPrimitiveProperty

        public static CodeMemberProperty GenerateDLinqPrimitiveProperty(IClassMap classMap, IPropertyMap propertyMap)
        {
            string fieldName = propertyMap.GetFieldName();

            return GenerateDLinqPrimitiveProperty(propertyMap, propertyMap.Name, fieldName, propertyMap.DataType);
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:6,代码来源:CodeDomGenerator.cs

示例3: GenerateDLinqPrimitiveField

        public static CodeMemberField GenerateDLinqPrimitiveField(IClassMap classMap, IPropertyMap propertyMap)
        {
            string fieldName = propertyMap.GetFieldName();

            CodeMemberField fieldMember = new CodeMemberField() ;
            fieldMember.Name = fieldName;

            CodeTypeReference typeReference = new CodeTypeReference(propertyMap.DataType);
            fieldMember.Type = typeReference;

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

示例4: PropertyMapToCodeMemberProperty

        private CodeMemberProperty PropertyMapToCodeMemberProperty(IPropertyMap propertyMap)
        {
            CodeMemberProperty propertyMember = new CodeMemberProperty() ;
            propertyMember.Name = propertyMap.Name ;

            CodeTypeReference typeReference = new CodeTypeReference(propertyMap.DataType);
            propertyMember.Type  = typeReference;

            propertyMember.Attributes = MemberAttributes.Public;
            string fieldName = propertyMap.GetFieldName() ;

            CodeThisReferenceExpression thisReferenceExpression = new CodeThisReferenceExpression();
            CodeFieldReferenceExpression fieldReferenceExpression = new CodeFieldReferenceExpression(thisReferenceExpression, fieldName) ;

            propertyMember.HasGet = true;
            CodeMethodReturnStatement getMethodReturnStatement = new CodeMethodReturnStatement(fieldReferenceExpression);
            propertyMember.GetStatements.Add(getMethodReturnStatement);

            if (!propertyMap.IsReadOnly)
            {
                propertyMember.HasSet = true;
                CodeVariableReferenceExpression valueReferenceExpression = new CodeVariableReferenceExpression("value");
                CodeAssignStatement setMethodAssignStatement = new CodeAssignStatement(fieldReferenceExpression, valueReferenceExpression);
                propertyMember.SetStatements.Add(setMethodAssignStatement);
            }

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

示例5: PropertyMapToCodeMemberField

        private CodeMemberField PropertyMapToCodeMemberField(IPropertyMap propertyMap)
        {
            string fieldName = propertyMap.GetFieldName() ;
            CodeMemberField fieldMember = new CodeMemberField(propertyMap.DataType, fieldName) ;

            fieldMember.Attributes = MemberAttributes.Private ;

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


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