Inside class inherit base class which can't import .

Feb 21, 2012 at 4:08 AM

Public Class RoleViewModel
{

       public List<RoleEditViewModel> Role
        {
            get
            {
                if (Model == null)
                    return null;
                else
                    return new List<RoleEditViewModel> { new RoleEditViewModel(this, Model.Role) };
            }
        }

   public class RoleEditViewModel: EditViewModel<Role>
        {   
  public RoleViewModel Parent { get; private set; }
            public RoleEditViewModel(RoleViewModel parent, Role role)
            {
                ManageObjectLifetime = false;
                Parent = parent;
                Model = role;
                
            }  
}

}


  public class EditViewModel<T> : Csla.Xaml.ViewModelBase<T>
{
   [Import]
        public IRegionManager RegionManager { get; set; }

        [Import]
        public IShellViewModel Shell { get; set; }

}

Run the code ,the RegionManager & Shell  are null.

Coordinator
Feb 21, 2012 at 7:41 AM
What ate you exporting?? Cannot tell from the code you have provided.

- alok

From: Cuiqs
Sent: 2/20/2012 9:09 PM
To: Alok Shriram
Subject: Inside class inherit base class which can't import . [MEF:334351]

From: Cuiqs

Public Class RoleViewModel
{

       public List<RoleEditViewModel> Role
        {
            get
            {
                if (Model == null)
                    return null;
                else
                    return new List<RoleEditViewModel> { new RoleEditViewModel(this, Model.Role) };
            }
        }

   public class RoleEditViewModel: EditViewModel<Role>
        {   
  public RoleViewModel Parent { get; private set; }
            public RoleEditViewModel(RoleViewModel parent, Role role)
            {
                ManageObjectLifetime = false;
                Parent = parent;
                Model = role;
                
            }  
}

}


  public class EditViewModel<T> : Csla.Xaml.ViewModelBase<T>
{
   [Import]
        public IRegionManager RegionManager { get; set; }

        [Import]
        public IShellViewModel Shell { get; set; }

}

Run the code ,the RegionManager & Shell  are null.

Feb 21, 2012 at 11:59 AM

the Exporting in another module.

If  in the EditViewModel  constractor use below code. it work fine.

 public EditViewModel()
        {
      
            this.Shell = ServiceLocator.Current.GetInstance<IShellViewModel>();
            this.RegionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
          
        }

Feb 22, 2012 at 12:12 PM

the Exporting in another module.

If  in the EditViewModel  constractor use below code. it work fine.

 

 public EditViewModel()
        {
      
            this.Shell = ServiceLocator.Current.GetInstance<IShellViewModel>();
            this.RegionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
          
        }


alokshriram wrote:
What ate you exporting?? Cannot tell from the code you have provided.

- alok

From: Cuiqs
Sent: 2/20/2012 9:09 PM
To: Alok Shriram
Subject: Inside class inherit base class which can't import . [MEF:334351]

From: Cuiqs

 

Public Class RoleViewModel
{

       public List<RoleEditViewModel> Role
        {
            get
            {
                if (Model == null)
                    return null;
                else
                    return new List<RoleEditViewModel> { new RoleEditViewModel(this, Model.Role) };
            }
        }

   public class RoleEditViewModel: EditViewModel<Role>
        {   
  public RoleViewModel Parent { get; private set; }
            public RoleEditViewModel(RoleViewModel parent, Role role)
            {
                ManageObjectLifetime = false;
                Parent = parent;
                Model = role;
                
            }  
}

}


  public class EditViewModel<T> : Csla.Xaml.ViewModelBase<T>
{
   [Import]
        public IRegionManager RegionManager { get; set; }

        [Import]
        public IShellViewModel Shell { get; set; }

}

Run the code ,the RegionManager & Shell  are null.

 

 

Feb 22, 2012 at 4:31 PM

Hi – I think what Alok is asking is, how is EditViewModel<T> being exported? If it is not being exported at all, are you using something like SatisfyImportsOnce() to set its imports? Classes with imports need to be either exported themselves, or composed using one of the methods on the container, in order for their imports to be set.

Hope this helps,
Nick

From: Cuiqs [email removed]
Sent: Wednesday, February 22, 2012 5:12 AM
To: Nicholas Blumhardt
Subject: Re: Inside class inherit base class which can't import . [MEF:334351]

From: Cuiqs

the Exporting in another module.

If in the EditViewModel constractor use below code. it work fine.

 public EditViewModel()
        {
      
            this.Shell = ServiceLocator.Current.GetInstance<IShellViewModel>();
            this.RegionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
          
        }

alokshriram wrote:

What ate you exporting?? Cannot tell from the code you have provided.

- alok


From: Cuiqs
Sent: 2/20/2012 9:09 PM
To: Alok Shriram
Subject: Inside class inherit base class which can't import . [MEF:334351]

From: Cuiqs

Public Class RoleViewModel
{
 
       public List<RoleEditViewModel> Role
        {
            get
            {
                if (Model == null)
                    return null;
                else
                    return new List<RoleEditViewModel> { new RoleEditViewModel(this, Model.Role) };
            }
        }
 
   public class RoleEditViewModel: EditViewModel<Role>
        {   
  public RoleViewModel Parent { get; private set; }
            public RoleEditViewModel(RoleViewModel parent, Role role)
            {
                ManageObjectLifetime = false;
                Parent = parent;
                Model = role;
                
            }  
}
 
}
 
 
  public class EditViewModel<T> : Csla.Xaml.ViewModelBase<T>
{
   [Import]
        public IRegionManager RegionManager { get; set; }
 
        [Import]
        public IShellViewModel Shell { get; set; }
 
}
 
Run the code ,the RegionManager & Shell  are null.
 

Feb 28, 2012 at 3:17 PM

Alok. thank you.