473,394 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Enterprise Library - Indirect/Inherited Configuration??

Hello,

My company creates many similar web applications for clients. I was
assigned the task of creating a versionable engine for producing these web
applications easily and protecting our code.

I am creating an assembly that functions as the guts of the web
applications we are producing. This way, all our code is contained within a
distributable DLL, so the only code clients see is that which is specific
to their business processes.

I would like to use EntLib in my DLL, but I don't want configure and
compile a custom version of our DLL for each client. (That kind-of defeats
the purpose, right?)

So, my question is:

How can I get my DLL to grab the EntLib configuration settings from the web
app's web.config instead of customizing my DLL for each client directly?

Here is an overview of the code structure:

MyDLL:

// MyEngine is the facade from which all processes take place
public class MyEngine
{
private CustomerManager _customerManager;

public CustomerManager CustomerManager
{
get { return _customerManager; }
}

public MyEngine()
{
_customerManager = new CustomerManager();
}
}

public class CustomerManager
{
private CustomerDB _customerDB;

public CustomerManager()
{
_customerDB = new CustomerDB();
}

public void AddCustomer(CustomerEntity customer)
{
if (ValidCustomer(customer))
{
_customerDB.Insert(customer);
}
}

public bool ValidCustomer(CustomerEntity customer)
{
return true;
}
}

public class CustomerDB
{
public CustomerDB()
{}

public void Insert(CustomerEntity customer)
{
// Ent Lib data needs database configuration...
Database db = DatabaseFactory.CreateDatabase("?????????");
db.ExecuteNonQuery(db.GetStoredProcCommandWrapper
("InsertCustomer",customer.ParamArray()));
}
}

public abstract class CustomerEntity
{
public abstract object[] ParamArray();
}

MyWebApp:

public class Customer : CustomerEntity
{
private int _id;
private string _name;

public int ID { get { return _id;} set { _id = value; } }
public string Name { get { return _name;} set { _name = value; } }

Customer() {}

public override object[] ParamArray()
{
object[] myParamArray = new object[2];
myParamArray[0] = _id;
myParamArray[1] = _name;
return myParamArray;
}
}

public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
MyEngine theEngine = new MyEngine();
Customer theCustomer = new Customer();
theCustomer.ID = 1;
theCustomer.Name = "Bob";
theEngine.CustomerManager.AddCustomer(theCustomer) ;
}
}

The way I have this set up, the entities are configured in the web apps and
passed into my DLL via the inheritance with the abstract Entity classes.
This avoided the need for configuring the DLL separately, but now I am
stuck at getting the EntLib configured too.

Input welcome and appreciated!

Thanks!

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
1 1266

Hi plaztik:

Pardon me if I don't understand the questions.

Web.config is the configuration file for the entire application,
including all the assemblies / dlls loaded into the app. If your class
library asks the framework for an application setting, the answer will
come back from web.config.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 06 May 2005 00:40:51 GMT, "plaztik via DotNetMonster.com"
<fo***@nospam.DotNetMonster.com> wrote:
Hello,

My company creates many similar web applications for clients. I was
assigned the task of creating a versionable engine for producing these web
applications easily and protecting our code.

I am creating an assembly that functions as the guts of the web
applications we are producing. This way, all our code is contained within a
distributable DLL, so the only code clients see is that which is specific
to their business processes.

I would like to use EntLib in my DLL, but I don't want configure and
compile a custom version of our DLL for each client. (That kind-of defeats
the purpose, right?)

So, my question is:

How can I get my DLL to grab the EntLib configuration settings from the web
app's web.config instead of customizing my DLL for each client directly?

Here is an overview of the code structure:

MyDLL:

// MyEngine is the facade from which all processes take place
public class MyEngine
{
private CustomerManager _customerManager;

public CustomerManager CustomerManager
{
get { return _customerManager; }
}

public MyEngine()
{
_customerManager = new CustomerManager();
}
}

public class CustomerManager
{
private CustomerDB _customerDB;

public CustomerManager()
{
_customerDB = new CustomerDB();
}

public void AddCustomer(CustomerEntity customer)
{
if (ValidCustomer(customer))
{
_customerDB.Insert(customer);
}
}

public bool ValidCustomer(CustomerEntity customer)
{
return true;
}
}

public class CustomerDB
{
public CustomerDB()
{}

public void Insert(CustomerEntity customer)
{
// Ent Lib data needs database configuration...
Database db = DatabaseFactory.CreateDatabase("?????????");
db.ExecuteNonQuery(db.GetStoredProcCommandWrapper
("InsertCustomer",customer.ParamArray()));
}
}

public abstract class CustomerEntity
{
public abstract object[] ParamArray();
}

MyWebApp:

public class Customer : CustomerEntity
{
private int _id;
private string _name;

public int ID { get { return _id;} set { _id = value; } }
public string Name { get { return _name;} set { _name = value; } }

Customer() {}

public override object[] ParamArray()
{
object[] myParamArray = new object[2];
myParamArray[0] = _id;
myParamArray[1] = _name;
return myParamArray;
}
}

public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
MyEngine theEngine = new MyEngine();
Customer theCustomer = new Customer();
theCustomer.ID = 1;
theCustomer.Name = "Bob";
theEngine.CustomerManager.AddCustomer(theCustomer) ;
}
}

The way I have this set up, the entities are configured in the web apps and
passed into my DLL via the inheritance with the abstract Entity classes.
This avoided the need for configuring the DLL separately, but now I am
stuck at getting the EntLib configured too.

Input welcome and appreciated!

Thanks!


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland...
3
by: veera sekhar kota | last post by:
hi, im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked...
2
by: bjhogan | last post by:
Hi, I have built an c# asp.net application on my laptop, it uses the Enterprise Library blocks - Data Access Application Block, Configuration Application Block. I now want to deploy my...
0
by: John Dalberg | last post by:
I am getting the error below many times when I am trying to use the Enterprise Library. The solution seems to be a reboot. I am using Windows 2003 as my dev box. The error also happens with other...
8
by: Gaetan | last post by:
Is is possible in C# to have the equivalent of an array of function pointers in C? I have a situation where a top level class exposes methods like Add, Delete, ... and a few child classes with...
7
by: rockdale | last post by:
hi, I just downloaded Microsoft Enterprise Library Jan 2006 and try to integrate it into my asp.net application. As i am going to connect to mySQL database, I need to include the source code in my...
3
by: bungle | last post by:
Hi, I have started using MS Enterprise Library for the data access layer and found it great. I have changed to coding on another machine though and didn't think it necessary to a full install of...
0
by: =?Utf-8?B?YW5rMmdv?= | last post by:
Hi, Thanks in advance for reading this. Not sure where to post this question, but I hope someone in here can help. Trying to write to Event Log in VS 2005 (.NET 2.0) using Enterprise Library...
0
by: =?Utf-8?B?UG9sbHkgQW5uYQ==?= | last post by:
Hi, I have previously used EL v 3.1 Exception Handling application block successfully. I thought I would now try to do the same with EL v 4.0. My first experiment was to replace an exception....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.