示例#1
0
        /// <summary>
        /// Gets the entity framework context.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        private ImageOptimizationEFDbContext GetContext(IImageOptimizationEFDataProvider provider)
        {
            if (provider.ProviderContext == null)
            {
                throw new Exception(String.Format("Provider {0} is not initialized.", provider.Name));
            }

            return(ImageOptimizationEFDataConnection.GetContext(this.connectionName, provider));
        }
示例#2
0
        public void Initialize(string providerName, NameValueCollection config, Type managerType)
        {
            this.connectionName = config["connectionName"];

            if (string.IsNullOrEmpty(this.connectionName))
            {
                this.connectionName = "Sitefinity"; /* the default connectionName */
            }
            var provider = this.DataProvider as IImageOptimizationEFDataProvider;

            if (provider != null)
            {
                ImageOptimizationEFDataConnection connection = ImageOptimizationEFDataConnection.InitializeConnection(this.connectionName, provider);

                provider.ProviderContext = new ImageOptimizationEFDataProviderContext()
                {
                    ProviderKey  = Guid.NewGuid().ToString(),
                    ConnectionId = connection.Name
                };

                this.connectionName = connection.Name;
            }
        }