Note that there are some explanatory texts on larger screens.

plurals
  1. POInheritance issue
    text
    copied!<p>I have an issue with inheritance. I have an interface called <code>Irewhizz</code>:</p> <pre><code>interface Irewhizz { void object save(object obj); void object getdata(object obj); } </code></pre> <p>I've written the definition in a different class:</p> <pre><code>public user:irewhzz { public object save(object obj); public object getdata(object obj); } public client:irewhzz { public object save(object obj); public object getdata(object obj); } </code></pre> <p>Now I have different classes like:</p> <pre><code>public partial class RwUser { #region variables IRewhizzDataHelper irewhizz; IRewhizzRelationDataHelper irewhizzrelation; #endregion //IRewhizz is the interface and its functions are implimented by UserDataHelper class //RwUser Class is inheriting the UserDataHelper Properties and functions. //Here UserDataHelper functions are called with Irewhizz Interface Object but not with the //UserDataHelper class Object It will resolves the unit testing conflict. #region Constructors public RwUser() : this(new UserDataHelper(), new RewhizzRelationalDataHelper()) { } public RwUser(IRewhizzDataHelper repositary, IRewhizzRelationDataHelper relationrepositary) { irewhizz = repositary; irewhizzrelation = relationrepositary; } #endregion #region Properties public int Role { get; set; } public string MobilePhone { get; set; } public bool ChangePassword { get; set; } public byte[] Image { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string MiddleName { get; set; } public string Email { get; set; } public string Website { get; set; } public int AddressId { get; set; } public string City { get; set; } public string Zipcode { get; set; } public string Phone { get; set; } public string Fax { get; set; } public string AboutMe { get; set; } public string username { get; set; } public string password { get; set; } public string SecurityQuestion { get; set; } public string SecurityQAnswer { get; set; } public Guid UserID { get; set; } public long RwUserID { get; set; } #endregion #region MemberFunctions // DataHelperDataContext db = new DataHelperDataContext(); // RewhizzDataHelper rwdh=new RewhizzDataHelper(); //It saves user information entered by user and returns the id of that user public object saveUserInfo(RwUser userObj) { userObj.UserID = irewhizzrelation.GetUserId(username); var res = irewhizz.saveData(userObj); return res; } //It returns the security questions for user registration } </code></pre> <p>and</p> <pre><code> public class Agent : RwUser { IRewhizzDataHelper irewhizz; IRewhizzRelationDataHelper irewhizzrelation; public string Locations { get; set; } public string SelectedLanguages { get; set; } public string SelectedSpecialization { get; set; } public string RegisteredStates { get; set; } public string AgentID { get; set; } public string ExpDate { get; set; } public SelectList RegisterStates { get; set; } public SelectList Languages { get; set; } public SelectList Specializations { get; set; } public int[] RegisterdStates { get; set; } public int RoleId { get; set; } public int SpeclisationId { get; set; } public int[] Language { get; set; } public int LocationTypeId { get; set; } public string BrokarageCompany { get; set; } public string Rolename { get; set; } public int[] Specialization { get; set; } public Agent() : this(new AgentDataHelper(), new RewhizzRelationalDataHelper()) { } public Agent(IRewhizzDataHelper repositary, IRewhizzRelationDataHelper relationrepositary) { irewhizz = repositary; irewhizzrelation = relationrepositary; } public void inviteclient() { //Code related to mailing } public Agent updateData(Agent objectId) { objectId.UserID = irewhizzrelation.GetUserId(objectId.username); objectId = (Agent)irewhizz.updateData(objectId); return objectId; } public Agent GetAgentData(Agent agentodj) { agentodj.UserID = irewhizzrelation.GetUserId(agentodj.username); agentodj = (Agent)irewhizz.getData(agentodj); if (agentodj.RoleId != 0) agentodj.Rolename = (string)(string)irewhizzrelation.getValue(agentodj.RoleId); if (agentodj.RegisterdStates.Count() != 0) { List&lt;SelectListItem&gt; list = new List&lt;SelectListItem&gt;(); string regstates = ""; foreach (int i in agentodj.RegisterdStates) { SelectListItem listitem = new SelectListItem(); listitem.Value = i.ToString(); listitem.Text = (string)irewhizzrelation.getValue(i); list.Add(listitem); regstates += (string)irewhizzrelation.getValue(i) + ","; } SelectList selectlist = new SelectList(list, "Value", "Text"); agentodj.RegisterStates = selectlist; if(regstates!=null) agentodj.RegisteredStates = regstates.Remove(regstates.Length - 1); } if (agentodj.Language.Count() != 0){ List&lt;SelectListItem&gt; list = new List&lt;SelectListItem&gt;(); string selectedlang = ""; foreach (int i in agentodj.Language) { SelectListItem listitem = new SelectListItem(); listitem.Value = i.ToString(); listitem.Text = (string)irewhizzrelation.getValue(i); list.Add(listitem); selectedlang += (string)irewhizzrelation.getValue(i) + ","; } SelectList selectlist = new SelectList(list, "Value", "Text"); agentodj.Languages = selectlist; } if (agentodj.Specialization.Count() != 0) { List&lt;SelectListItem&gt; list = new List&lt;SelectListItem&gt;(); string selectedspel = ""; foreach (int i in agentodj.Specialization) { SelectListItem listitem = new SelectListItem(); listitem.Value = i.ToString(); listitem.Text = (string)irewhizzrelation.getValue(i); list.Add(listitem); selectedspel += (string)irewhizzrelation.getValue(i) + ","; } SelectList selectlist = new SelectList(list, "Value", "Text"); agentodj.Specializations = selectlist; } return agentodj; } public void SaveImage(byte[] pic, String username) { irewhizzrelation.SaveImage(pic, username); } } </code></pre> <p>Now the issue is when ever I am calling the agent class it is giving an error like null reference exception for rwuser class </p> <p>Can anybody give me the solution?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload