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


C# Reflection.Assembly类代码示例

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


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


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