Exemplo n.º 1
0
        private void MapPathsForSwaggerUiAssets()
        {
            var thisAssembly = GetType().Assembly;

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

                _pathToAssetMap[path] = new EmbeddedAssetDescriptor(thisAssembly, resourceName, path == "index");
            }
        }
        private Stream GetEmbeddedResourceStreamFor(EmbeddedAssetDescriptor resourceDescriptor, string rootUrl)
        {
            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;
        }
Exemplo n.º 3
0
        private Stream GetEmbeddedResourceStreamFor(EmbeddedAssetDescriptor resourceDescriptor, string rootUrl)
        {
            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);
        }
Exemplo n.º 4
0
        private void MapPathsForSwaggerUiAssets()
        {
            var thisAssembly = GetType().Assembly;
            foreach (var resourceName in thisAssembly.GetManifestResourceNames())
            {
                if (resourceName.Contains("Abp.Web.Api.Swagger.SwaggerUi.CustomAssets")) continue; // original assets only

                var path = resourceName
                    .Replace("\\", "/")
                    .Replace(".", "-"); // extensionless to avoid RUMMFAR

                _pathToAssetMap[path] = new EmbeddedAssetDescriptor(thisAssembly, resourceName, path == "index");
            }
        }
Exemplo n.º 5
0
 public void CustomAsset(string path, Assembly resourceAssembly, string resourceName)
 {
     _pathToAssetMap[path] = new EmbeddedAssetDescriptor(resourceAssembly, resourceName, path == "index");
 }
Exemplo n.º 6
0
 public void CustomAsset(string path, Assembly resourceAssembly, string resourceName)
 {
     _pathToAssetMap[path] = new EmbeddedAssetDescriptor(resourceAssembly, resourceName, path == "index");
 }