public void Init (Type typeConfigHost, params object[] hostInitParams)
		{
			this.hostInitParams = hostInitParams;
			host = (IInternalConfigHost) Activator.CreateInstance (typeConfigHost);
			root = new InternalConfigurationRoot ();
			root.Init (host, false);
		}
 public override void InitForConfiguration(ref string locationSubPath, out string configPath,
     out string locationConfigPath, IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
 {
     // Stash the filemap so we can see if the machine config was explicitly specified
     _fileMap = (ConfigurationFileMap)hostInitConfigurationParams[0];
     base.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, hostInitConfigurationParams);
 }
Exemple #3
0
 public void Init(Type typeConfigHost, params object[] hostInitParams)
 {
     this.hostInitParams = hostInitParams;
     host = (IInternalConfigHost)Activator.CreateInstance(typeConfigHost);
     root = new InternalConfigurationRoot();
     root.Init(host, false);
 }
            /// <devdoc>
            ///     We delegate this to the ClientConfigurationHost. The only thing we need to do here is to
            ///     build a configPath from the ConfigurationUserLevel we get passed in.
            /// </devdoc>
            public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                                                      IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
            {
                ConfigurationUserLevel userLevel = (ConfigurationUserLevel)hostInitConfigurationParams[0];
                string desiredConfigPath         = null;

                Host = (IInternalConfigHost)TypeUtil.CreateInstanceWithReflectionPermission(ClientConfigurationHostTypeName);

                switch (userLevel)
                {
                case ConfigurationUserLevel.None:
                    desiredConfigPath = ClientHost.GetExeConfigPath();
                    break;

                case ConfigurationUserLevel.PerUserRoaming:
                    desiredConfigPath = ClientHost.GetRoamingUserConfigPath();
                    break;

                case ConfigurationUserLevel.PerUserRoamingAndLocal:
                    desiredConfigPath = ClientHost.GetLocalUserConfigPath();
                    break;

                default:
                    throw new ArgumentException(SR.GetString(SR.UnknownUserLevel));
                }


                Host.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, null, null, desiredConfigPath);
            }
Exemple #5
0
 void IConfigSystem.Init(Type typeConfigHost, params object[] hostInitParams)
 {
     this._configRoot = new InternalConfigRoot();
     this._configHost = (IInternalConfigHost)System.Configuration.TypeUtil.CreateInstanceWithReflectionPermission(typeConfigHost);
     this._configRoot.Init(this._configHost, false);
     this._configHost.Init(this._configRoot, hostInitParams);
 }
        void IInternalConfigHost.InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath, 
                IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams) {

            _configRoot = configRoot;
            configPath = null;
            locationConfigPath = null;
        }
 public virtual void InitForConfiguration(ref string locationSubPath, out string configPath,
                                          out string locationConfigPath,
                                          IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
 {
     Host.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot,
                               hostInitConfigurationParams);
 }
 public virtual void InitForConfiguration(ref string locationSubPath, out string configPath,
     out string locationConfigPath,
     IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
 {
     Host.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot,
         hostInitConfigurationParams);
 }
