• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Reflection.Assembly类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Assembly类属于System.Reflection命名空间,在下文中一共展示了Assembly类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Build

        public Test Build(string assemblyName, string testName, bool autoSuites)
        {
            if (testName == null || testName == string.Empty)
                return Build(assemblyName, autoSuites);

            // Change currentDirectory in case assembly references unmanaged dlls
            // and so that any addins are able to access the directory easily.
            using (new DirectorySwapper(Path.GetDirectoryName(assemblyName)))
            {
                this.assembly = Load(assemblyName);
                if (assembly == null) return null;

                // If provided test name is actually the name of
                // a type, we handle it specially
                Type testType = assembly.GetType(testName);
                if (testType != null)
                    return Build(assemblyName, testType, autoSuites);

                // Assume that testName is a namespace and get all fixtures in it
                IList fixtures = GetFixtures(assembly, testName);
                if (fixtures.Count > 0)
                    return BuildTestAssembly(assemblyName, fixtures, autoSuites);

                return null;
            }
        }
开发者ID:jimgraham,项目名称:visual-nunit,代码行数:26,代码来源:TestBuilder.cs


示例2: AddFromAssembly

        public static IServiceCollection AddFromAssembly(this IServiceCollection serviceCollection, Assembly assembly)
        {
            var builder = new ServiceDescriptorsBuilder().AddSourceAssembly(assembly);
            BuildAndFill(serviceCollection, builder);

            return serviceCollection;
        }
开发者ID:app-enhance,项目名称:ae-di,代码行数:7,代码来源:IServiceCollectionExtensions.cs


示例3: SearchPackageHandler

        public static int SearchPackageHandler(Assembly ass)
        {
            int count = 0;
            m_packagesHandlers.Clear();

            Type[] tList = ass.GetTypes();

            string interfaceStr = typeof(IPackageHandler).ToString();

            foreach (Type type in tList)
            {
                if (type.IsClass != true) continue;

                if (type.GetInterface(interfaceStr) == null) continue;

                PackageHandlerAttribute[] atts = (PackageHandlerAttribute[])type.GetCustomAttributes(typeof(PackageHandlerAttribute), true);

                if (atts.Length > 0)
                {
                    count++;
                    RegisterPacketHandler(atts[0].Code, (IPackageHandler)Activator.CreateInstance(type));
                    //m_packagesHandlers[atts[0].Code] = (IPackageHandler)Activator.CreateInstance(type);
                }
            }

            return count;
        }
开发者ID:W8023Y2014,项目名称:jsion,代码行数:27,代码来源:PackageHandlers.cs


示例4: TryCreatingIndexesOrRedirectToErrorPage

        private static void TryCreatingIndexesOrRedirectToErrorPage(Assembly[] indexAssemblies, string errorUrl)
        {
            try
            {
                foreach (var assembly in indexAssemblies)
                    IndexCreation.CreateIndexes(assembly, DocumentStore);
            }
            catch (WebException e)
            {
                var socketException = e.InnerException as SocketException;
                if (socketException == null)
                    throw;

                switch (socketException.SocketErrorCode)
                {
                    case SocketError.AddressNotAvailable:
                    case SocketError.NetworkDown:
                    case SocketError.NetworkUnreachable:
                    case SocketError.ConnectionAborted:
                    case SocketError.ConnectionReset:
                    case SocketError.TimedOut:
                    case SocketError.ConnectionRefused:
                    case SocketError.HostDown:
                    case SocketError.HostUnreachable:
                    case SocketError.HostNotFound:
                        HttpContext.Current.Response.Redirect(errorUrl);
                        break;
                    default:
                        throw;
                }
            }
        }
开发者ID:sofipacifico,项目名称:CommonJobs,代码行数:32,代码来源:RavenSessionManager.cs


