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


C# Assembly.ToString方法代码示例

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


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

示例1: FormatAssembly

 private string FormatAssembly(Assembly assem)
 {
     string formatedAssembly = assem.ToString();
     formatedAssembly = formatedAssembly.Remove(formatedAssembly.IndexOf("Culture"));
     if (formatedAssembly.Contains(".D"))
         formatedAssembly = formatedAssembly.Replace(".D", " D");
     formatedAssembly = formatedAssembly.Replace(',', ' ');
     formatedAssembly = formatedAssembly.Replace('=', '.');
     formatedAssembly = formatedAssembly.Replace("Version", "v");
     return formatedAssembly;
 }
开发者ID:dineshkummarc,项目名称:SWAT_4.1_Binaries_Source,代码行数:11,代码来源:AboutForm.cs

示例2: Initialize

 public override void Initialize(Assembly templateAssembly, string templateResourcePath)
 {
     if (_engine.Settings is SparkSettings)
     {
         var parameters = new Dictionary<string, string>
         {
             { "assembly", templateAssembly.ToString() },
             { "resourcePath", templateResourcePath }
         };
         ((SparkSettings) _engine.Settings).AddViewFolder(ViewFolderType.EmbeddedResource, parameters);
     }
 }
开发者ID:dpawatts,项目名称:zeus,代码行数:12,代码来源:DefaultMessageBuilder.cs

示例3: GetEmbeddedResource

        /// <summary>
        /// Assembly defaults to the current IExtendFramework assembly
        /// </summary>
        /// <param name="resourceName"></param>
        /// <param name="asm"></param>
        /// <returns></returns>
        public static Stream GetEmbeddedResource(string resourceName, Assembly asm = null)
        {
            if (asm == null)
                asm = Assembly.GetExecutingAssembly();
            //Assembly a1 = Assembly.GetExecutingAssembly();
            //Stream s = a1.GetManifestResourceStream(resourceName);
            //return s;
            Stream s = asm.GetManifestResourceStream(resourceName);
            if (s == null)
                throw new Exception("Could not load '" + resourceName + "' from '" + asm.ToString() + "'!");

            return s;
        }
开发者ID:mlnlover11,项目名称:IExtendFramework,代码行数:19,代码来源:AssemblyHelper.cs

示例4: BindTreeView

        private void BindTreeView(Assembly _assembly, Type _superType, Type _attributeType)
        {
            selectedAssembly__ = _assembly;

            treeView.Nodes.Clear();
            TreeNode root = treeView.Nodes.Add(_assembly.ToString(), _assembly.ToString(), "Assembly", "Assembly");
            root.Tag = null;
            foreach (Type type in _assembly.GetTypes())
            {
                if (_superType != null)
                {
                    if (!type.IsSubclassOf(_superType))
                        continue;
                }
                if (_attributeType != null)
                {
                    bool found = false;
                    object[] attrs = type.GetCustomAttributes(false);
                    foreach (object attr in attrs)
                    {
                        if (attr.GetType() == _attributeType)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found) continue;
                }
                TreeNode node = root.Nodes.Add(type.FullName, type.FullName, "Type", "Type");
                node.Tag = type;
            }

            root.ExpandAll();
            treeView.SelectedNode = root;
            btnOK.Enabled = false;
        }
开发者ID:daxnet,项目名称:guluwin,代码行数:36,代码来源:TypeSelector.cs

示例5: GetTypes

        protected static IEnumerable<Type> GetTypes(Assembly assembly)
        {
            try {
            return assembly.GetTypes();
              } catch (Exception ex) {
            string msg = string.Empty;
            if (ex is System.Reflection.ReflectionTypeLoadException) {
              msg = ((ReflectionTypeLoadException)ex).LoaderExceptions.ToAggregateString(". ");
            }
            Trace.WriteLine("Breeze probing: Unable to execute Assembly.GetTypes() for "
              + assembly.ToString() + "." + msg);

            return new Type[] { };
              }
        }
开发者ID:jgarverick,项目名称:Breeze,代码行数:15,代码来源:BreezeConfig.cs