Exemple #9
0
 void IInternalConfigHost.InitForConfiguration(ref string locationSubPath, out string configPath,
                                               out string locationConfigPath,
                                               IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
 {
     configPath         = null;
     locationConfigPath = null;
 }
 public override void InitForConfiguration(ref string locationSubPath, out string configPath,
                                           out string locationConfigPath, IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
 {
     // Stash the filemap so we can see if the machine config was explicitly specified
     _fileMap = hostInitConfigurationParams[0] as ConfigurationFileMap;
     base.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, hostInitConfigurationParams);
 }
        public override void InitForConfiguration(ref string locationSubPath, out string configPath,
                                                  out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
        {
            _map = (ExeConfigurationFileMap)hostInitConfigurationParams[0];

            if (hostInitConfigurationParams.Length > 1 &&
                hostInitConfigurationParams[1] is ConfigurationUserLevel)
            {
                _level = (ConfigurationUserLevel)hostInitConfigurationParams[1];
            }

            CheckFileMap(_level, _map);

            configPath = null;

            locationConfigPath = null;

            if (locationSubPath == "exe" || locationSubPath == null && _map.ExeConfigFilename != null)
            {
                configPath         = "exe";
                locationConfigPath = _map.ExeConfigFilename;
            }

            locationSubPath = null;
        }
Exemple #12
0
        public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
        {
            bool                 useConfigMapPath = (bool)hostInitParams[0];
            IConfigMapPath       configMapPath    = (IConfigMapPath)hostInitParams[1];
            ConfigurationFileMap fileMap          = (ConfigurationFileMap)hostInitParams[2];
            string               path             = (string)hostInitParams[3];
            string               str2             = (string)hostInitParams[4];
            string               str3             = (string)hostInitParams[5];

            if (hostInitParams.Length > 6)
            {
                string moniker = hostInitParams[6] as string;
                this._machineConfigFile = GetMachineConfigPathFromTargetFrameworkMoniker(moniker);
                if (!string.IsNullOrEmpty(this._machineConfigFile))
                {
                    this._rootWebConfigFile = Path.Combine(Path.GetDirectoryName(this._machineConfigFile), "web.config");
                }
            }
            base.Host.Init(configRoot, hostInitParams);
            this.ChooseAndInitConfigMapPath(useConfigMapPath, configMapPath, fileMap);
            path              = System.Web.Util.UrlPath.RemoveSlashFromPathIfNeeded(path);
            this._appPath     = VirtualPath.CreateAbsoluteAllowNull(path);
            this._appSiteName = str2;
            this._appSiteID   = str3;
            if (!string.IsNullOrEmpty(this._appSiteID) && (this._appPath != null))
            {
                this._appConfigPath = GetConfigPathFromSiteIDAndVPath(this._appSiteID, this._appPath);
            }
        }
        void IConfigSystem.Init(Type typeConfigHost, params object[] hostInitParams) {
            _configRoot = new InternalConfigRoot();
            _configHost = (IInternalConfigHost) TypeUtil.CreateInstanceWithReflectionPermission(typeConfigHost);

            _configRoot.Init(_configHost, false);
            _configHost.Init(_configRoot, hostInitParams);
        }
Exemple #14
0
        void IConfigSystem.Init(Type typeConfigHost, params object[] hostInitParams)
        {
            _configRoot = new InternalConfigRoot();
            _configHost = (IInternalConfigHost)TypeUtil.CreateInstance(typeConfigHost);

            _configRoot.Init(_configHost, false);
            _configHost.Init(_configRoot, hostInitParams);
        }
 internal ClientConfigurationSystem()
 {
     this._configSystem.Init(typeof(ClientConfigurationHost), new object[2]);
     this._configHost = (ClientConfigurationHost) this._configSystem.Host;
     this._configRoot = this._configSystem.Root;
     this._configRoot.ConfigRemoved += new InternalConfigEventHandler(this.OnConfigRemoved);
     this._isAppConfigHttp = this._configHost.IsAppConfigHttp;
     string schemeDelimiter = Uri.SchemeDelimiter;
 }
        public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
        {
            try
            {
                ConfigurationFileMap fileMap = (ConfigurationFileMap)hostInitParams[0];
                _exePath = (string)hostInitParams[1];

                Host.Init(configRoot, hostInitParams);

                // Do not complete initialization in runtime config, to avoid expense of
                // loading user.config files that may not be required.
                _initComplete = configRoot.IsDesignTime;

                if ((fileMap != null) && !string.IsNullOrEmpty(_exePath))
                {
                    throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Init");
                }

                if (string.IsNullOrEmpty(_exePath))
                {
                    _exePath = null;
                }

                // Initialize the fileMap, if provided.
                if (fileMap != null)
                {
                    _fileMap = new ExeConfigurationFileMap();
                    if (!string.IsNullOrEmpty(fileMap.MachineConfigFilename))
                    {
                        _fileMap.MachineConfigFilename = Path.GetFullPath(fileMap.MachineConfigFilename);
                    }

                    ExeConfigurationFileMap exeFileMap = fileMap as ExeConfigurationFileMap;
                    if (exeFileMap != null)
                    {
                        if (!string.IsNullOrEmpty(exeFileMap.ExeConfigFilename))
                        {
                            _fileMap.ExeConfigFilename = Path.GetFullPath(exeFileMap.ExeConfigFilename);
                        }

                        if (!string.IsNullOrEmpty(exeFileMap.RoamingUserConfigFilename))
                        {
                            _fileMap.RoamingUserConfigFilename = Path.GetFullPath(exeFileMap.RoamingUserConfigFilename);
                        }

                        if (!string.IsNullOrEmpty(exeFileMap.LocalUserConfigFilename))
                        {
                            _fileMap.LocalUserConfigFilename = Path.GetFullPath(exeFileMap.LocalUserConfigFilename);
                        }
                    }
                }
            }
            catch
            {
                throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Init");
            }
        }
 internal ClientConfigurationSystem()
 {
     this._configSystem.Init(typeof(ClientConfigurationHost), new object[2]);
     this._configHost = (ClientConfigurationHost)this._configSystem.Host;
     this._configRoot = this._configSystem.Root;
     this._configRoot.ConfigRemoved += new InternalConfigEventHandler(this.OnConfigRemoved);
     this._isAppConfigHttp           = this._configHost.IsAppConfigHttp;
     string schemeDelimiter = Uri.SchemeDelimiter;
 }
        public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                                                  IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
        {
            locationSubPath    = null;
            configPath         = (string)hostInitConfigurationParams[2];
            locationConfigPath = null;

            Init(configRoot, hostInitConfigurationParams);
        }
        private HybridDictionary _streamInfoUpdates; // List of StreamInfo, including the main config file, the configSource this record uses, and
                                                    // new configSource stream added thru API


        static internal MgmtConfigurationRecord Create(
                IInternalConfigRoot         configRoot,
                IInternalConfigRecord       parent,
                string                      configPath,
                string                      locationSubPath) {

            MgmtConfigurationRecord configRecord = new MgmtConfigurationRecord();
            configRecord.Init(configRoot, parent, configPath, locationSubPath);
            return configRecord;
        }
        public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                                                  IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
        {
            WebLevel             webLevel = (WebLevel)hostInitConfigurationParams[0];
            ConfigurationFileMap fileMap  = (ConfigurationFileMap)hostInitConfigurationParams[1];
            VirtualPath          path     = VirtualPath.CreateAbsoluteAllowNull((string)hostInitConfigurationParams[2]);
            string site = (string)hostInitConfigurationParams[3];

            if (locationSubPath == null)
            {
                locationSubPath = (string)hostInitConfigurationParams[4];
            }

            Host.Init(configRoot, hostInitConfigurationParams);

            // Choose the implementation of IConfigMapPath.
            ChooseAndInitConfigMapPath(false, null, fileMap);

            // Get the configuration paths and application information
            GetConfigPaths(_configMapPath, webLevel, path, site, locationSubPath, out _appPath, out _appSiteName, out _appSiteID, out configPath, out locationConfigPath);
            _appConfigPath = GetConfigPathFromSiteIDAndVPath(_appSiteID, _appPath);

            // Verify that the site and path arguments represent a valid name
            // For example, in Cassini app, which is running on \myApp, a page can
            // ask for the config for "\", which can't map to anything.  We want
            // to catch this kind of error.  Another example is if we're given
            // an invalid site id.
            if (IsVirtualPathConfigPath(configPath))
            {
                string      finalSiteID;
                VirtualPath finalPath;
                GetSiteIDAndVPathFromConfigPath(configPath, out finalSiteID, out finalPath);

                string physicalPath;

                // attempt to use IConfigMapPath2 if provider supports it
                if (null != _configMapPath2)
                {
                    physicalPath = _configMapPath2.MapPath(finalSiteID, finalPath);
                }
                else
                {
                    physicalPath = _configMapPath.MapPath(finalSiteID, finalPath.VirtualPathString);
                }

                if (String.IsNullOrEmpty(physicalPath))
                {
                    throw new ArgumentOutOfRangeException("site");
                }
            }

#if DBG
            _inited = true;
#endif
        }
    public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                                              IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
    {
        Host.Init(configRoot, hostInitConfigurationParams);

        _fileMap = hostInitConfigurationParams[1] as ConfigurationFileMap;

        locationSubPath    = ConfigurationFactory.NormalizeLocationSubPath(locationSubPath, null);
        configPath         = "MACHINE/EXE";
        locationConfigPath = locationSubPath;
    }
        internal ClientConfigurationSystem() {
            _configSystem = new ConfigSystem();
            _configSystem.Init(typeof(ClientConfigurationHost), null, null);

            _configHost = (ClientConfigurationHost) _configSystem.Host;
            _configRoot = _configSystem.Root;

            _configRoot.ConfigRemoved += OnConfigRemoved;

            _isAppConfigHttp = _configHost.IsAppConfigHttp;
        }
Exemple #23
0
        internal ClientConfigurationSystem()
        {
            _configSystem = new ConfigSystem();
            _configSystem.Init(typeof(ClientConfigurationHost), null, null);

            _configHost = (ClientConfigurationHost)_configSystem.Host;
            _configRoot = _configSystem.Root;

            _configRoot.ConfigRemoved += OnConfigRemoved;

            _isAppConfigHttp = _configHost.IsAppConfigHttp;
        }
        private ContextInformation _evalContext;                        // evaluation context

        internal Configuration(string locationSubPath, Type typeConfigHost, params object[] hostInitConfigurationParams)
        {
            _typeConfigHost = typeConfigHost;
            _hostInitConfigurationParams = hostInitConfigurationParams;

            _configRoot = new InternalConfigRoot();

            IInternalConfigHost configHost = (IInternalConfigHost)TypeUtil.CreateInstanceWithReflectionPermission(typeConfigHost);

            // Wrap the host with the UpdateConfigHost to support SaveAs.
            IInternalConfigHost updateConfigHost = new UpdateConfigHost(configHost);

            _configRoot.Init(updateConfigHost, true);

            //
            // Set the configuration paths for this Configuration.
            // We do this in a separate step so that the WebConfigurationHost
            // can use this object's _configRoot to get the <sites> section,
            // which is used in it's MapPath implementation.
            //
            string configPath, locationConfigPath;

            configHost.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, _configRoot, hostInitConfigurationParams);

            if (!String.IsNullOrEmpty(locationSubPath) && !updateConfigHost.SupportsLocation)
            {
                throw ExceptionUtil.UnexpectedError("Configuration::ctor");
            }

            if (String.IsNullOrEmpty(locationSubPath) != String.IsNullOrEmpty(locationConfigPath))
            {
                throw ExceptionUtil.UnexpectedError("Configuration::ctor");
            }

            // Get the configuration record for this config file.
            _configRecord = (MgmtConfigurationRecord)_configRoot.GetConfigRecord(configPath);

            //
            // Create another MgmtConfigurationRecord for the location that is a child of the above record.
            // Note that this does not match the resolution hiearchy that is used at runtime.
            //
            if (!String.IsNullOrEmpty(locationSubPath))
            {
                _configRecord = MgmtConfigurationRecord.Create(
                    _configRoot, _configRecord, locationConfigPath, locationSubPath);
            }

            //
            // Throw if the config record we created contains global errors.
            //
            _configRecord.ThrowIfInitErrors();
        }
Exemple #25
0
        void IConfigSystem.Init(Type typeConfigHost, params object[] hostInitParams)
        {
            _configRoot = new InternalConfigRoot();

            // Create the requested host and wrap in ImplicitMachineConfigHost so we can
            // stub in a simple machine.config if needed.
            IInternalConfigHost host = (IInternalConfigHost)TypeUtil.CreateInstance(typeConfigHost);

            _configHost = new ImplicitMachineConfigHost(host);

            _configRoot.Init(_configHost, isDesignTime: false);
            _configHost.Init(_configRoot, hostInitParams);
        }
Exemple #26
0
        internal ClientConfigurationSystem()
        {
            IConfigSystem configSystem = new ConfigSystem();

            configSystem.Init(typeof(ClientConfigurationHost), null, null);

            _configHost = configSystem.Host;
            _configRoot = configSystem.Root;

            _configRoot.ConfigRemoved += OnConfigRemoved;

            _isAppConfigHttp = ((IInternalConfigHostPaths)_configHost).IsAppConfigHttp;
        }
 public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
 {
     try
     {
         ConfigurationFileMap map = (ConfigurationFileMap)hostInitParams[0];
         this._exePath = (string)hostInitParams[1];
         base.Host.Init(configRoot, hostInitParams);
         this._initComplete = configRoot.IsDesignTime;
         if ((map != null) && !string.IsNullOrEmpty(this._exePath))
         {
             throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Init");
         }
         if (string.IsNullOrEmpty(this._exePath))
         {
             this._exePath = null;
         }
         if (map != null)
         {
             this._fileMap = new ExeConfigurationFileMap();
             if (!string.IsNullOrEmpty(map.MachineConfigFilename))
             {
                 this._fileMap.MachineConfigFilename = Path.GetFullPath(map.MachineConfigFilename);
             }
             ExeConfigurationFileMap map2 = map as ExeConfigurationFileMap;
             if (map2 != null)
             {
                 if (!string.IsNullOrEmpty(map2.ExeConfigFilename))
                 {
                     this._fileMap.ExeConfigFilename = Path.GetFullPath(map2.ExeConfigFilename);
                 }
                 if (!string.IsNullOrEmpty(map2.RoamingUserConfigFilename))
                 {
                     this._fileMap.RoamingUserConfigFilename = Path.GetFullPath(map2.RoamingUserConfigFilename);
                 }
                 if (!string.IsNullOrEmpty(map2.LocalUserConfigFilename))
                 {
                     this._fileMap.LocalUserConfigFilename = Path.GetFullPath(map2.LocalUserConfigFilename);
                 }
             }
         }
     }
     catch (SecurityException)
     {
         throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_client_config_init_security"));
     }
     catch
     {
         throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Init");
     }
 }
        private ContextInformation                  _evalContext;       // evaluation context

        internal Configuration(string locationSubPath, Type typeConfigHost, params object[] hostInitConfigurationParams) {
            _typeConfigHost = typeConfigHost;
            _hostInitConfigurationParams = hostInitConfigurationParams;

            _configRoot = new InternalConfigRoot();

            IInternalConfigHost configHost = (IInternalConfigHost) TypeUtil.CreateInstanceWithReflectionPermission(typeConfigHost);

            // Wrap the host with the UpdateConfigHost to support SaveAs.
            IInternalConfigHost updateConfigHost = new UpdateConfigHost(configHost);

            _configRoot.Init(updateConfigHost, true);

            //
            // Set the configuration paths for this Configuration.
            // We do this in a separate step so that the WebConfigurationHost
            // can use this object's _configRoot to get the <sites> section,
            // which is used in it's MapPath implementation.
            //
            string configPath, locationConfigPath;
            configHost.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, _configRoot, hostInitConfigurationParams);

            if (!String.IsNullOrEmpty(locationSubPath) && !updateConfigHost.SupportsLocation) {
                throw ExceptionUtil.UnexpectedError("Configuration::ctor");
            }

            if (String.IsNullOrEmpty(locationSubPath) != String.IsNullOrEmpty(locationConfigPath)) {
                throw ExceptionUtil.UnexpectedError("Configuration::ctor");
            }

            // Get the configuration record for this config file.
            _configRecord = (MgmtConfigurationRecord) _configRoot.GetConfigRecord(configPath);

            //
            // Create another MgmtConfigurationRecord for the location that is a child of the above record.
            // Note that this does not match the resolution hiearchy that is used at runtime.
            //
            if (!String.IsNullOrEmpty(locationSubPath)) {
                _configRecord = MgmtConfigurationRecord.Create(
                    _configRoot, _configRecord, locationConfigPath, locationSubPath);
            }

            //
            // Throw if the config record we created contains global errors.
            //
            _configRecord.ThrowIfInitErrors();
        }
