Group: Forum Members
Posts: 153,
Visits: 462
|
The property "AuditFields" does now appear on the BOs that inherit from the Base BO but the caption "Collection" does not show and when I click on the eclips I get the follow error:
"An error occurred while attempting to load this type editor: Object reference not set to an instance of an object."
Again, my hope here, is that you may be able to provide any information that may assist. I have successfully integrating the Auditing into our BaseBO as well as a ActivityLog viewer. My last goal is the creating of a property to allow the user to select none or select what fields they want to include. In addition I have some other plans for this but need to know what I may need to consider.
public class AuditField : IRequiredField
{
#region
" Declare Privates "
private string _FieldName;
#endregion
private SqlDbType _FieldType;
#region
" Declare Public Properties "
/// <summary>
/// The field name that is required
/// </summary>
/// <value></value>
/// <remarks></remarks>
public string FieldName
{
get { return _FieldName; }
set { _FieldName = value; }
}
/// <summary>
/// The data type of the required field
/// </summary>
/// <value></value>
/// <remarks></remarks>
public SqlDbType FieldType
{
get { return _FieldType; }
set { _FieldType = value; }
}
#endregion
}
[
Category(BUSINESSRULES_CATEGORY_NAME), Description("The AuditFieldsCollection that defines the fields within the business object that are required. If a required field is not populated, then a broken rule will be automatically added to the business object."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Editor(Constants.TE_RequiredFieldsEditor, typeof(UITypeEditor))]
public virtual RequiredFieldsCollection AuditFields
{
get
{
return _AuditFields;
}
set { _AuditFields = value; }
}
private
void ResetAuditFields()
{
_AuditFields =
new RequiredFieldsCollection();
}
private
bool ShouldSerializeRequiredFields()
{
return this._AuditFields.Count > 0;
}
[
Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
protected
virtual new string AllFieldNames
{
get
{
throw new NotImplementedException("A class derived from " + typeof(BusinessLayer).FullName + " must override the property 'AllFieldNames'");
}
}
public
class AuditFieldsCollection : System.Collections.CollectionBase, IRequiredFieldsCollection
{
public AuditFieldsCollection()
{
}
public void Add(IRequiredField Item)
{
InnerList.Add(Item);
}
public void Remove(AuditField Item)
{
InnerList.Remove(Item);
}
public bool Contains(AuditField Item)
{
return InnerList.Contains(Item);
}
public AuditField this[int Index]
{
get { return (AuditField)InnerList[Index]; }
set { InnerList[Index] = value; }
}
public void AddRange(AuditField[] Items)
{
InnerList.AddRange(Items);
}
public AuditField[] GetValues()
{
//-- Establish Locals
AuditField[] loReturn = null;
// ERROR: Not supported in C#: ReDimStatement
InnerList.CopyTo(0, loReturn, 0, InnerList.Count);
return loReturn;
}
protected override void OnInsert(int index, object value)
{
base.OnInsert(index, value);
}
public IRequiredField[] ToArray()
{
//-- Establish Locals
System.Collections.Generic.
List<RequiredField> loArray = new System.Collections.Generic.List<RequiredField>();
//RequiredField loItem = default(RequiredField);
foreach (RequiredField loItem in List)
{
loArray.Add(loItem);
}
return loArray.ToArray();
}
public new void Clear()
{
InnerList.Clear();
}
}
|