Example #1
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;
        }
Example #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);
        }