Beispiel #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;
        }
Beispiel #2
0
 internal JsonModelTypeProvider(Assembly @assembly, string @namespace, JsonEntityContext entityContext)
     : base(@namespace, JsonModel.GetEntityTypes(@assembly, @namespace), null, true)
 {
     EntityContext = entityContext;
 }
Beispiel #3
0
 internal JsonModelType(JsonEntityContext entityContext, string @namespace, Type type, string scope, string format)
     : base(@namespace, type, scope, format)
 {
     this._entityContext = entityContext;
     this._type = type;
 }
Beispiel #4
0
 internal JsonModelTypeProvider(Assembly @assembly, JsonEntityContext entityContext)
     : base(null, JsonModel.GetEntityTypes(@assembly), null, true)
 {
     EntityContext = entityContext;
 }