示例6: LoadAssembly

        private void LoadAssembly(string path, ref Assembly currentAssembly, ref Type currentType, ref MirandaPlugin currentPlugin)
        {
            Log.DebuggerWrite(0, LogCategory, "Loading assembly '" + path + "'...");

            try
            {
                currentAssembly = Assembly.Load(Path.GetFileNameWithoutExtension(path));

                foreach (Type type in GetExposedPlugins(currentAssembly))
                    LoadPluginFromType(currentType = type);
            }
            catch (BadImageFormatException bifE)
            {
                throw new FusionException(String.Format(TextResources.ExceptionMsg_Formatable1_UnmanagedImageFound, path), bifE.FusionLog, null, null, null, bifE);
            }
            catch (FileNotFoundException fnfE)
            {
                throw new FusionException(String.Format(TextResources.ExceptionMsg_Formatable1_AssemblyLoadError, currentAssembly != null ? currentAssembly.ToString() : path), fnfE.FusionLog, currentAssembly, currentType, null, fnfE);
            }
            catch (FusionException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new FusionException(String.Format(TextResources.ExceptionMsg_Formatable1_AssemblyLoadError, path, e.Message), currentAssembly.ToString(), null, null, null, e);
            }
        }
开发者ID:tomasdeml,项目名称:hyphen,代码行数:28,代码来源:DefaultPluginManager.cs

