C# Cast Class to Overridden Class
Posted
by
Nathan Tornquist
on Stack Overflow
See other posts from Stack Overflow
or by Nathan Tornquist
Published on 2012-07-09T20:27:05Z
Indexed on
2012/07/09
21:15 UTC
Read the original article
Hit count: 246
I have a class Application
that I need to override with INotifyPropertyChanged events. I have written the logic to override the original class and ended up creating SuperApplication
I am pulling the data from a library though, and cannot change the loading logic. I just need a way to get the data from the original class into my superClass. I've tried things like superClass = (SuperApplication)standardClass;
but it hasn't worked.
How would I go about doing this?
If it helps, this is the code I'm using to override the original class:
public class SuperCreditApplication : CreditApplication
{
public SuperCreditApplicant Applicant { get; set; }
public SuperCreditApplicant CoApplicant { get; set; }
}
public class SuperCreditApplicant : CreditApplicant
{
public SuperProspect Prospect { get; set; }
}
public class SuperProspect : Prospect, INotifyPropertyChanged
{
public State DriverLicenseState
{
get
{
return DriverLicenseState;
}
set
{
DriverLicenseState = value;
OnPropertyChanged("DriverLicenseState");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
© Stack Overflow or respective owner