private Stream CaseInsensitiveManifestResourceStreamLookup(RuntimeAssembly satellite, string name)
 {
     StringBuilder builder = new StringBuilder();
     if (this._mediator.LocationInfo != null)
     {
         string str = this._mediator.LocationInfo.Namespace;
         if (str != null)
         {
             builder.Append(str);
             if (name != null)
             {
                 builder.Append(Type.Delimiter);
             }
         }
     }
     builder.Append(name);
     string str2 = builder.ToString();
     CompareInfo compareInfo = CultureInfo.InvariantCulture.CompareInfo;
     string str3 = null;
     foreach (string str4 in satellite.GetManifestResourceNames())
     {
         if (compareInfo.Compare(str4, str2, CompareOptions.IgnoreCase) == 0)
         {
             if (str3 != null)
             {
                 throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_MultipleBlobs", new object[] { str2, satellite.ToString() }));
             }
             str3 = str4;
         }
     }
     if (FrameworkEventSource.IsInitialized)
     {
         if (str3 != null)
         {
             FrameworkEventSource.Log.ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(this._mediator.BaseName, this._mediator.MainAssembly, satellite.GetSimpleName(), str2);
         }
         else
         {
             FrameworkEventSource.Log.ResourceManagerCaseInsensitiveResourceStreamLookupFailed(this._mediator.BaseName, this._mediator.MainAssembly, satellite.GetSimpleName(), str2);
         }
     }
     if (str3 == null)
     {
         return null;
     }
     bool skipSecurityCheck = (this._mediator.MainAssembly == satellite) && (this._mediator.CallingAssembly == this._mediator.MainAssembly);
     StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;
     Stream stream = satellite.GetManifestResourceStream(str3, ref lookForMyCaller, skipSecurityCheck);
     if ((stream != null) && FrameworkEventSource.IsInitialized)
     {
         FrameworkEventSource.Log.ResourceManagerManifestResourceAccessDenied(this._mediator.BaseName, this._mediator.MainAssembly, satellite.GetSimpleName(), str3);
     }
     return stream;
 }
 private Stream GetManifestResourceStream(RuntimeAssembly satellite, string fileName, ref StackCrawlMark stackMark)
 {
     bool skipSecurityCheck = (this._mediator.MainAssembly == satellite) && (this._mediator.CallingAssembly == this._mediator.MainAssembly);
     Stream stream = satellite.GetManifestResourceStream(this._mediator.LocationInfo, fileName, skipSecurityCheck, ref stackMark);
     if (stream == null)
     {
         stream = this.CaseInsensitiveManifestResourceStreamLookup(satellite, fileName);
     }
     return stream;
 }
        private Stream GetManifestResourceStream(RuntimeAssembly satellite, String fileName, ref StackCrawlMark stackMark)
        {
            Contract.Requires(satellite != null, "satellite shouldn't be null; check caller");
            Contract.Requires(fileName != null, "fileName shouldn't be null; check caller");

            // If we're looking in the main assembly AND if the main assembly was the person who
            // created the ResourceManager, skip a security check for private manifest resources.
            bool canSkipSecurityCheck = (_mediator.MainAssembly == satellite)
                                        && (_mediator.CallingAssembly == _mediator.MainAssembly);

            Stream stream = satellite.GetManifestResourceStream(_mediator.LocationInfo, fileName, canSkipSecurityCheck, ref stackMark);
            if (stream == null)
            {
                stream = CaseInsensitiveManifestResourceStreamLookup(satellite, fileName);
            }

            return stream;
        }
        [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var have to be marked non-inlineable
        private Stream CaseInsensitiveManifestResourceStreamLookup(RuntimeAssembly satellite, String name)
        {
            Contract.Requires(satellite != null, "satellite shouldn't be null; check caller");
            Contract.Requires(name != null, "name shouldn't be null; check caller");

            StringBuilder sb = new StringBuilder();
            if (_mediator.LocationInfo != null)
            {
                String nameSpace = _mediator.LocationInfo.Namespace;
                if (nameSpace != null)
                {
                    sb.Append(nameSpace);
                    if (name != null)
                        sb.Append(Type.Delimiter);
                }
            }
            sb.Append(name);

            String givenName = sb.ToString();
            CompareInfo comparer = CultureInfo.InvariantCulture.CompareInfo;
            String canonicalName = null;
            foreach (String existingName in satellite.GetManifestResourceNames())
            {
                if (comparer.Compare(existingName, givenName, CompareOptions.IgnoreCase) == 0)
                {
                    if (canonicalName == null)
                    {
                        canonicalName = existingName;
                    }
                    else
                    {
                        throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_MultipleBlobs", givenName, satellite.ToString()));
                    }
                }
            }

#if !FEATURE_CORECLR && !MONO
            if (FrameworkEventSource.IsInitialized)
            {
                if (canonicalName != null)
                {
                    FrameworkEventSource.Log.ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(_mediator.BaseName, _mediator.MainAssembly, satellite.GetSimpleName(), givenName);
                }
                else
                {
                    FrameworkEventSource.Log.ResourceManagerCaseInsensitiveResourceStreamLookupFailed(_mediator.BaseName, _mediator.MainAssembly, satellite.GetSimpleName(), givenName);
                }
            }
#endif

            if (canonicalName == null)
            {
                return null;
            }
            // If we're looking in the main assembly AND if the main
            // assembly was the person who created the ResourceManager,
            // skip a security check for private manifest resources.
            bool canSkipSecurityCheck = _mediator.MainAssembly == satellite && _mediator.CallingAssembly == _mediator.MainAssembly;
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
            Stream s = satellite.GetManifestResourceStream(canonicalName, ref stackMark, canSkipSecurityCheck);
            // GetManifestResourceStream will return null if we don't have 
            // permission to read this stream from the assembly.  For example,
            // if the stream is private and we're trying to access it from another
            // assembly (ie, ResMgr in mscorlib accessing anything else), we 
            // require Reflection TypeInformation permission to be able to read 
            // this.  <




#if !FEATURE_CORECLR && !MONO
            if (s!=null) {
                if (FrameworkEventSource.IsInitialized)
                {
                    FrameworkEventSource.Log.ResourceManagerManifestResourceAccessDenied(_mediator.BaseName, _mediator.MainAssembly, satellite.GetSimpleName(), canonicalName);
                }
            }
#endif
            return s;
        }
        [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var have to be marked non-inlineable
        private Stream CaseInsensitiveManifestResourceStreamLookup(RuntimeAssembly satellite, String name)
        {
            Contract.Requires(satellite != null, "satellite shouldn't be null; check caller");
            Contract.Requires(name != null, "name shouldn't be null; check caller");

            StringBuilder sb = new StringBuilder();
            if (_mediator.LocationInfo != null)
            {
                String nameSpace = _mediator.LocationInfo.Namespace;
                if (nameSpace != null)
                {
                    sb.Append(nameSpace);
                    if (name != null)
                        sb.Append(Type.Delimiter);
                }
            }
            sb.Append(name);

            String givenName = sb.ToString();
            CompareInfo comparer = CultureInfo.InvariantCulture.CompareInfo;
            String canonicalName = null;
            foreach (String existingName in satellite.GetManifestResourceNames())
            {
                if (comparer.Compare(existingName, givenName, CompareOptions.IgnoreCase) == 0)
                {
                    if (canonicalName == null)
                    {
                        canonicalName = existingName;
                    }
                    else
                    {
                        throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_MultipleBlobs", givenName, satellite.ToString()));
                    }
                }
            }

            if (canonicalName == null)
            {
                return null;
            }

            // If we're looking in the main assembly AND if the main
            // assembly was the person who created the ResourceManager,
            // skip a security check for private manifest resources.
            bool canSkipSecurityCheck = _mediator.MainAssembly == satellite && _mediator.CallingAssembly == _mediator.MainAssembly;
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
            return satellite.GetManifestResourceStream(canonicalName, ref stackMark, canSkipSecurityCheck);
        }