Пример #1
0
        private void Init(object connection, MappingSource mapping)
        {
            _perInstanceProviderMode = DataContext.ProviderMode;
            MetaModel model = mapping.GetModel(this.GetType());

            this._services  = new CommonDataServices(this, model);
            this._conflicts = new ChangeConflictCollection();

            // determine provider
            Type providerType;

            if (model.ProviderType != null)
            {
                providerType = model.ProviderType;
            }
            else
            {
                throw Error.ProviderTypeNull();
            }

            if (!typeof(IProvider).IsAssignableFrom(providerType))
            {
                throw Error.ProviderDoesNotImplementRequiredInterface(providerType, typeof(IProvider));
            }

            this._provider = (IProvider)Activator.CreateInstance(providerType);
            SetProviderMode();
            this._provider.Initialize(this._services, connection);

            this._tables = new Dictionary <MetaTable, ITable>();
            this.InitTables(this);
        }
Пример #2
0
        private void Init(object connection, MappingSource mapping)
        {
            var model = mapping.GetModel(GetType());

            services  = new CommonDataServices(this, model);
            conflicts = new ChangeConflictCollection();

            // determine provider
            if (model.ProviderType == null)
            {
                throw Error.ProviderTypeNull();
            }
            var providerType = model.ProviderType;

            if (!typeof(IProvider).IsAssignableFrom(providerType))
            {
                throw Error.ProviderDoesNotImplementRequiredInterface(providerType, typeof(IProvider));
            }

            provider = (IProvider)Activator.CreateInstance(providerType);
            provider.Initialize(services, connection);

            tables = new Dictionary <MetaTable, ITable>();
            InitTables(this);
        }