private static System.Configuration.Configuration OpenWebConfigurationImpl(WebLevel webLevel, ConfigurationFileMap fileMap, string path, string site, string locationSubPath, string server, string userName, string password, IntPtr userToken)
        {
            VirtualPath path2;

            if (HostingEnvironment.IsHosted)
            {
                path2 = VirtualPath.CreateNonRelativeAllowNull(path);
            }
            else
            {
                path2 = VirtualPath.CreateAbsoluteAllowNull(path);
            }
            return(WebConfigurationHost.OpenConfiguration(webLevel, fileMap, path2, site, locationSubPath, server, userName, password, userToken));
        }
Beispiel #2
0
        public string GetFilePaths(int webLevelAsInt, string path, string site, string locationSubPath)
        {
            string         str;
            string         str2;
            VirtualPath    path3;
            string         str3;
            string         str4;
            string         str5;
            VirtualPath    path4;
            WebLevel       webLevel = (WebLevel)webLevelAsInt;
            IConfigMapPath instance = IISMapPath.GetInstance();

            WebConfigurationHost.GetConfigPaths(instance, webLevel, VirtualPath.CreateNonRelativeAllowNull(path), site, locationSubPath, out path3, out str, out str2, out str3, out str4);
            ArrayList list = new ArrayList();

            list.Add(VirtualPath.GetVirtualPathString(path3));
            list.Add(str);
            list.Add(str2);
            list.Add(str3);
            list.Add(str4);
            WebConfigurationHost.GetSiteIDAndVPathFromConfigPath(str3, out str5, out path4);
            list.Add("machine");
            list.Add(HttpConfigurationSystem.MachineConfigurationFilePath);
            if (webLevel != WebLevel.Machine)
            {
                list.Add("machine/webroot");
                list.Add(HttpConfigurationSystem.RootWebConfigurationFilePath);
                for (VirtualPath path5 = path4; path5 != null; path5 = path5.Parent)
                {
                    string configPathFromSiteIDAndVPath = WebConfigurationHost.GetConfigPathFromSiteIDAndVPath(str2, path5);
                    string str7 = Path.Combine(instance.MapPath(str2, path5.VirtualPathString), "web.config");
                    list.Add(configPathFromSiteIDAndVPath);
                    list.Add(str7);
                }
            }
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < list.Count; i++)
            {
                if (i > 0)
                {
                    builder.Append('<');
                }
                string str8 = (string)list[i];
                builder.Append(str8);
            }
            return(builder.ToString());
        }
Beispiel #3
0
        //
        // *************************************************
        // ** Static Management Functions to edit config **
        // *************************************************
        //

        private static Configuration OpenWebConfigurationImpl(
            WebLevel webLevel, ConfigurationFileMap fileMap, string path, string site, string locationSubPath,
            string server, string userName, string password, IntPtr userToken)
        {
            // In the hosted case, we allow app relative (~/....).  Otherwise, it must be absolute
            VirtualPath virtualPath;

            if (HostingEnvironment.IsHosted)
            {
                virtualPath = VirtualPath.CreateNonRelativeAllowNull(path);
            }
            else
            {
                virtualPath = VirtualPath.CreateAbsoluteAllowNull(path);
            }

            return(WebConfigurationHost.OpenConfiguration(webLevel, fileMap, virtualPath, site, locationSubPath,
                                                          server, userName, password, userToken));
        }
 internal static object GetSection(string sectionName, string path)
 {
     return(GetSection(sectionName, VirtualPath.CreateNonRelativeAllowNull(path)));
 }
 internal static RuntimeConfig GetConfig(string path)
 {
     return GetConfig(VirtualPath.CreateNonRelativeAllowNull(path));
 }
