Model View Presenter项目类给出空值

时间:2019-01-06 20:41:57

标签: c# mvp webformsmvp

在我的项目中,我创建了一个对象并放置了一些值,但是当保存这些值时,我无法像

一样在演示者中获得相同的值

我将这些值输入到组件文件中

SaveOrder abcd = somecomponent.create();

在somecomponent.cs文件中,我像

这样写了create()方法
public SaveOrder create()
{
    abcd.xyz = new Data.Hibernate.Model.dddd.xyz();

    abcd.xyz .Customer = blahblah;
    abcd.xyz .Device = blahblah;
} 

在SaveOrder.cs文件中,我将xyz声明为这样

  public virtual xyz xyz{ get; set; }

我的xyz.cs就是这样

namespace Myproject.Data.Hibernate.Model.xyz
{
    [Serializable] public class xyz: IEntity, IEquatable<xyz>
    {      
        public virtual int Id { get; set; }
        public virtual string Other { get; set; }
        public virtual int? Device { get; set; }

    public override int GetHashCode()
    {
        unchecked
        {
            int hashCode = Id;
            hashCode = (hashCode * 397) ^ (Other != null ? Other.GetHashCode() : 0);
            hashCode = (hashCode * 397) ^ Device.GetHashCode();
            return hashCode;
        }
    }

    public virtual bool Equals(xyz other)
    {
        if (ReferenceEquals(null, other)) return false;
        if (ReferenceEquals(this, other)) return true;
        return Id == other.Id 
            && string.Equals(Other, other.Other) 
            && Device == other.Device;
    }

    public override bool Equals(object obj)
    {
        if (ReferenceEquals(null, obj)) return false;
        if (ReferenceEquals(this, obj)) return true;
        if (obj.GetType() != GetType()) return false;
        return Equals((xyz)obj);
    }      
}

我的Presenter文件就是这样

namespace Myproject.Business.Presenters.xyz
{
    public abstract class BasexyzTabPresenter<TOrderComponent, TOrder> 
        : BaseTabPresenter<IPageView>
        where TOrderComponent : BaseComponent<TOrder>
        where TOrder : BaseOrder
    {
        private readonly XYZPanel _xyzPanel;

        private readonly TOrder _order;
        private readonly TOrderComponent _orderComponent;
        protected BasexyzTabPresenter
            (TOrderComponent orderComponent, XYZPanel xyzPanel, TOrder order, IPageView view)
            : base(view)
        {
            _xyzPanel = xyzPanel;
            _order = order;
            _orderComponent = orderComponent;
        }

在演示者中,我无法在TOrder order中获得xyz.cs文件的值。

编辑

在SaveOrder.cs中,公共虚拟xyz xyz {get;组;当控制权交给演示者时,无法访问模型。这是这里的主要问题。请帮助

0 个答案:

没有答案