本文整理汇总了C#中ILibraryManager.GetLibrary方法的典型用法代码示例。如果您正苦于以下问题:C# ILibraryManager.GetLibrary方法的具体用法?C# ILibraryManager.GetLibrary怎么用?C# ILibraryManager.GetLibrary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILibraryManager
的用法示例。
在下文中一共展示了ILibraryManager.GetLibrary方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProjectAssemblies
public static IEnumerable<Assembly> GetProjectAssemblies(
this ILibraryExporter libraryExporter,
ILibraryManager libraryManager,
IApplicationEnvironment environment)
{
if (libraryExporter == null)
{
throw new ArgumentNullException(nameof(libraryExporter));
}
if (libraryManager == null)
{
throw new ArgumentNullException(nameof(libraryManager));
}
if (environment == null)
{
throw new ArgumentNullException(nameof(environment));
}
return libraryExporter
.GetProjectsInApp(environment)
.Select(comp => libraryManager.GetLibrary(comp.Compilation.AssemblyName))
.Select(lib => LoadAssembly(lib.Name));
}
示例2: LoadAdapter
protected static IStorageAdapter LoadAdapter(ILibraryManager libraryManager, string library, string connectionString)
{
var lib = libraryManager.GetLibrary(library);
var assemblyName = lib.Assemblies.FirstOrDefault();
if(assemblyName == null)
throw new ApplicationException("Could not find assembly.");
var adapterAssembly = Assembly.Load(assemblyName);
if (adapterAssembly == null)
throw new ApplicationException("Failed to load assembly.");
var interfaceType = typeof(IStorageAdapter);
var types = adapterAssembly.GetTypes()
.Where(p => interfaceType.IsAssignableFrom(p));
var adapterType = types.FirstOrDefault();
if (adapterType == null)
throw new ApplicationException("Could not locate usable interface.");
var adapterInterfaceInstance = Activator.CreateInstance(adapterType, connectionString) as IStorageAdapter;
if (adapterInterfaceInstance == null)
throw new Exception("Could not create instance of interface.");
return adapterInterfaceInstance;
}
示例3: KestrelEngine
public KestrelEngine(ILibraryManager libraryManager, IApplicationShutdown appShutdownService)
: this(appShutdownService)
{
Libuv = new Libuv();
var libraryPath = default(string);
if (libraryManager != null)
{
var library = libraryManager.GetLibrary("Microsoft.AspNet.Server.Kestrel");
libraryPath = library.Path;
if (library.Type == "Project")
{
libraryPath = Path.GetDirectoryName(libraryPath);
}
if (Libuv.IsWindows)
{
var architecture = IntPtr.Size == 4
? "x86"
: "amd64";
libraryPath = Path.Combine(
libraryPath,
"native",
"windows",
architecture,
"libuv.dll");
}
else if (Libuv.IsDarwin)
{
libraryPath = Path.Combine(
libraryPath,
"native",
"darwin",
"universal",
"libuv.dylib");
}
else
{
libraryPath = "libuv.so.1";
}
}
Libuv.Load(libraryPath);
}
示例4: Startup
public Startup(ILibraryManager libraryManager)
{
if (PlatformApis.IsWindows())
{
var library = libraryManager.GetLibrary("LibGdAspNet5");
string libraryPath;
if (library.Type == "Project")
{
libraryPath = Path.GetDirectoryName(library.Path);
}
else
{
libraryPath = library.Path;
}
libraryPath = Path.Combine(libraryPath, "native", "windows", "x86");
LibGd.LoadWindows(libraryPath);
}
}
示例5: GetTemplateFolders
public static List<string> GetTemplateFolders(
string containingProject,
string applicationBasePath,
string[] baseFolders,
ILibraryManager libraryManager)
{
if (containingProject == null)
{
throw new ArgumentNullException(nameof(containingProject));
}
if (applicationBasePath == null)
{
throw new ArgumentNullException(nameof(applicationBasePath));
}
if (baseFolders == null)
{
throw new ArgumentNullException(nameof(baseFolders));
}
if (libraryManager == null)
{
throw new ArgumentNullException(nameof(libraryManager));
}
var rootFolders = new List<string>();
var templateFolders = new List<string>();
rootFolders.Add(applicationBasePath);
var dependency = libraryManager.GetLibrary(containingProject);
if (dependency != null)
{
string containingProjectPath = "";
if (string.Equals("Project", dependency.Type, StringComparison.Ordinal))
{
containingProjectPath = Path.GetDirectoryName(dependency.Path);
}
else if (string.Equals("Package", dependency.Type, StringComparison.Ordinal))
{
containingProjectPath = dependency.Path;
}
else
{
Debug.Assert(false, Resource.UnexpectedTypeLibraryForTemplates);
}
if (Directory.Exists(containingProjectPath))
{
rootFolders.Add(containingProjectPath);
}
}
foreach (var rootFolder in rootFolders)
{
foreach (var baseFolderName in baseFolders)
{
string templatesFolderName = "Templates";
var candidateTemplateFolders = Path.Combine(rootFolder, templatesFolderName, baseFolderName);
if (Directory.Exists(candidateTemplateFolders))
{
templateFolders.Add(candidateTemplateFolders);
}
}
}
return templateFolders;
}