當前位置: 首頁>>代碼示例>>C#>>正文


C# TargetFramework.IsExtensionOfFramework方法代碼示例

本文整理匯總了C#中MonoDevelop.Core.Assemblies.TargetFramework.IsExtensionOfFramework方法的典型用法代碼示例。如果您正苦於以下問題:C# TargetFramework.IsExtensionOfFramework方法的具體用法?C# TargetFramework.IsExtensionOfFramework怎麽用?C# TargetFramework.IsExtensionOfFramework使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MonoDevelop.Core.Assemblies.TargetFramework的用法示例。


在下文中一共展示了TargetFramework.IsExtensionOfFramework方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetAssemblyForVersion

		// Given the full name of an assembly, returns the corresponding full assembly name
		// in the specified target CLR version, or null if it doesn't exist in that version.
		public SystemAssembly GetAssemblyForVersion (string fullName, string packageName, TargetFramework fx)
		{
			Initialize ();

			fullName = NormalizeAsmName (fullName);
			
			//get the SystemAssembly for the current fullname, NOT the new target fx
			//in order to be able to check whether it's a framework assembly
			SystemAssembly asm = GetAssemblyFromFullName (fullName, packageName, null);

			if (asm == null)
				return null;
			
			var fxAsms = asm.AllSameName ().Where (a => a.Package.IsFrameworkPackage);
			
			//if the asm is not a framework asm, we don't upgrade it automatically
			if (!fxAsms.Any ()) {
				// Return null if the package is not compatible with the requested version
				if (fx.IsCompatibleWithFramework (asm.Package.TargetFramework))
					return asm;
				else
					return null;
			}
			
			foreach (var fxAsm in fxAsms) {
				if (fx.IsExtensionOfFramework (fxAsm.Package.TargetFramework))
					return fxAsm;
			}

			// We have to find the assembly with the same name in the target fx
			string fname = Path.GetFileName ((string) fxAsms.First ().Location);
			
			foreach (var pair in assemblyFullNameToAsm) {
				foreach (var fxAsm in pair.Value.AllSameName ()) {
					var rpack = fxAsm.Package;
					if (rpack.IsFrameworkPackage && fx.IsExtensionOfFramework (rpack.TargetFramework) && Path.GetFileName (fxAsm.Location) == fname)
						return fxAsm;
				}
			}
			return null;
		}
開發者ID:Tak,項目名稱:monodevelop-novell,代碼行數:43,代碼來源:AssemblyContext.cs

示例2: FindInstalledAssembly

		// Returns the installed version of the given assembly name
		// (it returns the full name of the installed assembly).
		public string FindInstalledAssembly (string fullname, string package, TargetFramework fx)
		{
			Initialize ();
			fullname = NormalizeAsmName (fullname);
			
			SystemAssembly fasm = GetAssemblyFromFullName (fullname, package, fx);
			if (fasm != null)
				return fullname;
			
			// Try to find a newer version of the same assembly, preferring framework assemblies
			if (fx == null) {
				string best = null;
				foreach (SystemAssembly asm in FindNewerAssembliesSameName (fullname)) {
					if (package == null || asm.Package.Name == package) {
						if (asm.Package.IsFrameworkPackage)
							return asm.FullName;
						else
							best = asm.FullName;
					}
				}
				return best;
			}
			
			string bestMatch = null;
			foreach (SystemAssembly asm in FindNewerAssembliesSameName (fullname)) {
				if (asm.Package.IsFrameworkPackage) {
					if (fx.IsExtensionOfFramework (asm.Package.TargetFramework))
						if (package == null || asm.Package.Name == package)
							return asm.FullName;
				} else if (fx.IsCompatibleWithFramework (asm.Package.TargetFramework)) {
					if (package != null && asm.Package.Name == package)
						return asm.FullName;
					bestMatch = asm.FullName;
				}
			}
			return bestMatch;
		}
開發者ID:Tak,項目名稱:monodevelop-novell,代碼行數:39,代碼來源:AssemblyContext.cs


注:本文中的MonoDevelop.Core.Assemblies.TargetFramework.IsExtensionOfFramework方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。