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


C# Assembly.Any方法代码示例

本文整理汇总了C#中System.Reflection.Assembly.Any方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.Any方法的具体用法?C# Assembly.Any怎么用?C# Assembly.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.Assembly的用法示例。


在下文中一共展示了Assembly.Any方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAssembliesInFolder

        private static IEnumerable<Assembly> GetAssembliesInFolder(Assembly[] loadedAsms, DirectoryInfo binPath)
        {
            List<Assembly> assemblies = new List<Assembly>();
            foreach (var fileSystemInfo in binPath.GetFileSystemInfos("*.dll"))
            {
                var assemblyName = AssemblyName.GetAssemblyName(fileSystemInfo.FullName);

                //first try to load assembly from refered libraries instead of plugin 'binaries' folder
                Assembly assembly = null;
                if (loadedAsms.Any(x => x.FullName == assemblyName.FullName))
                {
                    assembly = Assembly.Load(assemblyName);
                    break;
                }

                //if not found in referenced libraries, load from plugin binaries location
                if (assembly == null)
                {
                    assembly = Assembly.LoadFile(fileSystemInfo.FullName);
                    assemblies.Add(assembly);
                }
            }

            return assemblies;
        }
开发者ID:nhannv,项目名称:WebVella-ERP,代码行数:25,代码来源:MvcPluginExtensions.cs

示例2: EnsureAssembly

        /// <summary>
        /// In order for Assembly.GetCallingAssembly() to correctly reference this class' consumer, it must
        /// be invoked from a public method. Otherwise, Assembly.GetCallingAssembly() will reference this
        /// assembly, which obviously contains no AutoMapper.Profile implementations.
        ///
        /// This is a helper method for substituting the consuming assembly when no other assemblies are
        /// explicitly passed to any of the public RegisterProfiles method overloads.
        /// </summary>
        /// <param name="argAssemblies">
        /// The assemblies that the consuming assembly explcitly asked us to scan.
        /// </param>
        /// <param name="callingAssembly">
        /// The consuming assembly.
        /// </param>
        /// <returns>
        /// An enumeration of assemblies to be scanned for AutoMapper.Profile class implementations.
        /// </returns>
        private static IEnumerable<Assembly> EnsureAssembly(IEnumerable<Assembly> argAssemblies, Assembly callingAssembly)
        {
            // In order for GetCallingAssembly to work, it must be invoked from a public method.
            // This is why the callingAssembly arg is passed from public methods.

            // create an initial default empty array of assemblies in case argAssemblies is null
            var assembliesArray = new Assembly[] { };

            // when argAssemblies is not null, enumerate it as an array to prevent multiple enumerations
            if (argAssemblies != null)
                assembliesArray = argAssemblies.ToArray();

            // when there are no assemblies explicitly defined, return the calling assembly only
            if (!assembliesArray.Any())
                return new[] { callingAssembly };

            // otherwise, return the explicitly defined assemblies
            return assembliesArray;
        }
开发者ID:IanYates,项目名称:AutoAutoMapper,代码行数:36,代码来源:AutoProfiler.cs


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