Exemplo n.º 1
0
        /// <summary>
        /// Read method helps get configuration data (based on the current environment value)
        /// </summary>
        /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
        /// <param name="propName">The property name to read</param>
        /// <returns>
        ///  The value of the property stored in the given affiliate application of this component.
        /// </returns>
        public static string Read(string appName, string propName)
        {
            Guid   callToken      = TraceManager.CustomComponent.TraceIn(appName, propName);
            object propertyValue  = null;
            string propNameToRead = string.Format("{0}_{1}", Environment, propName);

            try
            {
                SSOConfigStore           ssoStore   = new SSOConfigStore();
                ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
                ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, IdenifierGuid, SSOFlag.SSO_FLAG_RUNTIME,
                                                          (IPropertyBag)appMgmtBag);
                appMgmtBag.Read(propNameToRead, out propertyValue, 0);
                // In case the result is null, we try to read the property without pre-pending the environment
                if (null == propertyValue)
                {
                    return(ReadInternal(appName, propName));
                }
            }
            catch (Exception e)
            {
                TraceManager.CustomComponent.TraceInfo("Failed to read '{0}' for application '{1}'", propNameToRead,
                                                       appName);
                TraceManager.CustomComponent.TraceError(e);
                throw;
            }
            finally
            {
                TraceManager.CustomComponent.TraceOut(callToken, propertyValue);
            }
            return((string)propertyValue);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Read method helps get configuration data (wihtout taking environment into account)
 /// </summary>
 /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
 /// <param name="propName">The property name to read</param>
 /// <returns>
 ///  The value of the property stored in the given affiliate application of this component.
 /// </returns>
 private static string ReadInternal(string appName, string propName)
 {
     try
     {
         SSOConfigStore           ssoStore   = new SSOConfigStore();
         ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
         ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, IdenifierGuid, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
         object propertyValue = null;
         appMgmtBag.Read(propName, out propertyValue, 0);
         return((string)propertyValue);
     }
     catch (Exception e)
     {
         TraceManager.CustomComponent.TraceInfo("Failed to read '{0}' for application '{1}'", propName, appName);
         TraceManager.CustomComponent.TraceError(e);
         throw;
     }
 }