继承问题

我面临着一个继承问题,我有一个名为Irewhizz的界面

interface irewhzz
{

void object save(object obj); void object getdata(object obj); }

我写了不同类的定义

public user:irewhzz
{
    public object save(object obj);

{.......}

公共对象getdata(object obj); {.......}}

这是antoher类

public client:irewhzz 
{
    public object save(object obj);
    {
        .......
    }

    public object getdata(object obj);
    {
        .......
    }
}

现在我有不同的类

public partial class RwUser
{

    #region variables

    IRewhizzDataHelper irewhizz;
    IRewhizzRelationDataHelper irewhizzrelation;
    private string _firstName;
    private string _lastName;
    private string _middleName;
    private string _email;
    private string _website;
    private int _addressId;
    private string _city;
    private string _zipcode;
    private string _phone;
    private string _fax;
    //private string _location;
    private string _aboutMe;
    private string _username;
    private string _password;
    private string _securityQuestion;
    private string _securityQAnswer;

私人Guid _user_Id; 私人长期_rwuserid; 私人字节[] _image; 私人bool _changepassword; 私人字符串_mobilephone; private int _role; #endregion

// IRewhizz是接口,其功能由UserDataHelper类实现// RwUser类继承UserDataHelper属性和函数。 //这里的UserDataHelper函数是用Irewhizz接口对象调用的,但不能用于// UserDataHelper类对象它将解决单元测试冲突。

#region构造函数public RwUser():this(new UserDataHelper(),new RewhizzRelationalDataHelper()){

}

public RwUser(IRewhizzDataHelper repositary,IRewhizzRelationDataHelper relationrepositary){irewhizz = repositary; irewhizzrelation = relationrepositary; } #endregion

#region属性public int Role {get {return _role; } set {_role = value; }}

公共字符串MobilePhone {get {return _mobilephone; } set {_mobilephone = value; }}

public bool ChangePassword {get {return _changepassword; } set {_changepassword = value; }}

public byte [] Image {get {return _image; } set {_image = value; }

}

public string FirstName {get {return _firstName; } set {_firstName = value; }}

公共字符串LastName {get {return _lastName; } set {_lastName = value; }}

公共字符串MiddleName {get {return _middleName; } set {_middleName = value; }}

public string Email {get {return _email; } set {_email = value; }}

public string Website {get {return _website; } set {_website = value; }}

public int AddressId {get {return _addressId; } set {_addressId = value; }}

public string City {get {return _city; } set {_city = value; }}

公共字符串Zipcode {get {return _zipcode; } set {_zipcode = value; }}

公共字符串电话{get {return _phone; } set {_phone = value; }}

公共字符串传真{获得{返回_fax; } set {_fax = value; }}

// public string Location // {// get // {// return _location; //} // set // {// _location = value; //} //}

公共字符串AboutMe {get {return _aboutMe; } set {_aboutMe = value; }}

public string username {get {return _username; } set {_username = value; }}

public string password {get {return _password; } set {_password = value; }}

公共字符串SecurityQuestion {get {return _securityQuestion; } set {_securityQuestion = value; }}

public string SecurityQAnswer {get {return _securityQAnswer; } set {_securityQAnswer = value; }}

public Guid UserID {get {return _user_Id; } set {_user_Id = value; }}

public long RwUserID {get {return _rwuserid; } set {_rwuserid = value; }} #endregion

#region MemberFunctions // DataHelperDataContext db = new DataHelperDataContext(); // RewhizzDataHelper rwdh = new RewhizzDataHelper();

//保存用户输入的用户信息并返回该用户的ID public Object saveUserInfo(RwUser userObj){

userObj.UserID = irewhizzrelation.GetUserId(username); var res = irewhizz.saveData(userObj); 返回资源; }

//它返回用户注册的安全问题

}

公共类代理:RwUser {IRewhizzDataHelper irewhizz; IRewhizzRelationDataHelper irewhizzrelation; private int _roleid; private int _speclisationid; private int [] _language; 私人字符串_brokaragecompany; private int _loctionType_lk; 私人字符串_rolename; private int [] _specialization; 私人字符串_agentID; 私人字符串_expDate; 私人字符串_regstates; 私人字符串_selLangs; 私人字符串_selSpels; 私人字符串_locations; 公共字符串位置{get {return _locations; } set {_locations = value; }}

公共字符串SelectedLanguages {get {return _selLangs; } set {_selLangs = value; }}

公共字符串SelectedSpecialization {获得{返回_selSpels; } set {_selSpels = value; }}

public string RegisteredStates {get {return _regstates;

} set {_regstates = value; }}

//私人字符串_registeredStates; 公共字符串AgentID {get {return _agentID;

} set {_agentID = value;

}}