示例7: GetNeutralResourcesLanguage

 internal static CultureInfo GetNeutralResourcesLanguage(Assembly a, ref UltimateResourceFallbackLocation fallbackLocation)
 {
     IList<CustomAttributeData> customAttributes = CustomAttributeData.GetCustomAttributes(a);
     CustomAttributeData data = null;
     for (int i = 0; i < customAttributes.Count; i++)
     {
         if (customAttributes[i].Constructor.DeclaringType == typeof(NeutralResourcesLanguageAttribute))
         {
             data = customAttributes[i];
             break;
         }
     }
     if (data == null)
     {
         if (FrameworkEventSource.IsInitialized)
         {
             FrameworkEventSource.Log.ResourceManagerNeutralResourceAttributeMissing(a);
         }
         fallbackLocation = UltimateResourceFallbackLocation.MainAssembly;
         return CultureInfo.InvariantCulture;
     }
     string name = null;
     if (data.Constructor.GetParameters().Length == 2)
     {
         CustomAttributeTypedArgument argument = data.ConstructorArguments[1];
         fallbackLocation = (UltimateResourceFallbackLocation) argument.Value;
         if ((fallbackLocation < UltimateResourceFallbackLocation.MainAssembly) || (fallbackLocation > UltimateResourceFallbackLocation.Satellite))
         {
             throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", new object[] { (UltimateResourceFallbackLocation) fallbackLocation }));
         }
     }
     else
     {
         fallbackLocation = UltimateResourceFallbackLocation.MainAssembly;
     }
     CustomAttributeTypedArgument argument2 = data.ConstructorArguments[0];
     name = argument2.Value as string;
     try
     {
         return CultureInfo.GetCultureInfo(name);
     }
     catch (ArgumentException exception)
     {
         if (a != typeof(object).Assembly)
         {
             throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_Asm_Culture", new object[] { a.ToString(), name }), exception);
         }
         return CultureInfo.InvariantCulture;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:50,代码来源:ManifestBasedResourceGroveler.cs

示例8: GetBackendsFromAssembly

        private List<IBackend> GetBackendsFromAssembly(Assembly asm)
        {
            List<IBackend> backends = new List<IBackend> ();

            Type[] types = null;

            try {
                types = asm.GetTypes ();
            } catch (Exception e) {
                Logger.Warn ("Exception reading types from assembly '{0}': {1}",
                    asm.ToString (), e.Message);
                return backends;
            }
            foreach (Type type in types) {
                if (!type.IsClass) {
                    continue; // Skip non-class types
                }
                if (type.GetInterface ("Tasque.Backends.IBackend") == null) {
                    continue;
                }
                Logger.Debug ("Found Available Backend: {0}", type.ToString ());

                IBackend availableBackend = null;
                try {
                    availableBackend = (IBackend)
                        asm.CreateInstance (type.ToString ());
                } catch (Exception e) {
                    Logger.Warn ("Could not instantiate {0}: {1}",
                                 type.ToString (),
                                 e.Message);
                    continue;
                }

                if (availableBackend != null) {
                    backends.Add (availableBackend);
                }
            }

            return backends;
        }
开发者ID:nolith,项目名称:tasque,代码行数:40,代码来源:Application.cs

示例9: AddAssembly

 public static void AddAssembly(Assembly a) 
 {
     Assemblies[a.ToString().Substring(0, a.ToString().IndexOf(','))] = a;
 }
开发者ID:emote-project,项目名称:Scenario1,代码行数:4,代码来源:DataTypes.cs

示例10: AddComponentsToList

		void AddComponentsToList(Assembly assembly, string loadPath)
		{
			if (assembly != null) {
				Hashtable images = new Hashtable();
				ImageList il = new ImageList();
				// try to load res icon
				string[] imgNames = assembly.GetManifestResourceNames();
				
				foreach (string im in imgNames) {
					try {
						Bitmap b = new Bitmap(Image.FromStream(assembly.GetManifestResourceStream(im)));
						b.MakeTransparent();
						images[im] = il.Images.Count;
						il.Images.Add(b);
					} catch {}
				}
				try {
					componentListView.SmallImageList = il;
					foreach (Type t in assembly.GetExportedTypes()) {
						if (!t.IsAbstract) {
							if (t.IsDefined(typeof(ToolboxItemFilterAttribute), true) || t.IsDefined(typeof(ToolboxItemAttribute), true) || typeof(System.ComponentModel.IComponent).IsAssignableFrom(t)) {
								object[] attributes  = t.GetCustomAttributes(false);
								object[] filterAttrs = t.GetCustomAttributes(typeof(DesignTimeVisibleAttribute), true);
								foreach (DesignTimeVisibleAttribute visibleAttr in filterAttrs) {
									if (!visibleAttr.Visible) {
										goto skip;
									}
								}
								
								if (images[t.FullName + ".bmp"] == null) {
									if (t.IsDefined(typeof(ToolboxBitmapAttribute), false)) {
										foreach (object attr in attributes) {
											if (attr is ToolboxBitmapAttribute) {
												ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr;
												images[t.FullName + ".bmp"] = il.Images.Count;
												Bitmap b = new Bitmap(toolboxBitmapAttribute.GetImage(t));
												b.MakeTransparent(Color.Fuchsia);
												il.Images.Add(b);
												break;
											}
										}
									}
								}
								
								ListViewItem newItem = new ListViewItem(t.Name);
								newItem.SubItems.Add(t.Namespace);
								newItem.SubItems.Add(assembly.ToString());
								newItem.SubItems.Add(assembly.Location);
								newItem.SubItems.Add(t.Namespace);
								if (images[t.FullName + ".bmp"] != null) {
									newItem.ImageIndex = (int)images[t.FullName + ".bmp"];
								}
								newItem.Checked  = true;
								ToolComponent toolComponent = new ToolComponent(t.FullName, new ComponentAssembly(assembly.FullName, loadPath), true);
								newItem.Tag = toolComponent;
								componentListView.Items.Add(newItem);
								ToolboxItem item = new ToolboxItem(t);
								skip:;
							}
						}
					}
				} catch (Exception e) {
					ClearComponentsList(e.Message);
				}
			}
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:66,代码来源:AddComponentsDialog.cs

示例11: GetNeutralResourcesLanguage

        private static CultureInfo GetNeutralResourcesLanguage(Assembly a, ref UltimateResourceFallbackLocation fallbackLocation)
        {
            BCLDebug.Assert(a != null, "assembly != null");

            IList<CustomAttributeData> attrs = CustomAttributeData.GetCustomAttributes(a);
            CustomAttributeData attr = null;
            for (int i = 0; i < attrs.Count; i++)
            {
                if (attrs[i].Constructor.DeclaringType == typeof(NeutralResourcesLanguageAttribute))
                {
                    attr = attrs[i];
                    break;
                }
            }

            if (attr == null)
            {
#if _DEBUG
                if (DEBUG >= 4) 
                    BCLDebug.Log("Consider putting the NeutralResourcesLanguageAttribute on assembly "+a.FullName);
#endif
                BCLDebug.Perf(false, "Consider adding NeutralResourcesLanguageAttribute to assembly "+a.FullName);
                fallbackLocation = UltimateResourceFallbackLocation.MainAssembly;
                return CultureInfo.InvariantCulture;
            }

            string cultureName = null;
            if (attr.Constructor.GetParameters().Length == 2) { 
                fallbackLocation = (UltimateResourceFallbackLocation)attr.ConstructorArguments[1].Value;
                if (fallbackLocation < UltimateResourceFallbackLocation.MainAssembly || fallbackLocation > UltimateResourceFallbackLocation.Satellite)
                    throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", fallbackLocation));
            }
            else
                fallbackLocation = UltimateResourceFallbackLocation.MainAssembly;

            cultureName = attr.ConstructorArguments[0].Value as string;

            try {
                CultureInfo c = CultureInfo.GetCultureInfo(cultureName);
                return c;
            }
            catch (ArgumentException e) { // we should catch ArgumentException only.
                // Note we could go into infinite loops if mscorlib's 
                // NeutralResourcesLanguageAttribute is mangled.  If this assert
                // fires, please fix the build process for the BCL directory.
                if (a == typeof(Object).Assembly) {
                    BCLDebug.Assert(false, "mscorlib's NeutralResourcesLanguageAttribute is a malformed culture name! name: \"" + cultureName + "\"  Exception: " + e);
                    return CultureInfo.InvariantCulture;
                }
                
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_Asm_Culture"), a.ToString(), cultureName), e);
            }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:53,代码来源:resourcemanager.cs

示例12: GetNeutralResourcesLanguage

        internal static CultureInfo GetNeutralResourcesLanguage(Assembly a, ref UltimateResourceFallbackLocation fallbackLocation) 
        {
            Contract.Assert(a != null, "assembly != null"); 

            IList<CustomAttributeData> attrs = CustomAttributeData.GetCustomAttributes(a);
            CustomAttributeData attr = null;
            for (int i = 0; i < attrs.Count; i++) 
            {
                if (attrs[i].Constructor.DeclaringType == typeof(NeutralResourcesLanguageAttribute)) 
                { 
                    attr = attrs[i];
                    break; 
                }
            }

            if (attr == null) 
            {
#if !FEATURE_CORECLR 
                if (FrameworkEventSource.IsInitialized) 
                {
                    FrameworkEventSource.Log.ResourceManagerNeutralResourceAttributeMissing(a); 
                }
#endif

                fallbackLocation = UltimateResourceFallbackLocation.MainAssembly; 
                return CultureInfo.InvariantCulture;
            } 
 
            string cultureName = null;
            if (attr.Constructor.GetParameters().Length == 2) 
            {
                fallbackLocation = (UltimateResourceFallbackLocation)attr.ConstructorArguments[1].Value;
                if (fallbackLocation < UltimateResourceFallbackLocation.MainAssembly || fallbackLocation > UltimateResourceFallbackLocation.Satellite)
                    throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", fallbackLocation)); 
            }
            else 
                fallbackLocation = UltimateResourceFallbackLocation.MainAssembly; 

            cultureName = attr.ConstructorArguments[0].Value as string; 

            try
            {
                CultureInfo c = CultureInfo.GetCultureInfo(cultureName); 
                return c;
            } 
            catch (ArgumentException e) 
            { // we should catch ArgumentException only.
                // Note we could go into infinite loops if mscorlib's 
                // NeutralResourcesLanguageAttribute is mangled.  If this assert
                // fires, please fix the build process for the BCL directory.
                if (a == typeof(Object).Assembly)
                { 
                    Contract.Assert(false, "mscorlib's NeutralResourcesLanguageAttribute is a malformed culture name! name: \"" + cultureName + "\"  Exception: " + e);
                    return CultureInfo.InvariantCulture; 
                } 

                throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_Asm_Culture", a.ToString(), cultureName), e); 
            }
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:59,代码来源:ManifestBasedResourceGroveler.cs

示例13: GetBackendsFromAssembly

        List<Backend> GetBackendsFromAssembly(Assembly asm)
        {
            var backends = new List<Backend> ();
            Type[] types = null;

            try {
                types = asm.GetTypes ();
            } catch (Exception e) {
                Trace.TraceWarning ("Exception reading types from assembly '{0}': {1}", asm.ToString (), e.Message);
                return backends;
            }

            foreach (var type in types) {
                if (!type.IsClass)
                    continue; // Skip non-class types

                if (!typeof(Backend).IsAssignableFrom (type))
                    continue;

                Debug.WriteLine ("Found Available Backend: {0}", type);

                Backend availableBackend = null;
                try {
                    availableBackend = (Backend)asm.CreateInstance (type.ToString ());
                } catch (Exception e) {
                    Trace.TraceWarning ("Could not instantiate {0}: {1}", type.ToString (), e.Message);
                    continue;
                }

                if (availableBackend != null)
                    backends.Add (availableBackend);
            }

            return backends;
        }
开发者ID:mono-soc-2012,项目名称:Tasque,代码行数:35,代码来源:Application.cs

示例14: GetNeutralResourcesLanguage

        internal static CultureInfo GetNeutralResourcesLanguage(Assembly a, ref UltimateResourceFallbackLocation fallbackLocation)
        {

#if FEATURE_LEGACYNETCF
            // Windows Phone 7.0/7.1 ignore NeutralResourceLanguage attribute and 
            // defaults fallbackLocation to MainAssembly
            if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
            {
                fallbackLocation = UltimateResourceFallbackLocation.MainAssembly;
                return CultureInfo.InvariantCulture;
            }
#endif

            Contract.Assert(a != null, "assembly != null");
            string cultureName = null;
            short fallback = 0;
            if (GetNeutralResourcesLanguageAttribute(((RuntimeAssembly)a).GetNativeHandle(), 
                                                        JitHelpers.GetStringHandleOnStack(ref cultureName), 
                                                        out fallback)) {
                if ((UltimateResourceFallbackLocation)fallback < UltimateResourceFallbackLocation.MainAssembly || (UltimateResourceFallbackLocation)fallback > UltimateResourceFallbackLocation.Satellite) {
                    throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", fallback));
                }
                fallbackLocation = (UltimateResourceFallbackLocation)fallback;
            }
            else {
#if !FEATURE_CORECLR
                if (FrameworkEventSource.IsInitialized) {
                    FrameworkEventSource.Log.ResourceManagerNeutralResourceAttributeMissing(a);
                }
#endif
                fallbackLocation = UltimateResourceFallbackLocation.MainAssembly;
                return CultureInfo.InvariantCulture;
            }

            try
            {
                CultureInfo c = CultureInfo.GetCultureInfo(cultureName);
                return c;
            }
            catch (ArgumentException e)
            { // we should catch ArgumentException only.
                // Note we could go into infinite loops if mscorlib's 
                // NeutralResourcesLanguageAttribute is mangled.  If this assert
                // fires, please fix the build process for the BCL directory.
                if (a == typeof(Object).Assembly)
                {
                    Contract.Assert(false, "mscorlib's NeutralResourcesLanguageAttribute is a malformed culture name! name: \"" + cultureName + "\"  Exception: " + e);
                    return CultureInfo.InvariantCulture;
                }

                throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_Asm_Culture", a.ToString(), cultureName), e);
            }
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:53,代码来源:ManifestBasedResourceGroveler.cs

示例15: GetNeutralResourcesLanguage

        internal static CultureInfo GetNeutralResourcesLanguage(Assembly a, ref UltimateResourceFallbackLocation fallbackLocation)
        {
            Debug.Assert(a != null, "assembly != null");
            string cultureName = null;
            short fallback = 0;
            if (GetNeutralResourcesLanguageAttribute(((RuntimeAssembly)a).GetNativeHandle(), 
                                                        JitHelpers.GetStringHandleOnStack(ref cultureName), 
                                                        out fallback)) {
                if ((UltimateResourceFallbackLocation)fallback < UltimateResourceFallbackLocation.MainAssembly || (UltimateResourceFallbackLocation)fallback > UltimateResourceFallbackLocation.Satellite) {
                    throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", fallback));
                }
                fallbackLocation = (UltimateResourceFallbackLocation)fallback;
            }
            else {
                fallbackLocation = UltimateResourceFallbackLocation.MainAssembly;
                return CultureInfo.InvariantCulture;
            }

            try
            {
                CultureInfo c = CultureInfo.GetCultureInfo(cultureName);
                return c;
            }
            catch (ArgumentException e)
            { // we should catch ArgumentException only.
                // Note we could go into infinite loops if mscorlib's 
                // NeutralResourcesLanguageAttribute is mangled.  If this assert
                // fires, please fix the build process for the BCL directory.
                if (a == typeof(Object).Assembly)
                {
                    Debug.Assert(false, System.CoreLib.Name+"'s NeutralResourcesLanguageAttribute is a malformed culture name! name: \"" + cultureName + "\"  Exception: " + e);
                    return CultureInfo.InvariantCulture;
                }

                throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_Asm_Culture", a.ToString(), cultureName), e);
            }
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:37,代码来源:ManifestBasedResourceGroveler.cs


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