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 class which uses reflection to instantiate the
approprite subclass( BoatCreditReport, HomeCreditReport, 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(project 1) will create an
instance of either BoatCreditReport or HomeCreditReport.
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(ByVal str As string) As Double
Blah,blah, blah
Return somedouble
End Function
Public Function GetReportSummary(ByVal str1 As string) As
Credit
Blah,blah, blah
Return somecredit
End Function
Public MustOverride Sub ChoicePointParser(ByVal str3 As
String)
Public MustOverride Function ValidateCreditRequest(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.GetType(reportType)
credreport = CType(Activator.CreateInstance(typ),
CreditReport)
Return credreport
End Function
End Class
PROJECT 2
Public Class BoatCreditReport
Inherits CreditReport
Public Overrides Sub ChoicePointParser(ByVal str3 As String)
'parsing code specific to boat credit report
End Sub
Public Overrides Function ValidateCreditRequest(ByVal str4 As
string) As String
'validation code specific to boat credit report
End Function
End Class
PROJECT 3
Public Class HomeCreditReport
Inherits CreditReport
Public Overrides Sub ChoicePointParser(ByVal str3 As String)
'parsing code specific to Home credit report
End Sub
Public Overrides Function ValidateCreditRequest(ByVal str4 As
string) As String
'validation code specific to Home credit report
End Function
End Class 2 1562 I have a CreditFactory class which uses reflection to instantiate the approprite subclass( BoatCreditReport, HomeCreditReport, 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.Class, 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.org> wrote in message news:<eu**************@TK2MSFTNGP12.phx.gbl>... I have a CreditFactory class which uses reflection to instantiate the approprite subclass( BoatCreditReport, HomeCreditReport, 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.Class, 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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
| |