示例#1
0
        /// <summary
        /// Returns an <see cref="Provisioning.Common.Data.ISiteRequestManager"/> interface for working with the SiteRequest Repository
        /// Custom implementations must implement <see cref="Provisioning.Common.Data.ISiteRequestManager"/>
        /// This member reads from your configuration file and the app setting RepositoryManagerType must be defined. 
        /// <add key="RepositoryManagerType" value="Provisioning.Common.Data.Impl.SPSiteRequestManagerImpl, Provisioning.Common" />
        /// <returns><see cref="Provisioning.Common.Data.ISiteRequestManager"/></returns>
        /// </summary>
        public ISiteRequestManager GetSiteRequestManager()
        {
            var _configManager = new ConfigManager();
            var _module = _configManager.GetModuleByName(ModuleKeys.REPOSITORYMANGER_KEY);
            var _managerTypeString = _module.ModuleType;

            if (string.IsNullOrEmpty(_managerTypeString)) throw new ConfigurationErrorsException(PCResources.Exception_Template_Provider_Missing_Config_Message);
          
            try { 
                var type = _managerTypeString.Split(',');
                var typeName = type[0];
                var assemblyName = type[1];
                var instance = (AbstractModule)Activator.CreateInstance(assemblyName, typeName).Unwrap();
                if (String.IsNullOrEmpty(_module.ConnectionString))
                {
                    instance.ConnectionString = SC.ConfigurationManager.AppSettings.Get(ModuleKeys.REPOSITORYMANGER_KEY + "_connectionString");
                }
                else
                {
                    instance.ConnectionString = _module.ConnectionString;
                }
                instance.Container = _module.Container;
                return (ISiteRequestManager)instance;
            }
            catch(Exception _ex)
            {
                throw new DataStoreException("Exception Occured while Creating Instance" ,_ex);
            }
         
        }
示例#2
0
        public IMetadataManager GetManager()
        {
            var _configManager = new ConfigManager();
            var _module = _configManager.GetModuleByName(ModuleKeys.METADATAMANGER_KEY);
            var _managerTypeString = _module.ModuleType;

            if (string.IsNullOrEmpty(_managerTypeString))
            {
                var _message = "MetadataManager is missing from the configuration file.  Please update the configuration file.";
                throw new ConfigurationErrorsException(_message);
            }
            try
            {
                var type = _managerTypeString.Split(',');
                var typeName = type[0];
                var assemblyName = type[1];
                var instance = (AbstractModule)Activator.CreateInstance(assemblyName, typeName).Unwrap();
                instance.ConnectionString = _module.ConnectionString;
                instance.Container = _module.Container;
                return (IMetadataManager)instance;
            }
            catch (Exception _ex)
            {
                throw new DataStoreException("Exception occured while creating instance", _ex);
            }
         
        }
示例#3
0
        /// <summary>
        /// Returns an <see cref="Provisioning.Common.Configuration.TemplateISiteTemplateManager"/> interface. This member reads from your configuration file and the app setting TemplateProviderType and must be defined. 
        /// Custom implementations must implement <see cref="Provisioning.Common.Configuration.TemplateISiteTemplateManager"/>
        /// <add key="TemplateProviderType"  value="Provisioning.Common.Configuration.Template.Impl.XMLSiteTemplateManager, Provisioning.Common"/>
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.Configuration.ConfigurationErrorsException"></exception>
        /// <exception cref="Provisioning.Common.Data.FactoryException">Exception that occurs when the factory encounters an exception.</exception>
        public ISiteTemplateManager GetManager()
        {
            var _configManager = new ConfigManager();
            var _module = _configManager.GetModuleByName(ModuleKeys.MASTERTEMPLATEPROVIDER_KEY);
            var _managerTypeString = _module.ModuleType;

            if(string.IsNullOrEmpty(_managerTypeString))
            {
                //TODO LOG
                throw new ConfigurationErrorsException(PCResources.Exception_Template_Provider_Missing_Config_Message);
            }
            try
            {
                var type = _managerTypeString.Split(',');
                var typeName = type[0];
                var assemblyName = type[1];
                var instance = (AbstractModule)Activator.CreateInstance(assemblyName, typeName).Unwrap();
                instance.ConnectionString = _module.ConnectionString;
                instance.Container = _module.Container;
                Log.Info("Provisioning.Common.Data.Templates", PCResources.SiteTemplate_Factory_Created_Instance, _managerTypeString);
                return (ISiteTemplateManager)instance;
            }
            catch (Exception _ex)
            {
                var _message = String.Format(PCResources.SiteTemplate_Factory_Created_Instance_Exception, _managerTypeString);
                Log.Info("Provisioning.Common.Data.Templates", _message) ;
                throw new FactoryException(_message, _ex);
            }
        }
示例#4
0
 public void CanGetModulesByKey()
 {
     ConfigManager _cm = new ConfigManager();
     var module = _cm.GetModuleByName(ModuleKeys.REPOSITORYMANGER_KEY);
     Assert.IsNotNull(module.Name);
     Assert.IsNotNull(module);
 }