Exemple #29
0
            /// <summary>
            /// We delegate this to the ClientConfigurationHost. The only thing we need to do here is to
            /// build a configPath from the ConfigurationUserLevel we get passed in.
            /// </summary>
            public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                                                      IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
            {
                ConfigurationUserLevel userLevel = (ConfigurationUserLevel)hostInitConfigurationParams[0];

                Host = TypeUtil.CreateInstance <IInternalConfigHost>(ClientConfigurationHostTypeName);

                string desiredConfigPath = userLevel switch
                {
                    ConfigurationUserLevel.None => ClientHost.GetExeConfigPath(),
                    ConfigurationUserLevel.PerUserRoaming => ClientHost.GetRoamingUserConfigPath(),
                    ConfigurationUserLevel.PerUserRoamingAndLocal => ClientHost.GetLocalUserConfigPath(),
                    _ => throw new ArgumentException(SR.UnknownUserLevel),
                };

                Host.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, null, null, desiredConfigPath);
            }
        internal ClientConfigurationSystem() {
            _configSystem = new ConfigSystem();
            _configSystem.Init(typeof(ClientConfigurationHost), null, null);

            _configHost = (ClientConfigurationHost) _configSystem.Host;
            _configRoot = _configSystem.Root;

            _configRoot.ConfigRemoved += OnConfigRemoved;

            _isAppConfigHttp = _configHost.IsAppConfigHttp;

            // VSWhidbey 606116: Config has a dependency on Uri class which has
            // a new static constructor that calls config.  We need a dummy reference
            // to Uri class so the static constructor would be involved first to
            // initialize config.
            string dummy = System.Uri.SchemeDelimiter;
        }
