Exemplo n.º 1
0
		public GroupsServiceBase(IConfigSource config, string cName)
			: base(config)
		{
			string dllName = String.Empty;
			string connString = String.Empty;
			string realm = "os_groups";
			string usersRealm = "GridUser";
			string configName = (cName == string.Empty) ? "Groups" : cName;

			//
			// Try reading the [DatabaseService] section, if it exists
			//
			IConfig dbConfig = config.Configs["DatabaseService"];
			if (dbConfig != null)
			{
				if (dllName == String.Empty)
					dllName = dbConfig.GetString("StorageProvider", String.Empty);
				if (connString == String.Empty)
					connString = dbConfig.GetString("ConnectionString", String.Empty);
			}

			//
			// [Groups] section overrides [DatabaseService], if it exists
			//
			IConfig groupsConfig = config.Configs[configName];
			if (groupsConfig != null)
			{
				dllName = groupsConfig.GetString("StorageProvider", dllName);
				connString = groupsConfig.GetString("ConnectionString", connString);
				realm = groupsConfig.GetString("Realm", realm);
			}

			//
			// We tried, but this doesn't exist. We can't proceed.
			//
			if (dllName.Equals(String.Empty))
				throw new Exception("No StorageProvider configured");

			m_Database = LoadPlugin<IGroupsData>(dllName, new Object[] { connString, realm });
			if (m_Database == null)
				throw new Exception("Could not find a storage interface in the given module " + dllName);

			//
			// [GridUserService] section overrides [DatabaseService], if it exists
			//
			IConfig usersConfig = config.Configs["GridUserService"];
			if (usersConfig != null)
			{
				dllName = usersConfig.GetString("StorageProvider", dllName);
				connString = usersConfig.GetString("ConnectionString", connString);
                usersRealm = usersConfig.GetString("Realm", usersRealm);
			}

			m_GridUserService = LoadPlugin<IGridUserData>(dllName, new Object[] { connString, usersRealm });
			if (m_GridUserService == null)
				throw new Exception("Could not find a storage inferface for the given users module " + dllName);
		}
        public GroupsServiceBase(IConfigSource config, string cName)
            : base(config)
        {
            string dllName    = String.Empty;
            string connString = String.Empty;
            string realm      = "os_groups";
            string configName = (cName == string.Empty) ? "Groups" : cName;

            //
            // Try reading the [DatabaseService] section, if it exists
            //
            IConfig dbConfig = config.Configs["DatabaseService"];

            if (dbConfig != null)
            {
                if (dllName == String.Empty)
                {
                    dllName = dbConfig.GetString("StorageProvider", String.Empty);
                }
                if (connString == String.Empty)
                {
                    connString = dbConfig.GetString("ConnectionString", String.Empty);
                }
            }

            //
            // [Groups] section overrides [DatabaseService], if it exists
            //
            IConfig groupsConfig = config.Configs[configName];

            if (groupsConfig != null)
            {
                dllName    = groupsConfig.GetString("StorageProvider", dllName);
                connString = groupsConfig.GetString("ConnectionString", connString);
                realm      = groupsConfig.GetString("Realm", realm);
            }

            //
            // We tried, but this doesn't exist. We can't proceed.
            //
            if (dllName.Equals(String.Empty))
            {
                throw new Exception("No StorageProvider configured");
            }

            m_Database = LoadPlugin <IGroupsData>(dllName, new Object[] { connString, realm });
            if (m_Database == null)
            {
                throw new Exception("Could not find a storage interface in the given module " + dllName);
            }
        }