Inheritance: ReflectionModelTypeProvider
示例#1
0
文件: JsonModel.cs 项目: vc3/ExoModel
        public static JsonEntityContext Initialize(Assembly @assembly, string @namespace, string storagePath, Action<ModelContext> onContextCreated = null)
        {
            var contextProvider = new ModelContextProvider();

            var entityContext = new JsonEntityContext(storagePath, false, GetEntityTypes(@assembly, @namespace).ToArray());

            contextProvider.CreateContext += (s, args) =>
            {
                // TODO: Reset entity context when a model context is created?
                var typeProvider = new JsonModelTypeProvider(@assembly, @namespace, entityContext);
                var ctx = args.Context = new ModelContext(typeProvider);
                if (onContextCreated != null)
                    onContextCreated(ctx);
            };

            return entityContext;
        }
示例#2
0
        public static JsonEntityContext Initialize(Assembly @assembly, string @namespace, string storagePath, Action <ModelContext> onContextCreated = null)
        {
            var contextProvider = new ModelContextProvider();

            var entityContext = new JsonEntityContext(storagePath, false, GetEntityTypes(@assembly, @namespace).ToArray());

            contextProvider.CreateContext += (s, args) =>
            {
                // TODO: Reset entity context when a model context is created?
                var typeProvider = new JsonModelTypeProvider(@assembly, @namespace, entityContext);
                var ctx          = args.Context = new ModelContext(typeProvider);
                if (onContextCreated != null)
                {
                    onContextCreated(ctx);
                }
            };

            return(entityContext);
        }