当前位置: 首页>>代码示例>>C#>>正文


C# ILibraryManager.GetLibrary方法代码示例

本文整理汇总了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));
        }
开发者ID:leloulight,项目名称:Scaffolding,代码行数:25,代码来源:ReflectionUtilities.cs

示例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;
        }
开发者ID:aluitink,项目名称:Ojibwe,代码行数:31,代码来源:StorageLocationFactory.cs

示例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);
        }
开发者ID:justkao,项目名称:KestrelHttpServer,代码行数:44,代码来源:KestrelEngine.cs

示例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);
            }
        }
开发者ID:halter73,项目名称:seattlecodecamp,代码行数:20,代码来源:Startup.cs

示例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;
        }
开发者ID:leloulight,项目名称:Scaffolding,代码行数:70,代码来源:TemplateFoldersUtilities.cs


注:本文中的ILibraryManager.GetLibrary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。