Ejemplo n.º 1
0
        public virtual void AddObject(TModel model, bool allocate = true)
        {
            IComparable key = typeof(TModel).GetProperty(keyProp).GetValue(model) as IComparable;
            TObject     obj;

            if (allocate)
            {
                obj = instantiator.NewObjectFromModel(model);
            }
            else
            {
                obj = model as TObject;
            }

            if (obj == null)
            {
                return;
            }

            // add the new key and sort the list
            this.keys.Add(key);
            this.keys.Sort();

            int index = this.keys.IndexOf(key);

            this.Insert(index, obj);
        }
Ejemplo n.º 2
0
        public async Task <List <TargetDevice> > GetCompatibleDevices(IObjectsCollectionInstantiator <TargetDevice, TorizonRestAPI.Model.TargetDevice> instantiator)
        {
            List <TorizonRestAPI.Model.TargetDevice> models = Utils.ObjectOrException <List <TorizonRestAPI.Model.TargetDevice> >(await api.PlatformCompatibledevicesGetAsync(this.Id));

            List <TargetDevice> devices = new List <TargetDevice>();

            foreach (TorizonRestAPI.Model.TargetDevice model in models)
            {
                devices.Add(instantiator.NewObjectFromModel(model));
            }
            return(devices);
        }