Exemple #31
0
        internal ClientConfigurationSystem()
        {
            _configSystem = new ConfigSystem();
            _configSystem.Init(typeof(ClientConfigurationHost), null, null);

            _configHost = (ClientConfigurationHost)_configSystem.Host;
            _configRoot = _configSystem.Root;

            _configRoot.ConfigRemoved += OnConfigRemoved;

            _isAppConfigHttp = _configHost.IsAppConfigHttp;

            // VSWhidbey 606116: Config has a dependency on Uri class which has
            // a new static constructor that calls config.  We need a dummy reference
            // to Uri class so the static constructor would be involved first to
            // initialize config.
            string dummy = System.Uri.SchemeDelimiter;
        }
        private void Init(
                IInternalConfigRoot         configRoot,
                IInternalConfigRecord       parent,
                string                      configPath,
                string                      locationSubPath) {

            base.Init(configRoot, (BaseConfigurationRecord) parent, configPath, locationSubPath);

            if (    IsLocationConfig &&
                    (MgmtParent._locationTags == null || !MgmtParent._locationTags.Contains(_locationSubPath))) {

                // By instantiating a "new" LocationSubPath class, we have implicitly
                // asked for one to be created
                _flags[ForceLocationWritten] = true;
            }

            // Copy all stream information so that we can model changes to ConfigSource
            InitStreamInfoUpdates();
        }
        public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
        {
            bool                 useConfigMapPath = (bool)hostInitParams[0];
            IConfigMapPath       configMapPath    = (IConfigMapPath)hostInitParams[1];
            ConfigurationFileMap fileMap          = (ConfigurationFileMap)hostInitParams[2];
            string               appPath          = (string)hostInitParams[3];
            string               appSiteName      = (string)hostInitParams[4];
            string               appSiteID        = (string)hostInitParams[5];

            if (hostInitParams.Length > 6)
            {
                // If VS sent a 7th param, it is the .Net Framwework Target version moniker
                string fxMoniker = hostInitParams[6] as string;
                _machineConfigFile = GetMachineConfigPathFromTargetFrameworkMoniker(fxMoniker);
                if (!string.IsNullOrEmpty(_machineConfigFile))
                {
                    _rootWebConfigFile = Path.Combine(Path.GetDirectoryName(_machineConfigFile), "web.config");
                }
            }

            Debug.Assert(configMapPath == null || useConfigMapPath, "non-null configMapPath without useConfigMapPath == true");

            Host.Init(configRoot, hostInitParams);

            ChooseAndInitConfigMapPath(useConfigMapPath, configMapPath, fileMap);

            appPath      = UrlPath.RemoveSlashFromPathIfNeeded(appPath);
            _appPath     = VirtualPath.CreateAbsoluteAllowNull(appPath);
            _appSiteName = appSiteName;
            _appSiteID   = appSiteID;

            if (!String.IsNullOrEmpty(_appSiteID) && _appPath != null)
            {
                _appConfigPath = GetConfigPathFromSiteIDAndVPath(_appSiteID, _appPath);
            }

#if DBG
            _inited = true;
#endif
        }
 internal static void EnsureInit(IConfigMapPath configMapPath, bool listenToFileChanges, bool initComplete)
 {
     if (!s_inited)
     {
         lock (s_initLock)
         {
             if (!s_inited)
             {
                 s_initComplete = initComplete;
                 if (configMapPath == null)
                 {
                     configMapPath = IISMapPath.GetInstance();
                 }
                 s_configMapPath = configMapPath;
                 s_configSystem = (IConfigSystem) Activator.CreateInstance(Type.GetType("System.Configuration.Internal.ConfigSystem, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", true), true);
                 object[] hostInitParams = new object[6];
                 hostInitParams[0] = true;
                 hostInitParams[1] = s_configMapPath;
                 hostInitParams[3] = HostingEnvironment.ApplicationVirtualPath;
                 hostInitParams[4] = HostingEnvironment.SiteNameNoDemand;
                 hostInitParams[5] = HostingEnvironment.SiteID;
                 s_configSystem.Init(typeof(WebConfigurationHost), hostInitParams);
                 s_configRoot = s_configSystem.Root;
                 s_configHost = (WebConfigurationHost) s_configSystem.Host;
                 HttpConfigurationSystem internalConfigSystem = new HttpConfigurationSystem();
                 if (listenToFileChanges)
                 {
                     s_configRoot.ConfigChanged += new InternalConfigEventHandler(internalConfigSystem.OnConfigurationChanged);
                 }
                 s_configSettingsFactory = (IInternalConfigSettingsFactory) Activator.CreateInstance(Type.GetType("System.Configuration.Internal.InternalConfigSettingsFactory, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", true), true);
                 s_configSettingsFactory.SetConfigurationSystem(internalConfigSystem, initComplete);
                 s_httpConfigSystem = internalConfigSystem;
                 s_inited = true;
             }
         }
     }
 }
 internal static void EnsureInit(IConfigMapPath configMapPath, bool listenToFileChanges, bool initComplete)
 {
     if (!s_inited)
     {
         lock (s_initLock)
         {
             if (!s_inited)
             {
                 s_initComplete = initComplete;
                 if (configMapPath == null)
                 {
                     configMapPath = IISMapPath.GetInstance();
                 }
                 s_configMapPath = configMapPath;
                 s_configSystem  = (IConfigSystem)Activator.CreateInstance(Type.GetType("System.Configuration.Internal.ConfigSystem, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", true), true);
                 object[] hostInitParams = new object[6];
                 hostInitParams[0] = true;
                 hostInitParams[1] = s_configMapPath;
                 hostInitParams[3] = HostingEnvironment.ApplicationVirtualPath;
                 hostInitParams[4] = HostingEnvironment.SiteNameNoDemand;
                 hostInitParams[5] = HostingEnvironment.SiteID;
                 s_configSystem.Init(typeof(WebConfigurationHost), hostInitParams);
                 s_configRoot = s_configSystem.Root;
                 s_configHost = (WebConfigurationHost)s_configSystem.Host;
                 HttpConfigurationSystem internalConfigSystem = new HttpConfigurationSystem();
                 if (listenToFileChanges)
                 {
                     s_configRoot.ConfigChanged += new InternalConfigEventHandler(internalConfigSystem.OnConfigurationChanged);
                 }
                 s_configSettingsFactory = (IInternalConfigSettingsFactory)Activator.CreateInstance(Type.GetType("System.Configuration.Internal.InternalConfigSettingsFactory, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", true), true);
                 s_configSettingsFactory.SetConfigurationSystem(internalConfigSystem, initComplete);
                 s_httpConfigSystem = internalConfigSystem;
                 s_inited           = true;
             }
         }
     }
 }
 public virtual void Init(IInternalConfigRoot configRoot, params object[] hostInitParams) {
     Host.Init(configRoot, hostInitParams);
 }
Exemple #37
0
 public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
 {
     base.Init(configRoot, hostInitParams);
 }
	public virtual void InitForConfiguration(System.String& locationSubPathout , System.String& configPathout , System.String& locationConfigPath, IInternalConfigRoot configRoot, object[] hostInitConfigurationParams) {}
		public abstract void Init (IInternalConfigRoot root, params object[] hostInitParams);
		public override void Init (IInternalConfigRoot root, params object[] hostInitParams)
		{
			map = (ConfigurationFileMap) hostInitParams [0];
		}
		public override void Init (IInternalConfigRoot root, params object[] hostInitParams)
		{
			map = (ExeConfigurationFileMap) hostInitParams [0];
			level = (ConfigurationUserLevel) hostInitParams [1];
			CheckFileMap (level, map);
		}
 public virtual void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
 {
     host.Init(configRoot, hostInitParams);
 }
        public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                        IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams) {


            WebLevel                webLevel = (WebLevel)               hostInitConfigurationParams[0];
            ConfigurationFileMap    fileMap = (ConfigurationFileMap)    hostInitConfigurationParams[1];
            VirtualPath             path = VirtualPath.CreateAbsoluteAllowNull((string)hostInitConfigurationParams[2]);
            string                  site = (string)                     hostInitConfigurationParams[3];

            if (locationSubPath == null) {
                locationSubPath = (string)                              hostInitConfigurationParams[4];
            }

            Host.Init(configRoot, hostInitConfigurationParams);

             // Choose the implementation of IConfigMapPath.
            ChooseAndInitConfigMapPath(false, null, fileMap);

            // Get the configuration paths and application information
            GetConfigPaths(_configMapPath, webLevel, path, site, locationSubPath, out _appPath, out _appSiteName, out _appSiteID, out configPath, out locationConfigPath);
            _appConfigPath = GetConfigPathFromSiteIDAndVPath(_appSiteID, _appPath);

            // Verify that the site and path arguments represent a valid name
            // For example, in Cassini app, which is running on \myApp, a page can
            // ask for the config for "\", which can't map to anything.  We want
            // to catch this kind of error.  Another example is if we're given
            // an invalid site id.
            if (IsVirtualPathConfigPath(configPath)) {
                string finalSiteID;
                VirtualPath finalPath;
                GetSiteIDAndVPathFromConfigPath(configPath, out finalSiteID, out finalPath);

                string physicalPath;

                // attempt to use IConfigMapPath2 if provider supports it
                if (null != _configMapPath2) {
                    physicalPath = _configMapPath2.MapPath(finalSiteID, finalPath);
                }
                else {
                    physicalPath = _configMapPath.MapPath(finalSiteID, finalPath.VirtualPathString);
                }

                if (String.IsNullOrEmpty(physicalPath)) {
                    throw new ArgumentOutOfRangeException("site");
                }
            }

#if DBG
            _inited = true;
#endif
        }
 public override void Init(IInternalConfigRoot root, params object[] hostInitParams)
 {
     _map   = (ExeConfigurationFileMap)hostInitParams[0];
     _level = (ConfigurationUserLevel)hostInitParams[1];
     CheckFileMap(_level, _map);
 }
