static StateRuntime()
 {
     WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
     UserMapPath configMapPath = new UserMapPath(fileMap);
     HttpConfigurationSystem.EnsureInit(configMapPath, false, true);
     StateApplication customApplication = new StateApplication();
     HttpApplicationFactory.SetCustomApplication(customApplication);
     PerfCounters.OpenStateCounters();
     ResetStateServerCounters();
 }
 public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
 {
     string str6;
     WebLevel level = (WebLevel) hostInitConfigurationParams[0];
     string str = (string) hostInitConfigurationParams[2];
     string site = (string) hostInitConfigurationParams[3];
     if (locationSubPath == null)
     {
         locationSubPath = (string) hostInitConfigurationParams[4];
     }
     string str3 = (string) hostInitConfigurationParams[5];
     string fullUserName = (string) hostInitConfigurationParams[6];
     string password = (string) hostInitConfigurationParams[7];
     IntPtr userToken = (IntPtr) hostInitConfigurationParams[8];
     configPath = null;
     locationConfigPath = null;
     this._Server = str3;
     this._Username = GetUserNameFromFullName(fullUserName);
     this._Domain = GetDomainFromFullName(fullUserName);
     this._Password = password;
     this._Identity = (userToken == IntPtr.Zero) ? null : new WindowsIdentity(userToken);
     this._PathMap = new Hashtable(StringComparer.OrdinalIgnoreCase);
     try
     {
         WindowsImpersonationContext context = (this._Identity != null) ? this._Identity.Impersonate() : null;
         try
         {
             IRemoteWebConfigurationHostServer o = CreateRemoteObject(str3, this._Username, this._Domain, password);
             try
             {
                 str6 = o.GetFilePaths((int) level, str, site, locationSubPath);
             }
             finally
             {
                 while (Marshal.ReleaseComObject(o) > 0)
                 {
                 }
             }
         }
         finally
         {
             if (context != null)
             {
                 context.Undo();
             }
         }
     }
     catch
     {
         throw;
     }
     if (str6 == null)
     {
         throw System.Web.Util.ExceptionUtil.UnexpectedError("RemoteWebConfigurationHost::InitForConfiguration");
     }
     string[] strArray = str6.Split(RemoteWebConfigurationHostServer.FilePathsSeparatorParams);
     if ((strArray.Length < 7) || (((strArray.Length - 5) % 2) != 0))
     {
         throw System.Web.Util.ExceptionUtil.UnexpectedError("RemoteWebConfigurationHost::InitForConfiguration");
     }
     for (int i = 0; i < strArray.Length; i++)
     {
         if (strArray[i].Length == 0)
         {
             strArray[i] = null;
         }
     }
     string virtualPath = strArray[0];
     string str8 = strArray[1];
     string str9 = strArray[2];
     configPath = strArray[3];
     locationConfigPath = strArray[4];
     this._ConfigPath = configPath;
     WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
     VirtualPath path = VirtualPath.CreateAbsoluteAllowNull(virtualPath);
     fileMap.Site = str9;
     for (int j = 5; j < strArray.Length; j += 2)
     {
         string key = strArray[j];
         string str11 = strArray[j + 1];
         this._PathMap.Add(key, str11);
         if (WebConfigurationHost.IsMachineConfigPath(key))
         {
             fileMap.MachineConfigFilename = str11;
         }
         else
         {
             string virtualPathString;
             bool flag;
             if (WebConfigurationHost.IsRootWebConfigPath(key))
             {
                 virtualPathString = null;
                 flag = false;
             }
             else
             {
                 VirtualPath path2;
                 string str13;
                 WebConfigurationHost.GetSiteIDAndVPathFromConfigPath(key, out str13, out path2);
                 virtualPathString = VirtualPath.GetVirtualPathString(path2);
                 flag = path2 == path;
             }
             fileMap.VirtualDirectories.Add(virtualPathString, new VirtualDirectoryMapping(Path.GetDirectoryName(str11), flag));
         }
     }
     WebConfigurationHost host = new WebConfigurationHost();
     object[] hostInitParams = new object[6];
     hostInitParams[0] = true;
     hostInitParams[1] = new UserMapPath(fileMap, false);
     hostInitParams[3] = virtualPath;
     hostInitParams[4] = str8;
     hostInitParams[5] = str9;
     host.Init(root, hostInitParams);
     base.Host = host;
 }
