Example #1
0
        private static Guid ExtractResourceInfo(string assemblyName, string resourcePath, out string assembly, out string resource, out string encoding)
        {
            Contract.Requires <ArgumentException>(!StringExtensions.IsNullOrWhiteSpace(assemblyName));
            Contract.Requires <ArgumentException>(!StringExtensions.IsNullOrWhiteSpace(resourcePath));

            assembly = TrimPath(assemblyName);
            resource = TrimPath(resourcePath);
            encoding = UrlCrypto.ToUrlEncodedString(resource);

            try
            {
                //---------------------------------------------------------------------------------
                //  The guid's are used to ensure that the client's browser does not use stale
                //  files from their cache. This is because whenever a new module's assembly is
                //  generated, the compiler assigns a new guid for it and new links are created
                //---------------------------------------------------------------------------------
                Assembly module = EmbeddedResourceHelper.GetResourceModule(assembly);
                Guid     guid   = module.ManifestModule.ModuleVersionId;
                return(guid);
            }
            catch (Exception)
            {
                return(Guid.Empty);  // couldn't retrieve the file info, probably a wrong file name
            }
        }