Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Confused in best implementation
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Confused in best implementation
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01599810
Message ID:
01599810
Views:
60
Hi everybody,

I am trying to figure out the following problem.

I have MiddlewareBase class. This is a base class for few other classes.

It has the following constructor currently
public class MiddlewareBase
   {
      public Request CurrentRequest;
      public LocalIni iniFile;

      private Database _database;
      public Database database
      {
         get { return _database; }
         set { _database = value; }
      }
      internal String CurrentSalespoint { get; private set; }
      internal String CurrentOperator { get; private set; }
      internal Int16 nPrefsSiteNo { get; set; }
      internal Int16 nClientNumber { get; set; }

      public static readonly DateTime DTSqlMinDate = DateTime.Parse("1900-01-01");

      public static readonly String ServerName = "SalesEZ"; //"Siriusware.Middleware"; // used to be SalesEZ
      public static readonly String GenericOperator = "SEZDTL"; // used in lcDTL in ValidatePass2

      public MiddlewareBase()
      {
         iniFile = new LocalIni();
      }
I have several classes that inherit from this class.

I don't want to set nPrefsSiteNo and nClientNumber properties in each of these classes individually. I want to set them once in the parent class. However, to get these properties I need to use this.database. methods.

All instances of this class properly set up the database.

My question is - how can I set these two properties in the base class?

This is how I currently set nPrefsSiteNo in the instance class:
this.nPrefsSiteNo = (Int16)database.GetPreferenceInt("prefs", "site_no");
I want to move this logic into the base class. However, I can not call it in constructor as the database is not defined at that point.

What can I do?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform