new public int Add(EntityField val) {
			if (_entity != null)
				val.SetEntity(_entity);
			if (!Contains(val))
				return base.Add(val);
			return -1;
		}
		new public void Insert(int index, EntityField val) {
			if (_entity != null)
				val.SetEntity(_entity);
			if (Contains(val))
				Remove(val);
			Insert(index, val);
		}
		new public void Insert(int index, EntityField val) {
			if (_entity != null)
				val.SetEntity(_entity);
			if (Contains(val))
				base.Remove(val);
			if (index < 0) index = 0;
			if (index > List.Count) index = List.Count - 1;
			base.Insert(index, val);
		}
		protected virtual string GetBasicColumnProperty(EntityField field)
		{
			string txt = string.Format(
				"public {0} {1} {{\r\n"
				, field.Type
				, field.Name);
			txt += StringHelper.IndentBlock(string.Format(
				"get {{{0}}}\r\n"
				, FormatPropertyAccessorText(field, GetPropertyGetterText(field))));
			txt += StringHelper.IndentBlock(string.Format(
				"set {{{0}}}\r\n"
				, FormatPropertyAccessorText(field, GetPropertySetterText(field))));
			txt += "}";

			return txt;
		}
		protected string GetBasicColumnProperty(EntityField field, string indent)
		{
			return StringHelper.IndentBlock(
				GetBasicColumnProperty(field), 
				indent);
		}
Exemplo n.º 6
0
		public EntityFieldNameChangedEventArgs(EntityField field, string oldName, string newName)
		{
			this.EntityField = field;
			this.NewName = newName;
			this.OldName = oldName;
		}
		private void RefreshFieldSchemaInfo(PropertyInfo prop, EntityField field) 
		{
			if (field.Name == string.Empty) 
			{
				field.Name = prop.Name.Replace(" ", "");
			}
			Debug.WriteLine(prop.Name + " " + prop.PropertyType.ToString());
			field.ReadOnly = ( prop.GetSetMethod() == null );
			field.DBColumn = prop.Name;
//			field.KeyField = column.IsPrimaryKey;
//			if (field.KeyField 
//				&& this.OrmConfiguration.RenameSurrogateKeys 
//				&& this.OrmConfiguration.SurrogateKeyName != "")
//			{
//				field.Name = this.OrmConfiguration.SurrogateKeyName;
//			}
//			field.DBIdentity = column.IsAutoIncrement;
//			field.DBReadOnly = column.IsReadOnly;
//			field.DBType = GetFieldDbType(column.DataTypeId, field);
			
			field.Type = prop.PropertyType.ToString().Replace("System.", "");
			if (field.Type.IndexOf(".") > 0)
			{
				field.Type = prop.PropertyType.ToString();
			}
			foreach (object att in prop.GetCustomAttributes(true))
			{
				if (att is CategoryAttribute)
				{
					field.Category = ((CategoryAttribute)att).Category;
				}
				if (att is DescriptionAttribute)
				{
					field.Description = ((DescriptionAttribute)att).Description;
				}
				if (att is BrowsableAttribute)
				{
					field.Browsable = ((BrowsableAttribute)att).Browsable;
				}
			}
//			field.DBSize = column.Length;
//			field.DBPrecision = 8;
		}
		internal void RemoveFieldFromList(TreeNode rootNode, EntityField field)
		{
			// Looping on Child Nodes
			foreach (TreeNode tmpNode in rootNode.Nodes)
			{
				RemoveFieldFromList(tmpNode, field);
			}

			// Verify
			if (rootNode.Tag.Equals(field))
			{
				// Try to Select Previous Item
				if (rootNode.PrevVisibleNode != null && rootNode.NextVisibleNode.Tag is EntityField)
				{
					rootNode.TreeView.SelectedNode = rootNode.NextVisibleNode;
				}
				else { rootNode.TreeView.SelectedNode = rootNode.PrevVisibleNode; }

				// Remove
				rootNode.Parent.Nodes.Remove(rootNode);
			}
		}
		private void RefreshIndexDBInfo(DataRowView schema, Index index, EntityField field) 
		{
			IndexField indexField = null;
			foreach (IndexField f in index.Fields) 
			{
				if (f.Name == field.Name) 
				{
					indexField = f;
					break;
				}
			}
			if (indexField == null) 
			{
				indexField = new IndexField();
				indexField.Name = field.Name;
				index.Fields.Add(indexField);
			}
			index.DBName = (string)schema["INDEX_NAME"];
			index.PrimaryKey = (bool)schema["PRIMARY_KEY"];
			index.ForeignKey = (((string)schema["INDEX_NAME"]).Substring(0, 3) == "FK_");
			index.Unique = (bool)schema["UNIQUE"];
			if (index.Name == string.Empty) 
			{
				if (index.PrimaryKey) 
				{
					index.IsExcluded = !this.OrmConfiguration.AutoEnableMappedIndexes && !this.OrmConfiguration.AutoEnablePrimaryIndex;
					if (this.OrmConfiguration.RenamePrimaryIndex && this.OrmConfiguration.PrimaryIndexName != "") 
					{
						index.Name = this.OrmConfiguration.PrimaryIndexName;
					}
					else 
					{
						index.Name = index.DBName;
					}
					index.DeleteBy = true;
				}
				else 
				{
					index.IsExcluded = !this.OrmConfiguration.AutoEnableMappedIndexes;
					index.Name = index.DBName;
				}
			}
		}
Exemplo n.º 10
0
		private string GetFieldFullyQualifiedName(EntityField field) 
		{
			string nm = "";
			if (field.Entity != null) 
			{
				nm = "Entity=" + field.Entity.ToString() + ":";
			}
			nm += "Field=" + field.ToString();
			return nm;
		}
Exemplo n.º 11
0
		// HACK
		private string GetFieldDbType(int typeID, EntityField field) 
		{
			switch (typeID) 
			{
				case 2:
					return "smallint";
				case 3:
					return "int";
				case 4:
					return "real";
				case 5:
					return "float";
				case 6:
					return "money"; //smallmoney
				case 11:
					return "bit";
				case 17:
					return "tinyint";
				case 20:
					return "bigint";
				case 72:
					return "uniqueidentifier";
				case 128:
					return "binary";
				case 129:
					return "char";
				case 130:
					return "nchar";
				case 131:
					return "decimal"; //numeric
				case 135:
					return "datetime"; //smalldatetime
				case 200:
					return "varchar";
				case 201:
					return "text";
				case 202:
					return "nvarchar";
				case 203:
					return "ntext";
				case 204:
					return "varbinary";
				case 205:
					return "image";
				default:
					throw new InvalidOperationException("Type ID '" + typeID.ToString() + "' is not a recognized type code. (" + this.GetFieldFullyQualifiedName(field) + ")");
			}
		}
Exemplo n.º 12
0
		private void RefreshFieldDBInfo(ColumnSchema column, EntityField field) 
		{
			if (field.Name == string.Empty) 
			{
				field.Name = column.Name.Replace(" ", "");
				field.ReadOnly = column.IsReadOnly;
				field.AllowNull = column.AllowNulls;
			}
			Debug.WriteLine(
				column.Name + " " + column.DataTypeId + " " + column.DataType + " " + column.NetType + " " + column.Length + " " +
				column.DefaultValue + " " + column.DefaultTestValue);
			field.DBColumn = column.Name;
			field.KeyField = column.IsPrimaryKey;
			if (field.KeyField 
				&& this.OrmConfiguration.RenameSurrogateKeys 
				&& this.OrmConfiguration.SurrogateKeyName != "")
			{
				field.Name = this.OrmConfiguration.SurrogateKeyName;
			}
			field.DBIdentity = column.IsAutoIncrement;
			field.DBReadOnly = column.IsReadOnly;
			field.DBType = GetFieldDbType(column.DataTypeId, field);
			field.Type = column.NetType.Replace("System.", "");
			//this.VBType
			field.DBSize = column.Length;
			field.DBPrecision = 8;
		}
Exemplo n.º 13
0
		private void designView_OnInsert(object sender, EventArgs e)
		{
			if (this.designView.CurrentSelectedNode != null)
			{
				if (this.designView.CurrentSelectedNode.Tag is EntityFieldCollection)
				{
					EntityField oEntity = new EntityField();
					oEntity.Name = Const_DefaultNewFieldText;

					((EntityFieldCollection) this.designView.CurrentSelectedNode.Tag).Add(oEntity);

					this.designView.RefreshFieldsList(this.designView.CurrentSelectedNode, this.designView.CurrentEntity, true);
				}
				else if (this.designView.CurrentSelectedNode.Tag is IndexCollection)
				{
					Index oIndex = new Index();
					oIndex.Name = Const_DefaultNewIndexText;

					((IndexCollection) this.designView.CurrentSelectedNode.Tag).Add(oIndex);

					this.designView.RefreshIndexesList(this.designView.CurrentSelectedNode, this.designView.CurrentEntity, true);
				}
				else if (this.designView.CurrentSelectedNode.Tag is LinkCollection)
				{
					Link oLink = new Link();
					oLink.Name = Const_DefaultNewLinkText;

					((LinkCollection) this.designView.CurrentSelectedNode.Tag).Add(oLink);

					this.designView.RefreshLinksList(this.designView.CurrentSelectedNode, this.designView.CurrentEntity, true);
				}
			}
		}
Exemplo n.º 14
0
		private void btnAddField_Click(object sender, EventArgs e)
		{
			EntityFieldCollection fields = (EntityFieldCollection) GetSelectedItemOfType(typeof (EntityFieldCollection));
			EntityField oField = new EntityField();
			fields.Add(oField);
			IObjectEditor editor = new OREntityFieldEditor(oField);
			ObjectEditorManager.OpenObjectEditorDialog(editor);
			this.designView.RefreshFieldsList(this.GetSelectedNodeOfType(typeof(EntityFieldCollection)), this.designView.CurrentEntity, false);
		}
		public OREntityFieldEditor(EntityField field) : this() {
			_field = field;
		}
Exemplo n.º 16
0
		public void RefreshDBInfo(DataRowView schema, EntityField entityField) {
			IndexField indexField = null;
			foreach (IndexField f in this.Fields) {
				if (f.Name == entityField.Name) {
					indexField = f;
					break;
				}
			}
			if (indexField == null) {
				indexField = new IndexField();
				indexField.Name = entityField.Name;
				this.Fields.Add(indexField);
			}
			this.DBName = (string)schema["INDEX_NAME"];
			this.PrimaryKey = (bool)schema["PRIMARY_KEY"];
			this.Unique = (bool)schema["UNIQUE"];
			if (this.Name == string.Empty) {
				if (this.PrimaryKey) {
					this.Name = "PK";
					this.DeleteBy = true;
				}
				else {
					this.Name = this.DBName;
				}
			}
		}