public List <Widget> AddWidgetToMachine(Widget newWidget)
        {
            // first lets get an object ready to send to our pretend API.  This endpong needs
            // a Widget with the added property "dateTime"
            HttpObjFactoryBase sendFactory = (HttpObjFactoryBase)ViewModelLocator.Container.Resolve <ISendHttpObjFactory>();
            IHttpObj           widget      = sendFactory.GetWidget(newWidget);

            // now that our object is ready, lets send it to our pretend API (we don't actually use the object above, just pretend we do).
            // lets now pretend the next line is the response from the API.
            var response = @"{'first_Name':'Izzy','last_Name':'Gonzales'}";
            // Unfortunately for us,
            // the response is in a different format than most of our other models.  The response has
            // the property names with underscores! So we'll send it to our factories to get back a proper type we can use
            HttpObjFactoryBase responseFactory = (HttpObjFactoryBase)ViewModelLocator.Container.Resolve <IResponseHttpObjFactory>();
            var responseWidget = (Widget)responseFactory.GetWidget <string>(response);


            if (widgets == null)
            {
                widgets = new List <Widget>();
            }
            if (widgets.Count < 3)
            {
                widgets.Add(responseWidget);
            }
            return(widgets);
        }
        public override IHttpObj CreateWidget(IHttpObj httpObj)
        {
            var x = new WidgetVariant1()
            {
                firstName = (httpObj as Widget).firstName,
                lastName  = (httpObj as Widget).lastName,
                dateTime  = DateTime.Now
            };

            return(x);
        }
예제 #3
0
 public abstract IHttpObj CreateWidget(IHttpObj httpObj);
 public override IHttpObj CreateWidget(IHttpObj httpObj)
 {
     throw new NotImplementedException();
 }