Beispiel #1
0
        public virtual IController <TContext, TModel> Select(JToken jToken)
        {
            switch (jToken)
            {
            case JValue jValue:
                Guid guid = new Guid();
                if (Guid.TryParse(jToken.ToString(), out guid))
                {
                    Bridge.Model bridgeModel = this.Context.Bridge[guid];
                    if (bridgeModel != null)
                    {
                        if (bridgeModel.Controller == null)
                        {
                            bridgeModel.Controller = this.Context[bridgeModel];
                        }
                        return((IController <TContext, TModel>)bridgeModel.Controller);
                    }
                }
                return(this.Select(jValue));

            case JObject jObject:
                return(this.Select(jObject));

            default:
                throw new Exception("Invalid Token");
            }
        }
Beispiel #2
0
 public IController <Context, Model> this[Bridge.Model bridgeModel] {
     get {
         if (bridgeModel.Controller != null)
         {
             return(bridgeModel.Controller);
         }
         bridgeModel.Controller = this[bridgeModel.Type, bridgeModel.Value];
         if (bridgeModel.Controller == null)
         {
             bridgeModel.Controller = this[bridgeModel.Type].Create(bridgeModel.Value);
         }
         return(bridgeModel.Controller);
     }
 }
Beispiel #3
0
        public void ValidateChanges(Bridge.Context bridgeContext)
        {
            foreach (var entry in this.ChangeTracker.Entries().Where(x => x.State != EntityState.Unchanged))
            {
                Bridge.Model bridgeModel = bridgeContext.Models.FirstOrDefault(x => x.Controller.Model == (Data.Model)entry.Entity);
                if (bridgeModel == null)
                {
                    bridgeModel = new Bridge.Model(this[(Data.Model)entry.Entity]);
                    bridgeContext.Models.Add(bridgeModel);
                }

                bridgeModel.ValidateChanges();
            }
        }