System.Security.Policy.ApplicationSecurityManager.DecodeAppTrustManager C# (CSharp) Method

DecodeAppTrustManager() private method

private DecodeAppTrustManager ( ) : IApplicationTrustManager
return IApplicationTrustManager
        private static IApplicationTrustManager DecodeAppTrustManager () {
            if (!File.InternalExists(s_machineConfigFile))
                goto defaultTrustManager;

            // A config file exists. Decode the trust manager from its Xml.
            FileStream contents = new FileStream(s_machineConfigFile, FileMode.Open, FileAccess.Read);

            SecurityElement elRoot = SecurityElement.FromString(new StreamReader(contents).ReadToEnd());
            SecurityElement elMscorlib = elRoot.SearchForChildByTag("mscorlib");
            if (elMscorlib == null)
                goto defaultTrustManager;
            SecurityElement elSecurity = elMscorlib.SearchForChildByTag("security");
            if (elSecurity == null)
                goto defaultTrustManager;
            SecurityElement elPolicy = elSecurity.SearchForChildByTag("policy");
            if (elPolicy == null)
                goto defaultTrustManager;
            SecurityElement elSecurityManager = elPolicy.SearchForChildByTag("ApplicationSecurityManager");
            if (elSecurityManager == null)
                goto defaultTrustManager;
            SecurityElement elTrustManager = elSecurityManager.SearchForChildByTag("IApplicationTrustManager");
            if (elTrustManager == null)
                goto defaultTrustManager;
            IApplicationTrustManager appTrustManager = DecodeAppTrustManagerFromElement(elTrustManager);
            if (appTrustManager == null)
                goto defaultTrustManager;
            return appTrustManager;

defaultTrustManager:
            return DecodeAppTrustManagerFromElement(CreateDefaultApplicationTrustManagerElement());
        }