-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathPluginContentController.cs
37 lines (32 loc) · 1.24 KB
/
PluginContentController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//-----------------------------------------------------------------------
// <copyright file="PluginContentController.cs" company="(none)">
// Copyright © 2013 John Gietzen and the WebGit .NET Authors. All rights reserved.
// </copyright>
// <author>John Gietzen</author>
//-----------------------------------------------------------------------
namespace WebGitNet
{
using System;
using System.Linq;
using System.Web.Mvc;
public class PluginContentController : Controller
{
public ActionResult Resource(string assemblyName, string resourceName, string contentType = "application/octet-stream")
{
if (Url.RouteCollection["Default"] == RouteData.Route)
{
return HttpNotFound();
}
var assembly = (from a in AppDomain.CurrentDomain.GetAssemblies()
where !a.IsDynamic
where a.GetName().Name == assemblyName
select a).FirstOrDefault();
if (assembly == null)
{
return HttpNotFound();
}
var resource = assembly.GetManifestResourceStream(resourceName);
return File(resource, contentType);
}
}
}