public EditAttribute(AttributeFieldReference attribute)
 {
     InitializeComponent();
     Text = "Edit Attribute: " + attribute.Name;
     this.attribute = attribute;
     DisplayValue();
     ux_DefaultValue.Enabled = attribute.HasValue;
 }
 private string GetDefaultValue(AttributeFieldReference attribute)
 {
     if (attribute.DefaultValue == null)
         return "";
     if (attribute.Type.IsEnum==false)
         return attribute.DefaultValue.ToString();
     //this is an enum
     return GetEnumXmlName(attribute,attribute.DefaultValue.ToString());
 }
 private static string GetValue(AttributeFieldReference attribute)
 {
     if(attribute.Type.IsEnum==false)
         return attribute.Value.ToString();
     else
         return GetEnumXmlName(attribute,attribute.Value.ToString());
 }
 private static string GetEnumXmlName(AttributeFieldReference attribute, string fieldName)
 {
     return SchemaEditor.GetEnumFieldsAndXMLNames(attribute.Type)[fieldName];
 }
 /// <summary>
 /// Remove an attribute from the active attributes collection
 /// </summary>
 /// <param name="inActiveAttribute">The attribute to remove from the active collection</param>
 public void DeactivateAttribute(AttributeFieldReference inActiveAttribute)
 {
     activeAttributes.Remove(inActiveAttribute);
 }
 /// <summary>
 /// Add an attribute to the collection.
 /// </summary>
 /// <param name="attribute">the new attribute</param>
 public void AddAttribute(AttributeFieldReference attribute)
 {
     attributes.Add(attribute);
 }
 /// <summary>
 /// Add an attribute to the active attributes collection
 /// </summary>
 /// <param name="activeAttribute">The new active attribute</param>
 public void ActivateAttribute(AttributeFieldReference activeAttribute)
 {
     if (!activeAttributes.Contains(activeAttribute))
         activeAttributes.Add(activeAttribute);
 }
 public void AttributeHandler(AttributeFieldReference sender, AttributeFieldReferenceEventArgs e)
 {
     if (node.Attributes.Contains(sender) == false)
         throw new InvalidOperationException("HasValueChanged was called to a node that doesn't contain the attribute.");
     if (e.HasValue)
         node.ActivateAttribute(sender);
     else
         node.DeactivateAttribute(sender);
 }
        private static void PopulateAttributes(ISchemaEditorNode node)
        {
            Type type = node.Value.GetType();
            NodeAttributeBridge nodeAttributeBridge = new NodeAttributeBridge(node);
            foreach (FieldInfo field in AttributeFields(type))
            {
                AttributeFieldReference attributeFieldReference = new AttributeFieldReference(node.Value, field, SpecifiedField(field));
                node.AddAttribute(attributeFieldReference);
                attributeFieldReference.HasValueChanged += new AttributeFieldReference.AttributeFieldReferenceEventHandler(nodeAttributeBridge.AttributeHandler);

                if (attributeFieldReference.HasValue == false)
                    continue;
                node.ActivateAttribute(attributeFieldReference);
            }
        }
 private void nodeAttributes_EventHanlder_True(AttributeFieldReference sender, AttributeFieldReferenceEventArgs e)
 {
     Assert.IsTrue(e.HasValue, "Attribute's has value was not changed");
 }
 private void fieldReference_HasValueChanged_True(AttributeFieldReference sender, AttributeFieldReferenceEventArgs e)
 {
     Assert.IsTrue(e.HasValue);
 }
 public void SetUp()
 {
     hm = new hibernatemapping();
     fieldReference = new AttributeFieldReference(hm, typeof (hibernatemapping).GetField("defaultcascade"), null);
 }