Is it possible, to replace lost attributes, by extending a class from a Web Reference.
For example, previously a class containing a property called 'Amount` was part of the same project as defined below:
public class Test
{
[Required]
[Display(Name = "Amount", Description = "Amount")]
[DisplayFormat(DataFormatString = "{0:F2}", ApplyFormatInEditMode = true)]
[Range(1000, int.MaxValue)]
public decimal Amount { get; set; }
}
The class containing the property as written above was then moved to an external project and referenced as a Web Reference. The class imported has the property 'Amount' however is simply as below:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3190.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")]
public partial class Test {
private decimal amountField;
/// <remarks/>
public decimal Amount {
get {
return this.amountField;
}
set {
this.amountField = value;
}
}
}
As you can see, attributes such as [Required]
, [Display(Name = "Amount", Description = "Amount")]
, [Display(Name = "Amount", Description = "Amount")]
, [DisplayFormat(DataFormatString = "{0:F2}", ApplyFormatInEditMode = true)]
and [Range(1000, int.MaxValue)]
have been obmitted.
These attributes are still required for Model Validation, how can I extend the imported class by adding the missing attributes, so that Form Validation is not affected?