示例5: GameLoader

        public GameLoader(string fileName, Assembly [] preloads, Action<string> die)
        {
            Game = new Game(this, die);
            string extention = null;
            try
            {
                extention = fileName.Substring(fileName.LastIndexOf('.'));
            }
            catch (Exception)
            {
                die("File " + fileName + " could Not be loaded");
                return;
            }

            if (".kgl" == extention)
            {
                loaderUtility = new KGLLoaderUtility(fileName, this);
            }
            else
            {
                die("File " + fileName + " could Not be loaded");
            }

            foreach (Assembly loaded in preloads)
            {
                string name = Path.GetFileName(loaded.Location);
                if (!LoadedFiles.ContainsKey(name))
                {
                    LoadedFiles.Add(name, loaded);
                    ClassFactory.LoadServicesAndManagers(loaded);
                }
            }
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:33,代码来源:GameLoader.cs


示例6: SendByMail

        /// <summary>
        /// Sends an error message by opening the user's mail client.
        /// </summary>
        /// <param name="recipient"></param>
        /// <param name="subject"></param>
        /// <param name="ex"></param>
        /// <param name="assembly">The assembly where the error originated. This will 
        /// be used to extract version information.</param>
        public static void SendByMail(string recipient, string subject, Exception ex,
            Assembly assembly, StringDictionary additionalInfo)
        {
            string attributes = GetAttributes(additionalInfo);

            StringBuilder msg = new StringBuilder();

            msg.AppendLine("[ Please send this as plain text to allow automatic pre-processing ]");
            msg.AppendLine();
            msg.AppendLine(GetMessage(ex));
            msg.AppendLine();
            msg.AppendLine(GetAttributes(additionalInfo));
            msg.AppendLine();
            msg.AppendLine("[ Please send this as plain text to allow automatic pre-processing ]");
            msg.AppendLine();

            string command = string.Format("mailto:{0}?subject={1}&body={2}",
                recipient,
                Uri.EscapeDataString(subject),
                Uri.EscapeDataString(msg.ToString()));

            Debug.WriteLine(command);
            Process p = new Process();
            p.StartInfo.FileName = command;
            p.StartInfo.UseShellExecute = true;

            p.Start();
        }
开发者ID:necora,项目名称:ank_git,代码行数:36,代码来源:ErrorMessage.cs


示例7: AssemblyScannerMockRegistry

        public AssemblyScannerMockRegistry(Assembly pluginAssembly)
        {
            _pluginAssembly = pluginAssembly;
            Forward<ISagaPersister, TpInMemorySagaPersister>();

            Forward<IActivityLogger, LogMock>();
        }
开发者ID:FarReachJason,项目名称:Target-Process-Plugins,代码行数:7,代码来源:AssemblyScannerMockRegistry.cs


示例8: LoadString

 public static string LoadString(string baseName, string resourceName, Assembly asm)
 {
     if (string.IsNullOrEmpty(baseName))
     {
         throw new ArgumentNullException("baseName");
     }
     if (string.IsNullOrEmpty(resourceName))
     {
         throw new ArgumentNullException("resourceName");
     }
     string str = null;
     if (asm != null)
     {
         str = LoadAssemblyString(asm, baseName, resourceName);
     }
     if (str == null)
     {
         str = LoadAssemblyString(Assembly.GetExecutingAssembly(), baseName, resourceName);
     }
     if (str == null)
     {
         return string.Empty;
     }
     return str;
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:25,代码来源:ResourceStringLoader.cs


示例9: GetLoadableTypes

 public IEnumerable<Type> GetLoadableTypes(Assembly assembly, Type ofBaseType)
 {
     var types = GetLoadableTypes(assembly);
     return types != null
                ? types.Where(ofBaseType.IsAssignableFrom)
                : null;
 }
开发者ID:juancarlospalomo,项目名称:tantumcms,代码行数:7,代码来源:DefaultAssemblyLoader.cs


示例10: Theme

        /// <summary>
        /// Initializes a new instance of the Theme class.
        /// </summary>
        /// <param name="themeAssembly">
        /// Assembly with the embedded resource containing the theme to apply.
        /// </param>
        /// <param name="themeResourceName">
        /// Name of the embedded resource containing the theme to apply.
        /// </param>
        protected Theme(Assembly themeAssembly, string themeResourceName)
            : this()
        {
            if (themeAssembly == null)
            {
                throw new ArgumentNullException("themeAssembly");
            }

            // Get the resource stream for the theme.
            using (Stream stream = themeAssembly.GetManifestResourceStream(themeResourceName))
            {
                if (stream == null)
                {
                    throw new ResourceNotFoundException(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            Properties.Resources.Theme_ResourceNotFound,
                            themeResourceName),
                        new Uri(themeResourceName, UriKind.Relative));
                }

                // Load the theme
                ThemeResources = LoadThemeResources(stream, Resources);
            }
        }
开发者ID:shijiaxing,项目名称:SilverlightToolkit,代码行数:34,代码来源:Theme.cs


示例11: compile_

		public static CompilerContext compile_(CompileUnit unit, Assembly[] references)
		{
			BooCompiler compiler = NewCompiler();
			foreach (Assembly reference in references)
				compiler.Parameters.References.Add(reference);
			return compiler.Run(unit);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:Compilation.cs


示例12: FromResource

		public static UIImage FromResource (Assembly assembly, string name)
		{
			if (name == null)
				throw new ArgumentNullException ("name");
			assembly = Assembly.GetCallingAssembly ();
			var stream = assembly.GetManifestResourceStream (name);
			if (stream == null)
				return null;
			
			IntPtr buffer = Marshal.AllocHGlobal ((int) stream.Length);
			if (buffer == IntPtr.Zero)
				return null;
			
			var copyBuffer = new byte [Math.Min (1024, (int) stream.Length)];
			int n;
			IntPtr target = buffer;
			while ((n = stream.Read (copyBuffer, 0, copyBuffer.Length)) != 0){
				Marshal.Copy (copyBuffer, 0, target, n);
				target = (IntPtr) ((int) target + n);
			}
			try {
				var data = NSData.FromBytes (buffer, (uint) stream.Length);
				return UIImage.LoadFromData (data);
			} finally {
				Marshal.FreeHGlobal (buffer);
				stream.Dispose ();
			}
		}
开发者ID:Clancey,项目名称:MonoTouch.Dialog,代码行数:28,代码来源:Controls.cs


示例13: GetExamples

        private void GetExamples(Assembly asm)
        {
            var types = asm.GetExportedTypes().OrderBy(t => t.Name);

            foreach (Type type in types)
            {
                if (type.GetInterface(typeof(IExample).Name) != null && !type.IsAbstract)
                {
                    var example = (ExampleDescriptionAttribute)type.GetCustomAttributes(typeof(ExampleDescriptionAttribute), false)[0];

                    var paths = example.NodePath.Split(';');
                    foreach (var path in paths)
                    {
                        var pathNodes = path.Split('/');
                        var nodes = this.treeView1.Nodes;
                        for (int index = 0; index < pathNodes.Length; index++)
                        {
                            var s = pathNodes[index];
                            if (!nodes.ContainsKey(s))
                            {
                                var node = nodes.Add(s, s);
                                if (index == pathNodes.Length - 1)
                                {
                                    node.Tag = type.GetConstructor(Type.EmptyTypes);
                                }
                            }

                            nodes = nodes[s].Nodes;
                        }
                    }
                }
            }
        }
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:33,代码来源:ExampleSelector.cs


示例14: GetResourceManager

 private static ResourceManager GetResourceManager(string resourceBaseName, Assembly assembly)
 {
     // check the cache
     if (_resManager == null)
         _resManager = new ResourceManager(resourceBaseName, assembly);
     return _resManager;
 }
开发者ID:dtafe,项目名称:WorkNC,代码行数:7,代码来源:ResourceUtil.cs


示例15: ResolveAssembly

        private static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
        {
            var name = args.Name.Split(',')[0];

            if (name.Equals("Microsoft.UpdateServices.Administration"))
            {
                // Microsoft changed version numbers when putting WSUS Admin API into RSAT.
                // Need to try and maintain backward compatability.

                if (!alreadyTriedRedirect)
                {
                    alreadyTriedRedirect = true;

                    var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                    if (!programFiles.EndsWith(@"\"))
                    {
                        programFiles = programFiles + @"\";
                    }

                    redirect = Assembly.LoadFrom(string.Format("{0}Update Services\\Api\\Microsoft.UpdateServices.Administration.dll", programFiles));
                }

                return redirect;
            }

            return null;
        }
开发者ID:dpvreony,项目名称:wsussmartapprove,代码行数:27,代码来源:Program.cs


示例16: AddAssemblyTypes

 private void AddAssemblyTypes(Assembly assembly)
 {
     Type[] types = assembly.GetTypes();
     foreach (var type in types)
         if (typeof(BinaryData).IsAssignableFrom(type) && !type.IsAbstract)
             AddType(type);
 }
开发者ID:hillwhite,项目名称:DeltaEngine,代码行数:7,代码来源:BinaryDataFactory.cs


示例17: ServiceInstallerBase

        /// <summary>
        /// ProcessingServiceInstaller initialization with information from service assembly and RunAs user name, password from config file
        /// </summary>
        /// <param name="serviceAssembly"></param>
        /// <param name="installRunAsUserFromConfig"></param>
        public ServiceInstallerBase(Assembly serviceAssembly, bool installRunAsUserFromConfig)
        {
            if (serviceAssembly == null)
                throw new ServiceInitializationException("Installation failed, serviceAssembly is null");

            IAssemblyInfo assemblyInfo = new AssemblyInfo(serviceAssembly);

            if (installRunAsUserFromConfig)
            {
                var config = ConfigurationManager.OpenExeConfiguration(serviceAssembly.Location);
                var configSection = config.GetSection("ServiceInstallerSettings");

                if (configSection != null)
                {
                    var configSectionElement = XElement.Parse(configSection.SectionInformation.GetRawXml());

                    foreach (var item in configSectionElement.XPathSelectElements("add"))
                    {
                        if (item.Attribute(XName.Get("key")) == null)
                            continue;

                        if (item.Attribute(XName.Get("key")).Value == "RunAsUserName")
                            _userName = item.Attribute(XName.Get("value")).Value;

                        if (item.Attribute(XName.Get("key")).Value == "RunAsUserPassword")
                            _password = item.Attribute(XName.Get("value")).Value;
                    }
                }
            }

            Initialize(assemblyInfo.Description, assemblyInfo.Description, assemblyInfo.Title, ServiceAccount.User, _userName, _password);
        }
开发者ID:jv9,项目名称:Simplify,代码行数:37,代码来源:ServiceInstallerBase.cs


示例18: PluginConfiguration

 public PluginConfiguration(string moduleName, Assembly applicationAssembly, Assembly domainAssembly, Assembly infrastructureAssembly)
 {
     ModuleName = moduleName;
     ApplicationAssembly = applicationAssembly;
     DomainAssembly = domainAssembly;
     InfrastructureAssembly = infrastructureAssembly;
 }
开发者ID:TicketArchitecture,项目名称:EasyArchitecture,代码行数:7,代码来源:PluginConfiguration.cs


示例19: Load

 /// <summary>
 /// Loads this the module and instantiates the UrlMap.
 /// </summary>
 public void Load()
 {
     if (!File.Exists(ModulePath))
     {
         throw new NoSuchModuleException("Error: No such module at '" + ModulePath + "'.");
     }
     ModuleAssembly = Assembly.LoadFile(ModulePath);
     #if (Windows && !Unix)
     int lastslash = ModulePath.LastIndexOf(@"\");
     #else
     int lastslash = ModulePath.LastIndexOf("/");
     #endif
     string assemblynamespace = ModulePath.Substring(lastslash+1, ModulePath.LastIndexOf('.') - lastslash-1);
     ModuleNamespace = assemblynamespace;
     Type t = ModuleAssembly.GetType(assemblynamespace+".ModuleMap");
     if (t != null)
     {
         MethodInfo m = t.GetMethod("GetUrlMap");
         if (m != null)
         {
             UrlMap = (List<UrlMapItem>)m.Invoke(null, (new object[]{}));
         }
         else
         {
             throw new InvalidModuleMapException("Error: The ModuleMap class is incorrect!");
         }
     }
     else
     {
         throw new InvalidModuleMapException("Error: The ModuleMap class is missing!");
     }
 }
开发者ID:theanti9,项目名称:irek,代码行数:35,代码来源:Module.cs


示例20: GetPluginEntity

        public PluginEntity GetPluginEntity(Assembly _Assembly, string _Url, out List<Function> _Functions)
        {
            //this.Functions.ForEach(x => { x.Url = _Url; x.Assembly = _Assembly; });  // x 是临时的~~ 修改不了

            //for (int i = 0; i < this.Functions.Count; i++)   // 这样写赋值不上
            //{

            //    //Functions[i].Url = _Url;
            //    this.Functions[i].Url = "asdfasdf";
            //    this.Functions[i].Assembly = _Assembly;
            //}

            _Functions = Functions.Select(x => new Function()
                {
                    Action = x.Action,
                    Assembly = _Assembly,
                    Controller = x.Controller,
                    NameSpace = x.NameSpace,
                    ControllerType = x.ControllerType,
                    Name = x.Name,
                    Url = _Url
                }).ToList();

            return new PluginEntity(
                        Name: this.Name,
                        Author: this.Author,
                        Description: this.Description,
                        Functions: _Functions.ToDictionary(x => x.Name), // 通过Function对象的Name属性作为key
                        Assembly: _Assembly
                       );
        }
开发者ID:flint527,项目名称:SmartPlatform,代码行数:31,代码来源:BasePlugin.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Reflection.AssemblyName类代码示例发布时间:2022-05-26
下一篇:
C# Numerics.Vector3类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap