Esempio n. 1
0
 public void SetMember(Member m)
 {
     if (m == null || !(m is Field))
         field = null;
     else
         field = (Field)m;
     if (m != null)
     {
         memberName = m.Name;
         memberType = m.Type;
     }
     UpdateValues();
 }
		/// <exception cref="BadSyntaxException">
		/// The <paramref name="field"/> contains invalid modifier combinations.
		/// </exception>
		protected internal override void ValidateField(Field field)
		{
			if (field.IsConstant) {
				if (field.IsStatic) {
					throw new BadSyntaxException(string.Format(
						Strings.ErrorInvalidModifierCombination, "static", "const"));
				}
				if (field.IsReadonly) {
					throw new BadSyntaxException(string.Format(
						Strings.ErrorInvalidModifierCombination, "readonly", "const"));
				}
				if (field.IsVolatile) {
					throw new BadSyntaxException(string.Format(
						Strings.ErrorInvalidModifierCombination, "volatile", "const"));
				}
			}
			if (field.IsReadonly && field.IsVolatile) {
				throw new BadSyntaxException(string.Format(
					Strings.ErrorInvalidModifierCombination, "volatile", "readonly"));
			}
		}
Esempio n. 3
0
 void LoadSchemaInfo(XmlElement child, Field field)
 {
     field.GenerateDbColumn = child.GetAttributeValue("GenColumn", false);
     if (field.GenerateDbColumn)
     {
         field.DbSchema.Initialing = true;
         field.DbSchema.Name = child.GetAttributeValue("Name", "");
         field.DbSchema.NotNull = child.GetAttributeValue("NotNull", false);
         field.DbSchema.AutoIncrement = child.GetAttributeValue("AutoIncrement", false);
         field.DbSchema.DbType = child.GetAttributeValue<System.Data.DbType?>("DbType", null);
         field.DbSchema.DefaultValue = child.GetAttributeValue("DefaultValue", "");
         field.DbSchema.Index = child.GetAttributeValue("Index", false);
         field.DbSchema.IsPrimaryKey = child.GetAttributeValue("IsPrimaryKey", false);
         field.DbSchema.Length = child.GetAttributeValue("Length", "");
         field.DbSchema.Initialing = false;
     }
 }
Esempio n. 4
0
 void SaveSchemaInfo(XmlElement child, Field field)
 {
     if (field.GenerateDbColumn)
     {
         child.SetAttribute("GenColumn", field.GenerateDbColumn.ToString());
         child.SetAttribute("Name", field.DbSchema.Name);
         child.SetAttribute("DbType", field.DbSchema.DbType.ToString());
         if (field.DbSchema.NotNull)
             child.SetAttribute("NotNull", "true");
         if (field.DbSchema.AutoIncrement)
             child.SetAttribute("AutoIncrement", "true");
         if (field.DbSchema.DefaultValue.IsNotEmpty())
             child.SetAttribute("DefaultValue", field.DbSchema.DefaultValue);
         if (field.DbSchema.Index)
             child.SetAttribute("Index", "true");
         if (field.DbSchema.IsPrimaryKey)
             child.SetAttribute("IsPrimaryKey", "true");
         if (field.DbSchema.Length.IsNotEmpty())
             child.SetAttribute("Length", field.DbSchema.Length);
     }
 }
Esempio n. 5
0
		protected void AddField(Field field)
		{
			if (field != null && !FieldList.Contains(field))
			{
				fields.Add(field);
				field.Modified += delegate { Changed(); };
				Changed();
			}
		}
Esempio n. 6
0
		/// <exception cref="BadSyntaxException">
		/// The <paramref name="field"/> contains invalid modifier combinations.字段包括無效的修飾組合
		/// </exception>
		protected internal abstract void ValidateField(Field field);
        //void AddNewItem(ListViewItem item)
        //{
        //    try
        //    {
        //        item.Focused = true;
        //        item.Selected = true;
        //    }
        //    catch { }
        //}

        //void AddNewField(Field field)
        //{
        //    ListViewItem item = AddFieldToList(field);
        //    NewMemberType = MemberType.Field;
        //    AddNewItem(item);
        //}

        //void AddNewOperation(Operation operation)
        //{
        //    ListViewItem item = AddOperationToList(operation);
        //    NewMemberType = operation.MemberType;
        //    AddNewItem(item);
        //}

        ListViewItem AddFieldToList(Field field)
        {
            if (field == null)
                throw new ArgumentNullException("field");

            ListViewItem item = lstMembers.Items.Insert(attributeCount, "");

            item.Tag = field;
            item.ImageIndex = Icons.GetImageIndex(field);
            item.SubItems.Add(field.Name);
            item.SubItems.Add(field.Type);
            item.SubItems.Add(field.Language.GetAccessString(field.AccessModifier));
            item.SubItems.Add(field.Language.GetFieldModifierString(field.Modifier));
            item.SubItems.Add(field.GenerateDbColumn.ToString());
            item.SubItems.Add(field.DbSchema.Name);
            item.SubItems.Add(field.DbSchema.DbType.ToSafeString());
            item.SubItems.Add(field.DbSchema.Length);
            item.SubItems.Add(field.DbSchema.NotNull.ToString());
            item.SubItems.Add(field.DbSchema.IsPrimaryKey.ToString());
            item.SubItems.Add(field.DbSchema.Index.ToString());
            item.SubItems.Add(field.DbSchema.AutoIncrement.ToString());
            item.SubItems.Add(field.DbSchema.DefaultValue);
            item.SubItems.Add(field.Comments);
            attributeCount++;

            return item;
        }