Exemple #45
0
 public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
 {
     map                = (ConfigurationFileMap)hostInitConfigurationParams [0];
     locationSubPath    = null;
     configPath         = null;
     locationConfigPath = null;
 }
            /// <devdoc>
            ///     We delegate this to the ClientConfigurationHost. The only thing we need to do here is to 
            ///     build a configPath from the ConfigurationUserLevel we get passed in.
            /// </devdoc>
            public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath, 
                    IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams) {
    
                ConfigurationUserLevel userLevel = (ConfigurationUserLevel) hostInitConfigurationParams[0];
                string desiredConfigPath = null;
                Host = (IInternalConfigHost) TypeUtil.CreateInstanceWithReflectionPermission(ClientConfigurationHostTypeName);

                switch (userLevel) {
                    case ConfigurationUserLevel.None:
                        desiredConfigPath = ClientHost.GetExeConfigPath();
                        break;
    
                    case ConfigurationUserLevel.PerUserRoaming:
                        desiredConfigPath = ClientHost.GetRoamingUserConfigPath();
                        break;
    
                    case ConfigurationUserLevel.PerUserRoamingAndLocal:
                        desiredConfigPath = ClientHost.GetLocalUserConfigPath();
                        break;
    
                    default: 
                        throw new ArgumentException(SR.GetString(SR.UnknownUserLevel));
                }
    
                
                Host.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, null, null, desiredConfigPath);
            }
        public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
        {
            locationSubPath = null;
            configPath = (string)hostInitConfigurationParams[2];
            locationConfigPath = null;

            Init(configRoot, hostInitConfigurationParams);
        }
        public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
        {
            try
            {
                ConfigurationFileMap fileMap = (ConfigurationFileMap)hostInitParams[0];
                _exePath = (string)hostInitParams[1];

                Host.Init(configRoot, hostInitParams);

                // Do not complete initialization in runtime config, to avoid expense of
                // loading user.config files that may not be required.
                _initComplete = configRoot.IsDesignTime;

                if (fileMap != null && !String.IsNullOrEmpty(_exePath))
                {
                    throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Init");
                }

                if (String.IsNullOrEmpty(_exePath))
                {
                    _exePath = null;
                }

                // Initialize the fileMap, if provided.
                if (fileMap != null)
                {
                    _fileMap = new ExeConfigurationFileMap();
                    if (!String.IsNullOrEmpty(fileMap.MachineConfigFilename))
                    {
                        _fileMap.MachineConfigFilename = Path.GetFullPath(fileMap.MachineConfigFilename);
                    }

                    ExeConfigurationFileMap exeFileMap = fileMap as ExeConfigurationFileMap;
                    if (exeFileMap != null)
                    {
                        if (!String.IsNullOrEmpty(exeFileMap.ExeConfigFilename))
                        {
                            _fileMap.ExeConfigFilename = Path.GetFullPath(exeFileMap.ExeConfigFilename);
                        }

                        if (!String.IsNullOrEmpty(exeFileMap.RoamingUserConfigFilename))
                        {
                            _fileMap.RoamingUserConfigFilename = Path.GetFullPath(exeFileMap.RoamingUserConfigFilename);
                        }

                        if (!String.IsNullOrEmpty(exeFileMap.LocalUserConfigFilename))
                        {
                            _fileMap.LocalUserConfigFilename = Path.GetFullPath(exeFileMap.LocalUserConfigFilename);
                        }
                    }
                }
            }
            catch
            {
                throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::Init");
            }
        }
 void IInternalConfigHost.Init(IInternalConfigRoot configRoot, params object[] hostInitParams) {
     _configRoot = configRoot;
 }