public string ExpDate {get {return _expDate;

} set {_expDate = value;

}}

private int [] _registeredStates; public SelectList RegisterStates {set; 得到; }

公共SelectList语言{set; 得到; }

公共SelectList专业化{set; 得到; }

public int [] RegisterdStates {get {return _registeredStates; } set {_registeredStates = value; }

}

// public string RegisterdStates // {// // // // // // return _registeredStates; //} // set // {// _registeredStates = value; //}

//}

public int RoleId {get {return _roleid; } set {_roleid = value; }

}

public int SpeclisationId {get {return _speclisationid; } set {_speclisationid = value; }

}

public int [] Language {get {return _language; } set {_language = value; }

}

public int LocationTypeId {get {return _loctionType_lk; } set {_loctionType_lk = value; }

}

公共字符串BrokarageCompany {get {return _brokaragecompany; } set {_brokaragecompany = value; }

}

公共字符串Rolename {get {return _rolename; } set {_rolename = value; }

}

public int []专精{get {return _specialization; } set {_specialization = value; }

}

public Agent():this(new AgentDataHelper(),new RewhizzRelationalDataHelper()){

}

公共代理(IRewhizzDataHelper repositary,IRewhizzRelationDataHelper relationrepositary){irewhizz = repositary; irewhizzrelation = relationrepositary;

}

public void inviteclient(){//与邮件相关的代码}

// DataHelperDataContext dataObj = new DataHelperDataContext();

//#区域IRewhizzFactory成员

// public List getAgentInfo(string username)// {// var res = dataObj.GetCompleteUserDetails(username); //返回res.ToList();

//抛出新的NotImplementedException(); //} // public List GetRegisterAgentData(string username)// {// var res = dataObj.RegisteredUserdetails(username); //返回res.ToList(); //}

// public void saveAgentInfo(string username,string password,string firstname,string lastname,string middlename,string securityquestion,string securityQanswer)// {// User userobj = new User();

// var result = dataObj.rw_Users_InsertUserInfo(firstname,middlename,lastname,dataObj.GetUserId(username),securityquestion,securityquestionanswer);

//抛出新的NotImplementedException(); //}

//#endregion

公共代理程序updateData(Agent objectId){

objectId.UserID = irewhizzrelation.GetUserId(objectId.username); objectId =(Agent)irewhizz.updateData(objectId); 返回objectId; }

public agent GetAgentData(Agent agentodj){agentodj.UserID = irewhizzrelation.GetUserId(agentodj.username); agentodj =(Agent)irewhizz.getData(agentodj); 如果(agentodj.RoleId!= 0)agentodj.Rolename =(string)(string)irewhizzrelation.getValue(agentodj.RoleId);

if(agentodj.RegisterdStates.Count()!= 0){

List<SelectListItem> list = new List<SelectListItem>();
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 list = new List(); string selectedlang =“”; foreach(int i在agentodj.Language中){SelectListItem listitem = new SelectListItem(); listitem.Value = i.ToString(); listitem.Text =(string)irewhizzrelation.getValue(i); list.Add(列表项); selectedlang + =(string)irewhizzrelation.getValue(i)+“,”;

}
SelectList selectlist = new SelectList(list, "Value", "Text");
agentodj.Languages = selectlist;
// agentodj.SelectedLanguages = selectedlang;

}

if(agentodj.Specialization.Count()!= 0){List list = new List(); string selectedspel =“”; foreach(int i在agentodj.Specialization中){SelectListItem listitem = new SelectListItem(); listitem.Value = i.ToString(); listitem.Text =(string)irewhizzrelation.getValue(i); list.Add(列表项); selectedspel + =(string)irewhizzrelation.getValue(i)+“,”; } SelectList selectlist = new SelectList(list,“Value”,“Text”); agentodj.Specializations = selectlist; //agentodj.SelectedSpecialization = selectedspel;

}

return agentodj;

}

public void SaveImage(byte [] pic,String username){irewhizzrelation.SaveImage(pic,username); }

}

现在的问题是,当我打电话给代理类时,它给出的错误就像rwuser类的空引用异常一样

任何机构都可以提前给出解决方案


你应该得到一个编译错误,因为你的接口被称为irewhzz,但你调用irewhizz。

但我猜测这只是一个复制粘贴错误,对吧?

链接地址: http://www.djcxy.com/p/46567.html

上一篇: Inheritance issue

下一篇: WPF multithreaded progress dialog