Exemple #1
0
        /// <summary>
        /// Ouput the image resource specified by its assembly's name and resource's name
        /// to the current <see cref="IResponse"/>.<see cref="IResponse.OutputStream"/>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The following HTTP Headers are set :
        /// </para>
        /// <list type="table">
        ///		<item>
        ///			<term>content-disposition</term>
        ///			<description>filename=[resourceName]</description>
        ///		</item>
        ///		<item>
        ///			<term>content-length</term>
        ///			<description>The resource's bytes length.</description>
        ///		</item>
        ///		<item>
        ///			<term>content-type</term>
        ///			<description>The <paramref name="mimeType"/> value</description>
        ///		</item>
        /// </list>
        /// </remarks>
        /// <param name="assemblyName">The name of the image's resource assembly.</param>
        /// <param name="resourceName">The name of the image's resource.</param>
        /// <param name="mimeType">The MIME-TYPE to use.</param>
        public void GetImageWithMIME(string assemblyName, string resourceName, string mimeType)
        {
            CancelLayout();
            CancelView();

            Assembly assemblyFound = null;

            if (assemblyName == null || assemblyName.Length == 0)
            {
                assemblyName = _ResourceHelper.GetAssemblyNameFromResourceName(resourceName);

                // Try to find the assembly from its name
                try
                {
                    assemblyFound = Assembly.Load(assemblyName);
                }
                catch { }

                // If not found, then the resource did not have a recommended name, so we try to find it
                // by manually searching parsing the resource's name
                if (assemblyFound == null)
                {
                    assemblyFound = _ResourceHelper.FindAssemblyFromResources(resourceName);
                }
            }
            else
            {
                try
                {
                    assemblyFound = Assembly.Load(assemblyName);
                }
                catch { }
            }

            if (assemblyFound != null)
            {
                GetImageFromAssembly(assemblyFound, resourceName, mimeType);
            }
            else
            {
                Logger.WarnFormat("ResourceController: cannot find the resource \"{0}\" in the modules assemblies.", resourceName);
            }
        }