Exemple #50
0
 void IInternalConfigHost.Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
 {
 }
Exemple #51
0
		public virtual void InitForConfiguration (ref string locationSubPath, out string configPath,
							  out string locationConfigPath, IInternalConfigRoot root,
							  params object[] hostInitConfigurationParams)
		{
			string fullPath = (string) hostInitConfigurationParams [1];
			map = (WebConfigurationFileMap) hostInitConfigurationParams [0];
			bool inAnotherApp = (bool) hostInitConfigurationParams [7];

			if (inAnotherApp)
				appVirtualPath = fullPath;
			else
				appVirtualPath = HttpRuntime.AppDomainAppVirtualPath;
			
			if (locationSubPath == MachineWebPath) {
				locationSubPath = MachinePath;
				configPath = MachineWebPath;
				locationConfigPath = null;
			} else if (locationSubPath == MachinePath) {
				locationSubPath = null;
				configPath = MachinePath;
				locationConfigPath = null;
			} else {
				int i;
				if (locationSubPath == null) {
					configPath = fullPath;
					if (configPath.Length > 1)
						configPath = VirtualPathUtility.RemoveTrailingSlash (configPath);
				} else
					configPath = locationSubPath;
				
				if (configPath == HttpRuntime.AppDomainAppVirtualPath || configPath == "/")
					i = -1;
				else
					i = configPath.LastIndexOf ("/");

				if (i != -1) {
					locationConfigPath = configPath.Substring (i+1);
					
					if (i == 0)
						locationSubPath = "/";
					else
						locationSubPath = fullPath.Substring (0, i);
				} else {
					locationSubPath = MachineWebPath;
					locationConfigPath = null;
				}
			}
		}
 public abstract void Init(IInternalConfigRoot root, params object[] hostInitParams);
        public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams) {
            bool                    useConfigMapPath = (bool)           hostInitParams[0];
            IConfigMapPath          configMapPath = (IConfigMapPath)    hostInitParams[1];
            ConfigurationFileMap    fileMap = (ConfigurationFileMap)    hostInitParams[2];
            string                  appPath = (string)                  hostInitParams[3];
            string                  appSiteName = (string)              hostInitParams[4];
            string                  appSiteID = (string)                hostInitParams[5];

            if (hostInitParams.Length > 6) {
                // If VS sent a 7th param, it is the .Net Framwework Target version moniker
                string fxMoniker = hostInitParams[6] as string;
                _machineConfigFile = GetMachineConfigPathFromTargetFrameworkMoniker(fxMoniker);
                if (!string.IsNullOrEmpty(_machineConfigFile)) {
                    _rootWebConfigFile = Path.Combine(Path.GetDirectoryName(_machineConfigFile), "web.config");
                }
            }

            Debug.Assert(configMapPath == null || useConfigMapPath, "non-null configMapPath without useConfigMapPath == true");

            Host.Init(configRoot, hostInitParams);

            ChooseAndInitConfigMapPath(useConfigMapPath, configMapPath, fileMap);

            appPath = UrlPath.RemoveSlashFromPathIfNeeded(appPath);
            _appPath = VirtualPath.CreateAbsoluteAllowNull(appPath);
            _appSiteName = appSiteName;
            _appSiteID = appSiteID;

            if (!String.IsNullOrEmpty(_appSiteID) && _appPath != null) {
                _appConfigPath = GetConfigPathFromSiteIDAndVPath(_appSiteID, _appPath);
            }

#if DBG
            _inited = true;
#endif
        }
 public abstract void InitForConfiguration(ref string locationSubPath, out string configPath,
                                           out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams);
		public override void InitForConfiguration (ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
		{
			map = (ExeConfigurationFileMap) hostInitConfigurationParams [0];

			if (hostInitConfigurationParams.Length > 1 && 
			    hostInitConfigurationParams [1] is ConfigurationUserLevel)
				level = (ConfigurationUserLevel) hostInitConfigurationParams [1];

			CheckFileMap (level, map);

			if (locationSubPath == null)
				switch (level) {
				case ConfigurationUserLevel.PerUserRoaming:
					if (map.RoamingUserConfigFilename == null)
						throw new ArgumentException ("RoamingUserConfigFilename must be set correctly");
					locationSubPath = "roaming";
					break;
				case ConfigurationUserLevel.PerUserRoamingAndLocal:
					if (map.LocalUserConfigFilename == null)
						throw new ArgumentException ("LocalUserConfigFilename must be set correctly");
					locationSubPath = "local";
					break;
				}

			configPath = null;
			string next = null;

			locationConfigPath = null;

			if (locationSubPath == "exe" || locationSubPath == null && map.ExeConfigFilename != null) {
				configPath = "exe";
				next = "machine";
				locationConfigPath = map.ExeConfigFilename;
			}
			
			if (locationSubPath == "local" && map.LocalUserConfigFilename != null) {
				configPath = "local";
				next = "roaming";
				locationConfigPath = map.LocalUserConfigFilename;
			}
			
			if (locationSubPath == "roaming" && map.RoamingUserConfigFilename != null) {
				configPath = "roaming";
				next = "exe";
				locationConfigPath = map.RoamingUserConfigFilename;
			}
			
			if ((locationSubPath == "machine" || configPath == null) && map.MachineConfigFilename != null) {
				configPath = "machine";
				next = null;
			}
			locationSubPath = next;
		}
	public virtual void Init(IInternalConfigRoot configRoot, object[] hostInitParams) {}
		public override void InitForConfiguration (ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
		{
			map = (ConfigurationFileMap) hostInitConfigurationParams [0];
			locationSubPath = null;
			configPath = null;
			locationConfigPath = null;
		}
 public override void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
 {
     // Stash the filemap so we can see if the machine config was explicitly specified
     _fileMap = hostInitParams[0] as ConfigurationFileMap;
     base.Init(configRoot, hostInitParams);
 }
		public abstract void InitForConfiguration (ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams);
Exemple #60
0
 public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
     IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
 {
     base.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, hostInitConfigurationParams);
 }