I have the following situation and could use some advise.
I have a Base Class CreditReport, classes BoatCreditRepor t and
HomeCreditRepor t Inherit from CreditReport.
I would like to have the CreditReport class in a separate project from
BoatCreditRepor t and HomecreditRepor t for departmental code
development reasons.
I have a CreditFactory class which uses reflection to instantiate the
approprite subclass( BoatCreditRepor t, HomeCreditRepor t, etc) based on
some parm passed in.
The parm passed in will be a fully qualified class name pulled from
the web.config. No problem there.
The problem is; Project 2 & 3 need to reference Project 1 ( because
they inherit). Correct? The CreditFactory(p roject 1) will create an
instance of either BoatCreditRepor t or HomeCreditRepor t.
How can it do this without a reference? I certainly don't want to
reference Project 1 from project 2 ( although I tried that and the
reflection did not work). See code below
Any advise here would be greatly appreciated.
PROJECT 1
Public MustInherit Class CreditReport
Public objCredit As New Credit()
Public Function RequestReport(B yVal str As string) As Double
Blah,blah, blah
Return somedouble
End Function
Public Function GetReportSummar y(ByVal str1 As string) As
Credit
Blah,blah, blah
Return somecredit
End Function
Public MustOverride Sub ChoicePointPars er(ByVal str3 As
String)
Public MustOverride Function ValidateCreditR equest(ByVal str4
As string) As String
End Class
Public Class CreditFactory
Private Sub New()
End Sub
Public Shared Function Create(ByVal reportType As String) As
CreditReport
Dim credreport As CreditReport
credreport = Nothing
Dim typ As System.Type = System.Type.Get Type(reportType )
credreport = CType(Activator .CreateInstance (typ),
CreditReport)
Return credreport
End Function
End Class
PROJECT 2
Public Class BoatCreditRepor t
Inherits CreditReport
Public Overrides Sub ChoicePointPars er(ByVal str3 As String)
'parsing code specific to boat credit report
End Sub
Public Overrides Function ValidateCreditR equest(ByVal str4 As
string) As String
'validation code specific to boat credit report
End Function
End Class
PROJECT 3
Public Class HomeCreditRepor t
Inherits CreditReport
Public Overrides Sub ChoicePointPars er(ByVal str3 As String)
'parsing code specific to Home credit report
End Sub
Public Overrides Function ValidateCreditR equest(ByVal str4 As
string) As String
'validation code specific to Home credit report
End Function
End Class 2 1575 I have a CreditFactory class which uses reflection to instantiate the approprite subclass( BoatCreditRepor t, HomeCreditRepor t, etc) based on some parm passed in. The parm passed in will be a fully qualified class name pulled from the web.config. No problem there.
If you include the assembly name after the class name (in the format
"Namespace.Clas s, AssemblyName"), then Type.GetType() will load the
assembly, so you don't need a compile time reference to it.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mattias Sjögren <ma************ ********@mvps.o rg> wrote in message news:<eu******* *******@TK2MSFT NGP12.phx.gbl>. .. I have a CreditFactory class which uses reflection to instantiate the approprite subclass( BoatCreditRepor t, HomeCreditRepor t, etc) based on some parm passed in. The parm passed in will be a fully qualified class name pulled from the web.config. No problem there.
If you include the assembly name after the class name (in the format "Namespace.Clas s, AssemblyName"), then Type.GetType() will load the assembly, so you don't need a compile time reference to it. Mattias
Thanks that worked out great This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ray Z |
last post by:
hi, there
I build a Class Library, I write a class A to implement interface IA. The
problem is when I give the dll file to others, thet can get all information
about not only IA, but also A. They can even see my protected members of
class A. How could I hide these informations about class A, just give them
the interface informations.
...
|
by: d0wsdkn02 |
last post by:
I need some architecture help. Our app is similar between clients, but
every client has specific needs that can require us to change anything.
I'll concentrate on one class below, but potentially any number of
methods, fields, additional classes, or anything could need to be
changed for a client.
With two clients, one way to implement this...
|
by: Jason MacKenzie |
last post by:
Is there a way to prevent classes from being instantiated by methods other
than my factory pattern?
I have a couple of classes and want to force the factory class to be used as
the "entry point".
Any help is appreciated,
Jason MacKenzie
|
by: Nancy |
last post by:
I have the following situation and could use some advise.
I have a Base Class CreditReport, classes BoatCreditReport and
HomeCreditReport Inherit from CreditReport.
I would like to have the CreditReport class in a separate project from
BoatCreditReport and HomecreditReport for departmental code
development reasons.
I have a CreditFactory...
|
by: Peter Gummer |
last post by:
This is a design question.
I have a project containing a dozen or so classes with protected
internal constructors.
My reason for having protected internal constructors is to prevent
classes in other assemblies from instantiating them. There is a factory
class that instantiates them. Only the factory should do so, because
some of these...
| |
by: docschnipp |
last post by:
Hi,
I have a bunch of object derived from the same base class. They all share
the same constructor with some parameters. Now, instead of using a large
switch() statement where I call every single Object by itself, I'd like to
assign a reference to the class type and call it later without knowing the
derived type.
Example:
|
by: Anthony Greene |
last post by:
This is probably a very introductory object-oriented question, but it
has been nagging me for years, and since I've never been able to find
the right answer, I've had to work around it with non-optimal code.
However, I suspect there must be a proper object-oriented approach to
solving this problem. Perhaps someone might be able to help me...
|
by: GroupReader |
last post by:
In my app, I have two very similar static classes. After long
thought, I've decided *yes - keep them static*.
- Sometimes I will want to use Static Class A, and somtimes I will
want to use Static Class B, depending on the situation.
- The interfaces (are interfaces allowed on static classes?) are
almost identical.
What's the best way...
|
by: dascandy |
last post by:
Hi,
For a project I'm working on I'm kind-of-hacking my way around
deriving a class from an interface or such to create a mock, but
instead creating the mock directly. It is usable as the interface type
(as the virtual functions match up), but there is a snag. No members
are initialized, which means it can't be used as the original type if...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |