コード例 #1
0
		private static ConditionMappingItemCollection GetMappingItemsBySubClass(RelativeAttributes attrs, MemberInfo sourceMI)
		{
			ConditionMappingItemCollection items = new ConditionMappingItemCollection();
			System.Type subType = attrs.SubClassType != null ? attrs.SubClassType.Type : GetRealType(sourceMI);

			MemberInfo[] mis = GetTypeMembers(subType);

			foreach (SubConditionMappingAttribute attr in attrs.SubClassFieldMappings)
			{
				MemberInfo mi = GetMemberInfoByName(attr.SubPropertyName, mis);

				if (mi != null)
				{
					ConditionMappingItem item = new ConditionMappingItem();

					item.PropertyName = sourceMI.Name;
					item.SubClassPropertyName = attr.SubPropertyName;
					item.MemberInfo = mi;

					if (attrs.SubClassType != null)
						item.SubClassTypeDescription = attrs.SubClassType.TypeDescription;

					FillMappingItemByAttr(item, attr);

					items.Add(item);
				}
			}

			return items;
		}
コード例 #2
0
		private static ConditionMappingItem FindItemBySubClassPropertyName(string subPropertyName, ConditionMappingItemCollection items)
		{
			ConditionMappingItem result = null;

			foreach (ConditionMappingItem item in items)
			{
				if (item.SubClassPropertyName == subPropertyName)
				{
					result = item;
					break;
				}
			}

			return result;
		}
コード例 #3
0
		private static ConditionMappingItemCollection GetMappingItems(RelativeAttributes attrs, MemberInfo mi)
		{
			ConditionMappingItemCollection items = new ConditionMappingItemCollection();

			ConditionMappingItem item = new ConditionMappingItem();
			item.PropertyName = mi.Name;
			item.DataFieldName = mi.Name;

			if (attrs.FieldMapping != null)
				FillMappingItemByAttr(item, attrs.FieldMapping);

			item.MemberInfo = mi;

			items.Add(item);

			return items;
		}
コード例 #4
0
		private static void MergeMappingItems(ConditionMappingItemCollection dest, ConditionMappingItemCollection src)
		{
			foreach (ConditionMappingItem item in src)
				dest.Add(item);
		}
コード例 #5
0
		private static ConditionMappingItemCollection CreateMappingItems(MemberInfo mi)
		{
			ConditionMappingItemCollection result = null;
			bool isDoMapping = false;

			RelativeAttributes attrs = null;

			if (mi.Name != "Item" && GetRealType(mi).GetInterface("ICollection") == null)
			{
				attrs = GetRelativeAttributes(mi);

				if (attrs.NoMapping == null)
					isDoMapping = true;
			}

			if (isDoMapping == true)
			{
				if (attrs != null)
				{
					if (attrs.SubClassFieldMappings.Count > 0)
						result = GetMappingItemsBySubClass(attrs, mi);
					else
						result = GetMappingItems(attrs, mi);
				}
			}
			else
				result = new ConditionMappingItemCollection();

			return result;
		}
コード例 #6
0
		private static ConditionMappingItemCollection GetMappingItemCollection(System.Type type)
		{
			ConditionMappingItemCollection result = new ConditionMappingItemCollection();

			MemberInfo[] mis = GetTypeMembers(type);

			foreach (MemberInfo mi in mis)
			{
				if (mi.MemberType == MemberTypes.Field || mi.MemberType == MemberTypes.Property)
				{
					ConditionMappingItemCollection items = CreateMappingItems(mi);

					MergeMappingItems(result, items);
				}
			}

			return result;
		}
コード例 #7
0
		private static WhereSqlClauseBuilder GetWhereSqlClauseBuilderFromMapping(
				object condition,
				ConditionMappingItemCollection mapping,
				bool ignoreDefaultValue,
				AdjustConditionValueDelegate acv)
		{
			WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

			foreach (ConditionMappingItem item in mapping)
			{
				object data = GetValueFromObject(item, condition);

				if (data != null)
					if (ignoreDefaultValue == false || (ignoreDefaultValue == true && IsTypeDefaultValue(item, data) == false))
					{
						bool ignored = false;

						data = AdjustValueBeforeAppendToBuilder(item, data);

						if (acv != null)
							data = acv(item.PropertyName, data, ref ignored);

						if (ignored == false)
							builder.AppendItem(item.DataFieldName, data, item.Operation, item.Template, item.IsExpression);
					}
			}

			return builder;
		}