How to add a property to BO that inherit from a base bo as a collection like RequiredFields.


Author
Message
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Lets say I want to add a property called RequiredAuditFields that does exactly what the RequiredFields. IE... a collection of collumns. What is the code to do this?
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Ross.

Here is a thread that could get you started:

http://forum.strataframe.net/FindPost27609.aspx
Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.6K reputation)StrataFrame VIP (1.6K reputation)StrataFrame VIP (1.6K reputation)StrataFrame VIP (1.6K reputation)StrataFrame VIP (1.6K reputation)StrataFrame VIP (1.6K reputation)StrataFrame VIP (1.6K reputation)StrataFrame VIP (1.6K reputation)StrataFrame VIP (1.6K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
FYI, I ended up implementing the collection property without the editor, it proved a bit more work with the VS integration than I was willing to invest at the time, if you go down that road all the way, it would be great if you share your results Smile

Keith Chisarik
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Before I abandon this I was hoping that you may be able to shed some light on this?

 

The type or namespace name 'UITypeEditor' could not be found (are you missing a using directive or an assembly reference?)

I placed this in my BO Base, along with other code that seems to be working but when it comes to this line I get this error above.

Here are my USING statements in the BaseBO:

using

MicroFour.StrataFrame.Business;

using

System;

using

System.Collections;

using

System.Collections.Generic;

using

System.ComponentModel;

using

System.Data;

using

System.Data.SqlClient;

using

System.Runtime.Serialization;

using

System.Text;

using

MicroFour.StrataFrame.Security;

using

System.Diagnostics;

using

Microsoft.VisualBasic;

using

System.ComponentModel.Design;

using

System.Collections.Specialized;

using

System.Reflection;

using

System.Runtime.InteropServices.ComTypes;

using

MicroFour.StrataFrame.UI.Windows.Forms;

using

MicroFour.StrataFrame.Extensibility;

using

System.Drawing.Design;

[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; }



}


Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)
Group: Forum Members
Posts: 153, Visits: 462
I am not trying to create a new UITypeEditor but just trying to use the same one used by StrataFrame.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Forget my last post for now. I just got past this.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)StrataFrame User (197 reputation)
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();

}

}


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search