StrataFrame Forum
Back
Login
Login
Home
»
StrataFrame Application Framework - V1
»
Business Objects and Data Access (How do I?)
»
Subcalssing SF Business Objects
Subcalssing SF Business Objects
Post Reply
Like
0
Subcalssing SF Business Objects
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Ger Cannoll
Ger Cannoll
posted 14 Years Ago
ANSWER
HOT
Topic Details
Share Topic
Group: StrataFrame Users
Posts: 430,
Visits: 507
I want to start subclassing SF Buisness Objects (so I can imbed ny own Code in some of the methods) and am not sure how to do this. I have successfully subclassed a few controls (TextBoxes, Lables) etc and they are working fine, so I am using a similar approcah for Buisness Objects.
I tried :
public class KernelBO : MicroFour.StrataFrame.Business.BusinessLayer
{
}
My project compiles ok. I then created a new Business Object in the normal way , and went in manually and changed the generated code
from:
public partial class SquBO : MicroFour.StrataFrame.Business.BusinessLayer
to:
public partial class SquBO : KernelBaseSF.KernelBO
but got an error in compiling the Business Objects Project (KernelBaseSF.KernelBO does not contain a constructor that takes 2 arguments
What am I doing wrong here ?
Reply
Like
0
Replies
Ger Cannoll
Ger Cannoll
posted 14 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Users
Posts: 430,
Visits: 507
I have put in constructor code when subclassing the SF buisnes object but am getting errors on Icontainer line and InitializeComponent. I basically took these snippets of code from the BuisnessObjects created ut of the Busimess Object Mapper. Not sure if I need the InitializeComponent line ??
My full Subclassing Code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using MicroFour.StrataFrame.UI;
using MicroFour.StrataFrame.Business;
using MicroFour.StrataFrame.UI.Windows.Forms.DevEx;
using DevExpress.XtraEditors;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.Serialization;
using System.Diagnostics;
namespace KernelBaseSF
{
// 16-05-11 Subclass Business Object
public class KernelBO : MicroFour.StrataFrame.Business.BusinessLayer
{
public KernelBO()
: base()
{ InitializeComponent(); }
public KernelBO(Icontainer container)
: base()
{
container.Add(this);
InitializeComponent();
}
public KernelBO(SerializationInfo info, StreamingContext context)
:base(info,context)
{
InitializeComponent();
}
}
Reply
Like
0
Greg McGuffey
Greg McGuffey
posted 14 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 2K,
Visits: 6.6K
You do not need the initialize component. That is specific to the actual BOs. For an extended BusinessLayer, you'd use
something like this:
public class KernelBO : MicroFour.StrataFrame.Business.BusinessLayer
{
public KernelBO() : base() {}
public KernelBO(Icontainer container) : base( container ) {}
public KernelBO(SerializationInfo info, StreamingContext context) :base( info, context ) {}
}
You would then add any specific code as needed. For instance I did a BusinessLayer to support auditing and added event handlers to add/edit/delete events of base.
Reply
Like
0
Ger Cannoll
Ger Cannoll
posted 14 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Users
Posts: 430,
Visits: 507
Hi Greg. ve stripped out all the InitailizeComponent etc stuff and have it down to what you have suggested, but its coming up with a problem on Icontainer....type or namespace Icontainer could not be found. I've included all the namespaces I think are required, including System.ComponentModel
Reply
Like
0
Greg McGuffey
Greg McGuffey
posted 14 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 2K,
Visits: 6.6K
Hmmm....It's in System.ComponentModel, so not sure what your problem is. Could you post a sample of the stripped down app?
Reply
Like
0
Ger Cannoll
Ger Cannoll
posted 14 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Users
Posts: 430,
Visits: 507
Hi Greg.
I removed the line and typeed it in again......and now it compiles ok without an error .
Now I want to add in functionality (into my Bae Class) to run code in the SetDefaultValues method of the Business Object. How do I code this in in my Base Class.
Reply
Like
0
Greg McGuffey
Greg McGuffey
posted 14 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 2K,
Visits: 6.6K
I removed the line and typed it in again......and now it compiles ok without an error
Don't ya love it when that happens. I can't tell you how many hours I've wasted on things like this.....
As to having custom code for SetDefaultValues, you would override the OnSetDefaultValues method. You'll want to call the base method to ensure that the event gets raised for others to consume.
//-- In your base class....
protected override void OnSetDefaultValues()
{
//-- Call base method to actually raise event for other consumers.
base.OnSetDefaultValues();
//-- Add you customization code.
}
Depending on your needs, you can call the base class first (as shown) which will raise the event, then execute your custom code (i.e. you want any other work to be done
before
you do yours) OR you can call it afterwards, meaning you want to have your custom work done before the event is raised and thus available to any consumers of the event.
Edited
14 Years Ago by
Greg McGuffey
Reply
Like
0
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Threaded View
Threaded View
Subcalssing SF Business Objects
Ger Cannoll
-
14 Years Ago
Hi Gerard, There used to be an article available from this website...
Sam Tenney
-
14 Years Ago
I have a copy if you want me to email it too you? Terry Bottorff
Terry Bottorff
-
14 Years Ago
Hi Terry. Yes, Please email it. Not sure if its the same one as an...
Ger Cannoll
-
14 Years Ago
That is exactly the one it is. So no need to send it. Sorry.
Terry Bottorff
-
14 Years Ago
Hi Terry I have had another look at the artcile and it seems to...
Ger Cannoll
-
14 Years Ago
The error you are getting is likely because your base class and...
Greg McGuffey
-
14 Years Ago
Hi Greg. If subclassing the SF Business Objects is not the way to...
Ger Cannoll
-
14 Years Ago
You're headed in the right direction. You DO want to sub class...
Greg McGuffey
-
14 Years Ago
Ok Greg, still not clear on what I have to do to SubClass the SF BO....
Ger Cannoll
-
14 Years Ago
To sub-class a BO, you are actually sub-classing the BusinessLayer as...
Greg McGuffey
-
14 Years Ago
I have put in constructor code when subclassing the SF buisnes object...
Ger Cannoll
-
14 Years Ago
You do not need the initialize component. That is specific to the...
Greg McGuffey
-
14 Years Ago
Hi Greg. ve stripped out all the InitailizeComponent etc stuff and...
Ger Cannoll
-
14 Years Ago
Hmmm....It's in System.ComponentModel, so not sure what your problem...
Greg McGuffey
-
14 Years Ago
Hi Greg. I removed the line and typeed it in again......and now it...
Ger Cannoll
-
14 Years Ago
[quote] I removed the line and typed it in again......and now it...
Greg McGuffey
-
14 Years Ago
Post Reply
Like
0
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search