Beispiel #6
0
        public string GetFilePaths(int webLevelAsInt, string path, string site, string locationSubPath)
        {
            WebLevel webLevel = (WebLevel)webLevelAsInt;

            IConfigMapPath configMapPath = IISMapPath.GetInstance();

            // Get the configuration paths and application information
            string      appSiteName, appSiteID;
            VirtualPath appPath;
            string      configPath, locationConfigPath;

            WebConfigurationHost.GetConfigPaths(configMapPath, webLevel, VirtualPath.CreateNonRelativeAllowNull(path), site, locationSubPath,
                                                out appPath, out appSiteName, out appSiteID, out configPath, out locationConfigPath);

            //
            // Format of filePaths:
            //      appPath < appSiteName < appSiteID < configPath < locationConfigPath [< configPath < fileName]+
            //
            ArrayList filePaths = new ArrayList();

            filePaths.Add(VirtualPath.GetVirtualPathString(appPath));
            filePaths.Add(appSiteName);
            filePaths.Add(appSiteID);
            filePaths.Add(configPath);
            filePaths.Add(locationConfigPath);

            string      dummySiteID;
            VirtualPath virtualPath;

            WebConfigurationHost.GetSiteIDAndVPathFromConfigPath(configPath, out dummySiteID, out virtualPath);

            // pathmap for machine.config
            filePaths.Add(WebConfigurationHost.MachineConfigPath);
            filePaths.Add(HttpConfigurationSystem.MachineConfigurationFilePath);

            // pathmap for root web.config
            if (webLevel != WebLevel.Machine)
            {
                filePaths.Add(WebConfigurationHost.RootWebConfigPath);
                filePaths.Add(HttpConfigurationSystem.RootWebConfigurationFilePath);

                // pathmap for other paths
                for (VirtualPath currentVirtualPath = virtualPath; currentVirtualPath != null; currentVirtualPath = currentVirtualPath.Parent)
                {
                    string currentConfigPath = WebConfigurationHost.GetConfigPathFromSiteIDAndVPath(appSiteID, currentVirtualPath);
                    string currentFilePath   = configMapPath.MapPath(appSiteID, currentVirtualPath.VirtualPathString);
                    currentFilePath = System.IO.Path.Combine(currentFilePath, HttpConfigurationSystem.WebConfigFileName);

                    filePaths.Add(currentConfigPath);
                    filePaths.Add(currentFilePath);
                }
            }

            // join into a single string
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < filePaths.Count; i++)
            {
                if (i > 0)
                {
                    sb.Append(FilePathsSeparatorChar);
                }

                string part = (string)filePaths[i];
                sb.Append(part);
            }

            return(sb.ToString());
        }
 private static S GetConfig <S>(string vpath) where S : ConfigurationSection
 {
     return(GetConfig <S>(VirtualPath.CreateNonRelativeAllowNull(vpath)));
 }
        private static IDictionary DeserializeData(byte[] data)
        {
            IDictionary dictionary = null;

            if ((data != null) && (data.Length > 0))
            {
                Exception innerException = null;
                int       num            = -1;
                object[]  objArray       = null;
                int       num2           = 0;
                try
                {
                    ObjectStateFormatter formatter = new ObjectStateFormatter(null, false);
                    if ((!HttpRuntime.DisableProcessRequestInApplicationTrust && (HttpRuntime.NamedPermissionSet != null)) && HttpRuntime.ProcessRequestInApplicationTrust)
                    {
                        HttpRuntime.NamedPermissionSet.PermitOnly();
                    }
                    objArray = (object[])formatter.DeserializeWithAssert(new MemoryStream(data));
                    if ((objArray != null) && (objArray.Length != 0))
                    {
                        num = (int)objArray[num2++];
                    }
                }
                catch (Exception exception2)
                {
                    innerException = exception2;
                }
                switch (num)
                {
                case 1:
                case 2:
                    try
                    {
                        int initialSize = (int)objArray[num2++];
                        if (initialSize > 0)
                        {
                            dictionary = new HybridDictionary(initialSize, false);
                        }
                        for (int i = 0; i < initialSize; i++)
                        {
                            string      str;
                            bool        flag;
                            Type        type = null;
                            VirtualPath path = null;
                            object      obj2 = objArray[num2++];
                            if (obj2 is string)
                            {
                                str  = (string)obj2;
                                flag = false;
                            }
                            else
                            {
                                type = (Type)obj2;
                                if (type == typeof(UserControl))
                                {
                                    path = VirtualPath.CreateNonRelativeAllowNull((string)objArray[num2++]);
                                }
                                str  = (string)objArray[num2++];
                                flag = true;
                            }
                            IDictionary dictionary2 = null;
                            int         num5        = (int)objArray[num2++];
                            if (num5 > 0)
                            {
                                dictionary2 = new HybridDictionary(num5, false);
                                for (int j = 0; j < num5; j++)
                                {
                                    string str2 = ((IndexedString)objArray[num2++]).Value;
                                    object obj3 = objArray[num2++];
                                    dictionary2[str2] = obj3;
                                }
                            }
                            PersonalizationDictionary dictionary3 = null;
                            int num7 = (int)objArray[num2++];
                            if (num7 > 0)
                            {
                                dictionary3 = new PersonalizationDictionary(num7);
                                for (int k = 0; k < num7; k++)
                                {
                                    string str3 = ((IndexedString)objArray[num2++]).Value;
                                    object obj4 = objArray[num2++];
                                    System.Web.UI.WebControls.WebParts.PersonalizationScope scope = ((bool)objArray[num2++]) ? System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared : System.Web.UI.WebControls.WebParts.PersonalizationScope.User;
                                    bool isSensitive = false;
                                    if (num == 2)
                                    {
                                        isSensitive = (bool)objArray[num2++];
                                    }
                                    dictionary3[str3] = new PersonalizationEntry(obj4, scope, isSensitive);
                                }
                            }
                            PersonalizationInfo info = new PersonalizationInfo {
                                _controlID        = str,
                                _controlType      = type,
                                _controlVPath     = path,
                                _isStatic         = flag,
                                _properties       = dictionary2,
                                _customProperties = dictionary3
                            };
                            dictionary[str] = info;
                        }
                    }
                    catch (Exception exception3)
                    {
                        innerException = exception3;
                    }
                    break;
                }
                if ((innerException != null) || ((num != 1) && (num != 2)))
                {
                    throw new ArgumentException(System.Web.SR.GetString("BlobPersonalizationState_DeserializeError"), "data", innerException);
                }
            }
            if (dictionary == null)
            {
                dictionary = new HybridDictionary(false);
            }
            return(dictionary);
        }