object IConvertible.ToType(Type conversionType, IFormatProvider provider)
 {
     try
     {
         IEntityBuffer eb = EntityBufferCollection.Instance[this.GetType()];
         if (eb != null)
         {
             return(eb.Get(this.Identity));
         }
         else
         {
             using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository(this.GetType()))
             {
                 rep.BeginTransaction();
                 var r = rep.Get(this.GetType(), this.Identity);
                 rep.CommitTransaction();
                 return(r);
             }
         }
     }
     catch (Exception ex)
     {
         throw new InvalidCastException("Convert is invalid!", ex);
     }
 }
        private object TryGetCachedTarget(Type persistentClass, object id)
        {
            IEntityBuffer eb = EntityBufferCollection.Instance[persistentClass];

            if (eb == null)
            {
                return(null);
            }
            return(eb.Get(id));
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public object Get(Type type, object id)
        {
            IEntityBuffer eb = this[type];

            if (eb == null)
            {
                throw new ArgumentException(string.Format("There is no EntityBuffer with {0}!", type));
            }
            return(eb.Get(id));
        }