コード例 #1
0
 public EntityServiceChannelBuilder(CacheEntityContextBuilder builder)
 {
     if (builder == null)
         throw new ArgumentNullException("builder");
     Builder = builder;
     DataFormatter = new EntityServiceFormatter(builder);
 }
コード例 #2
0
 public EntityServiceChannelBuilder(CacheEntityContextBuilder builder)
 {
     if (builder == null)
     {
         throw new ArgumentNullException("builder");
     }
     Builder       = builder;
     DataFormatter = new EntityServiceFormatter(builder);
 }
コード例 #3
0
        public EntityServiceClient(DbContext localContext, IPEndPoint endPoint)
            : base(endPoint)
        {
            DataFormatter = new EntityServiceFormatter(this);

            if (LocalContext == null)
            {
                throw new ArgumentNullException("localContext");
            }
            LocalContext = localContext;

            List <Type> types = new List <Type>();

            foreach (var property in LocalContext.GetType().GetProperties())
            {
                if (!property.PropertyType.IsGenericType)
                {
                    continue;
                }
                if (property.PropertyType.GetGenericTypeDefinition() != typeof(DbSet <>))
                {
                    continue;
                }
                types.Add(property.PropertyType.GetGenericArguments()[0]);
            }
            EntityTypes = types.ToArray();

            Channels = new Dictionary <Type, ServiceChannel>();
            foreach (var type in EntityTypes)
            {
                Type            contract = typeof(ICacheEntityQueryable <>).MakeGenericType(new Type[] { type });
                ServiceProvider provider = new ServiceProvider(null, contract);
                ServiceChannel  channel  = new ServiceChannel("Comboost_EntityChannel_" + type.Name, provider, DataFormatter);
                Channels.Add(type, channel);
            }

            Factories = new Dictionary <Type, object>();
            Instaces  = new Dictionary <Type, object>();
        }