Beispiel #1
0
        private void MapPathsForSwaggerUiAssets()
        {
            var thisAssembly = GetType().Assembly;

            foreach (var resourceName in thisAssembly.GetManifestResourceNames())
            {
                if (resourceName.Contains("CServiceStackSwagger.SwaggerUi.CustomAssets"))
                {
                    continue;                                                                       // original assets only
                }
                var path = resourceName
                           .Replace("\\", "/");
                //.Replace(".", "-"); // extensionless to avoid RUMMFAR

                _pathToAssetMap[path] = new EmbeddedAssetDescriptor(thisAssembly, resourceName, false);
            }
        }
        private Stream GetEmbeddedResourceStreamFor(EmbeddedAssetDescriptor resourceDescriptor)
        {
            var stream = resourceDescriptor.Assembly.GetManifestResourceStream(resourceDescriptor.Name);

            if (stream == null)
            {
                throw new AssetNotFound(String.Format("Embedded resource not found - {0}", resourceDescriptor.Name));
            }

            //if (resourceDescriptor.IsTemplate)
            //{
            //    var templateParams = _templateParams
            //        .Union(new[] { new KeyValuePair<string, string>("%(RootUrl)", rootUrl) })
            //        .ToDictionary(entry => entry.Key, entry => entry.Value);

            //    return stream.FindAndReplace(templateParams);
            //}

            return(stream);
        }