CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Design time / Run time VM

622 Views
Copy Code Show/Hide Line Numbers
//Design time VM
 
        [Export]
        public ContactVM GetViewModel()
        {
            var contact = new Contact()
            {
                FirstName = "John",
                LastName = "Doe",
                City = "Design time",
                Address = "123 Any Street",
                State = "XXY",
                Zip = "99999"
            };
            var currentContactService = new CurrentContactService();
            currentContactService.Contact = contact;
 
            return new ContactVM(currentContactService);
        }
 
//Runtime VM
 
    [Export]
    public class ContactVM 
    {
        public ContactVM() {}
        
        [ImportingConstructor]
        public ContactVM(ICurrentContactService contactService)
        {
            Contact = contactService.Contact;
        }
 
        public Contact Contact { get; private set; }
    }
 
 
by Glenn Block
  December 07, 2009 @ 12:39pm
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate