Inheritance: IVisitable
コード例 #1
0
		/// <summary>
		/// Visits the field.
		/// </summary>
		/// <param name="model">The model.</param>
		public override void VisitField(FieldModel model)
		{
			FieldAttribute att = model.FieldAtt;

			if (AppliesToCurrentTable(att))
			{
				WriteProperty(model.Field.Name, model.Field.FieldType, att.AccessString,
							  att.ColumnType, att.Insert,
							  att.Update, att.Formula, att.Column,
							  att.Length, att.NotNull, att.Unique, att.UniqueKey, att.SqlType, att.Index, att.Check, att.Default);
			}
		}
コード例 #2
0
		/// <summary>
		/// Visits the field.
		/// </summary>
		/// <remarks>
		/// Infer column name and nullablity
		/// </remarks>
		/// <param name="model">The model.</param>
		public override void VisitField(FieldModel model)
		{
			if (model.FieldAtt.Column == null)
			{
				model.FieldAtt.Column = model.Field.Name;
			}

			// Append column prefix
			model.FieldAtt.Column = columnPrefix + model.FieldAtt.Column;

			Type fieldType = model.Field.FieldType;

			if (NHibernateNullablesSupport.IsNHibernateNullableType(fieldType) &&
			    (model.FieldAtt.ColumnType == null || model.FieldAtt.ColumnType.Length == 0))
			{
				model.FieldAtt.NotNull = false;
				model.FieldAtt.ColumnType = NHibernateNullablesSupport.GetITypeTypeNameForNHibernateNullable(fieldType);
			}

			if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof (Nullable<>) &&
			    String.IsNullOrEmpty(model.FieldAtt.ColumnType))
			{
				model.FieldAtt.NotNull = false;
				model.FieldAtt.ColumnType = ObtainNullableTypeNameForCLRNullable(fieldType);
			}

			JoinedTableModel joinedTable = ObtainJoinedTableIfPresent(model.Field, model.FieldAtt);

			if (joinedTable != null)
			{
				joinedTable.Fields.Add(model);
			}
		}
コード例 #3
0
 /// <summary>
 /// Visits the field.
 /// </summary>
 /// <param name="model">The model.</param>
 public virtual void VisitField(FieldModel model)
 {
 }
コード例 #4
0
		/// <summary>
		/// Visits the field.
		/// </summary>
		/// <param name="model">The model.</param>
		public override void VisitField(FieldModel model)
		{
			FieldAttribute att = model.FieldAtt;

			WriteProperty(model.Field.Name, model.Field.FieldType, att.AccessString,
			              att.ColumnType, att.Insert,
			              att.Update, att.Formula, att.Column,
			              att.Length, att.NotNull, att.Unique, att.UniqueKey, att.SqlType, att.Index, att.Check);
		}
コード例 #5
0
		public bool CanHandle(FieldModel field)
		{
			return CanHandleType(field.Field.FieldType);
		}
コード例 #6
0
		public String CreateControl(ActiveRecordModel model, String prefix, 
		                            FieldModel fieldModel, object instance)
		{
			stringBuilder.Length = 0;

			FieldInfo fieldInfo = fieldModel.Field;

			String propName = CreatePropName(model, prefix, fieldInfo.Name);

			if (fieldInfo.FieldType == typeof(DateTime))
			{
				stringBuilder.Append(LabelFor(propName + "day", TextHelper.PascalCaseToWord(fieldInfo.Name) + ": &nbsp;"));
			}
			else
			{
				stringBuilder.Append(LabelFor(propName, TextHelper.PascalCaseToWord(fieldInfo.Name) + ": &nbsp;"));
			}

			FieldAttribute propAtt = fieldModel.FieldAtt;

			RenderAppropriateControl(model, fieldInfo.FieldType, propName, null, null,
			                         propAtt.Unique, propAtt.NotNull, propAtt.ColumnType, propAtt.Length);

			return stringBuilder.ToString();
		}
コード例 #7
0
 /// <summary>
 /// Visits the field.
 /// </summary>
 /// <param name="model">The model.</param>
 public virtual void VisitField(FieldModel model)
 {
 }