Example #1
0
        // Mostly borrowed from IsolatedStorage, with some modifications
        private static object GetEvidenceInfo(AppDomain appDomain, string exePath, out string typeName)
        {
            ControlEvidencePermission.Assert();
            Evidence   evidence = appDomain.Evidence;
            StrongName sn       = null;
            Url        url      = null;

            if (evidence != null)
            {
                IEnumerator e    = evidence.GetHostEnumerator();
                object      temp = null;

                while (e.MoveNext())
                {
                    temp = e.Current;

                    if (temp is StrongName)
                    {
                        sn = (StrongName)temp;
                        break;
                    }
                    else if (temp is Url)
                    {
                        url = (Url)temp;
                    }
                }
            }

            object o = null;

            // The order of preference is StrongName, Url, ExePath.
            if (sn != null)
            {
                o        = MakeVersionIndependent(sn);
                typeName = StrongNameDesc;
            }
            else if (url != null)
            {
                // Extract the url string and normalize it to use as evidence
                o        = url.Value.ToUpperInvariant();
                typeName = UrlDesc;
            }
            else if (exePath != null)
            {
                o        = exePath;
                typeName = PathDesc;
            }
            else
            {
                typeName = null;
            }

            return(o);
        }
        private static object GetEvidenceInfo(AppDomain appDomain, string exePath, out string typeName)
        {
            ControlEvidencePermission.Assert();
            Evidence   evidence = appDomain.Evidence;
            StrongName sn       = null;
            Url        url      = null;

            if (evidence != null)
            {
                IEnumerator hostEnumerator = evidence.GetHostEnumerator();
                object      current        = null;
                while (hostEnumerator.MoveNext())
                {
                    current = hostEnumerator.Current;
                    if (current is StrongName)
                    {
                        sn = (StrongName)current;
                        break;
                    }
                    if (current is Url)
                    {
                        url = (Url)current;
                    }
                }
            }
            object obj3 = null;

            if (sn != null)
            {
                obj3     = MakeVersionIndependent(sn);
                typeName = "StrongName";
                return(obj3);
            }
            if (url != null)
            {
                obj3     = url.Value.ToUpperInvariant();
                typeName = "Url";
                return(obj3);
            }
            if (exePath != null)
            {
                obj3     = exePath;
                typeName = "Path";
                return(obj3);
            }
            typeName = null;
            return(obj3);
        }