예제 #1
0
        /// <summary>Gets a data provider instance for the specified entity type.</summary>
        public virtual IDataProvider GetProvider(Type type)
        {
            IDataProvider result = null;
            ICache        cache  = Context.Current.GetService <ICache>();

            if (type == typeof(Person))
            {
                result = new PersonDataProvider(cache);
            }
            else if (type.IsInterface)
            {
                result = new InterfaceDataProvider(type);
            }

            if (result == null)
            {
                throw new NotSupportedException(type + " is not a data-supported type.");
            }
            else if (ConnectionString.HasValue())
            {
                result.ConnectionString = ConnectionString;
            }
            else if (ConnectionStringKey.HasValue())
            {
                result.ConnectionStringKey = ConnectionStringKey;
            }

            return(result);
        }
        /// <summary>Gets a data provider instance for the specified entity type.</summary>
        public virtual IDataProvider GetProvider(Type type)
        {
            IDataProvider result = null;

            if (type == typeof(Domain.Administrator))
            {
                result = new AdministratorDataProvider();
            }
            else if (type == typeof(Domain.User))
            {
                result = new UserDataProvider();
            }
            else if (type == typeof(Domain.ApplicationEvent))
            {
                result = new ApplicationEventDataProvider();
            }
            else if (type == typeof(Domain.PasswordResetTicket))
            {
                result = new PasswordResetTicketDataProvider();
            }
            else if (type == typeof(Domain.LogonFailure))
            {
                result = new LogonFailureDataProvider();
            }
            else if (type == typeof(Domain.ContentBlock))
            {
                result = new ContentBlockDataProvider();
            }
            else if (type == typeof(Domain.Settings))
            {
                result = new SettingsDataProvider();
            }
            else if (type.IsInterface)
            {
                result = new InterfaceDataProvider(type);
            }

            if (result == null)
            {
                throw new NotSupportedException(type + " is not a data-supported type.");
            }
            else if (this.ConnectionString.HasValue())
            {
                result.ConnectionString = this.ConnectionString;
            }
            else if (this.ConnectionStringKey.HasValue())
            {
                result.ConnectionStringKey = this.ConnectionStringKey;
            }

            return(result);
        }
예제 #3
0
        /// <summary>Gets a data provider instance for the specified entity type.</summary>
        public virtual IDataProvider GetProvider(Type type)
        {
            IDataProvider result = null;

            if (type.IsInterface)
            {
                result = new InterfaceDataProvider(type);
            }

            if (result == null)
            {
                throw new NotSupportedException(type + " is not a data-supported type.");
            }
            else if (this.ConnectionString.HasValue())
            {
                result.ConnectionString = this.ConnectionString;
            }
            else if (this.ConnectionStringKey.HasValue())
            {
                result.ConnectionStringKey = this.ConnectionStringKey;
            }

            return(result);
        }