示例#3
0
        public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
        {
            string   str6;
            WebLevel level = (WebLevel)hostInitConfigurationParams[0];
            string   str   = (string)hostInitConfigurationParams[2];
            string   site  = (string)hostInitConfigurationParams[3];

            if (locationSubPath == null)
            {
                locationSubPath = (string)hostInitConfigurationParams[4];
            }
            string str3         = (string)hostInitConfigurationParams[5];
            string fullUserName = (string)hostInitConfigurationParams[6];
            string password     = (string)hostInitConfigurationParams[7];
            IntPtr userToken    = (IntPtr)hostInitConfigurationParams[8];

            configPath         = null;
            locationConfigPath = null;
            this._Server       = str3;
            this._Username     = GetUserNameFromFullName(fullUserName);
            this._Domain       = GetDomainFromFullName(fullUserName);
            this._Password     = password;
            this._Identity     = (userToken == IntPtr.Zero) ? null : new WindowsIdentity(userToken);
            this._PathMap      = new Hashtable(StringComparer.OrdinalIgnoreCase);
            try
            {
                WindowsImpersonationContext context = (this._Identity != null) ? this._Identity.Impersonate() : null;
                try
                {
                    IRemoteWebConfigurationHostServer o = CreateRemoteObject(str3, this._Username, this._Domain, password);
                    try
                    {
                        str6 = o.GetFilePaths((int)level, str, site, locationSubPath);
                    }
                    finally
                    {
                        while (Marshal.ReleaseComObject(o) > 0)
                        {
                        }
                    }
                }
                finally
                {
                    if (context != null)
                    {
                        context.Undo();
                    }
                }
            }
            catch
            {
                throw;
            }
            if (str6 == null)
            {
                throw System.Web.Util.ExceptionUtil.UnexpectedError("RemoteWebConfigurationHost::InitForConfiguration");
            }
            string[] strArray = str6.Split(RemoteWebConfigurationHostServer.FilePathsSeparatorParams);
            if ((strArray.Length < 7) || (((strArray.Length - 5) % 2) != 0))
            {
                throw System.Web.Util.ExceptionUtil.UnexpectedError("RemoteWebConfigurationHost::InitForConfiguration");
            }
            for (int i = 0; i < strArray.Length; i++)
            {
                if (strArray[i].Length == 0)
                {
                    strArray[i] = null;
                }
            }
            string virtualPath = strArray[0];
            string str8        = strArray[1];
            string str9        = strArray[2];

            configPath         = strArray[3];
            locationConfigPath = strArray[4];
            this._ConfigPath   = configPath;
            WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
            VirtualPath             path    = VirtualPath.CreateAbsoluteAllowNull(virtualPath);

            fileMap.Site = str9;
            for (int j = 5; j < strArray.Length; j += 2)
            {
                string key   = strArray[j];
                string str11 = strArray[j + 1];
                this._PathMap.Add(key, str11);
                if (WebConfigurationHost.IsMachineConfigPath(key))
                {
                    fileMap.MachineConfigFilename = str11;
                }
                else
                {
                    string virtualPathString;
                    bool   flag;
                    if (WebConfigurationHost.IsRootWebConfigPath(key))
                    {
                        virtualPathString = null;
                        flag = false;
                    }
                    else
                    {
                        VirtualPath path2;
                        string      str13;
                        WebConfigurationHost.GetSiteIDAndVPathFromConfigPath(key, out str13, out path2);
                        virtualPathString = VirtualPath.GetVirtualPathString(path2);
                        flag = path2 == path;
                    }
                    fileMap.VirtualDirectories.Add(virtualPathString, new VirtualDirectoryMapping(Path.GetDirectoryName(str11), flag));
                }
            }
            WebConfigurationHost host = new WebConfigurationHost();

            object[] hostInitParams = new object[6];
            hostInitParams[0] = true;
            hostInitParams[1] = new UserMapPath(fileMap, false);
            hostInitParams[3] = virtualPath;
            hostInitParams[4] = str8;
            hostInitParams[5] = str9;
            host.Init(root, hostInitParams);
            base.Host = host;
        }