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


C# AssemblyName.GetPublicKeyToken方法代码示例

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


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

示例1: RoundTrip

        private void RoundTrip(AssemblyName name, bool testFullName = true)
        {
            AssemblyName rtName;
            FusionAssemblyIdentity.IAssemblyName obj;

            if (testFullName)
            {
                string fullName = name.FullName;

                obj = FusionAssemblyIdentity.ToAssemblyNameObject(fullName);
                rtName = ToAssemblyName(obj);
                Assert.Equal(name.Name, rtName.Name);
                Assert.Equal(name.Version, rtName.Version);
                Assert.Equal(name.CultureInfo, rtName.CultureInfo);
                Assert.Equal(name.GetPublicKeyToken(), rtName.GetPublicKeyToken());
                Assert.Equal(name.Flags, rtName.Flags);
                Assert.Equal(name.ContentType, rtName.ContentType);

                string displayName = FusionAssemblyIdentity.GetDisplayName(obj, FusionAssemblyIdentity.ASM_DISPLAYF.FULL);
                Assert.Equal(fullName, displayName);
            }

            obj = FusionAssemblyIdentity.ToAssemblyNameObject(name);
            rtName = ToAssemblyName(obj);
            Assert.Equal(name.Name, rtName.Name);
            Assert.Equal(name.Version, rtName.Version);
            Assert.Equal(name.CultureInfo, rtName.CultureInfo);
            Assert.Equal(name.GetPublicKeyToken(), rtName.GetPublicKeyToken());
            Assert.Equal(name.Flags, rtName.Flags);
            Assert.Equal(name.ContentType, rtName.ContentType);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:31,代码来源:FusionAssemblyIdentityTests.cs

示例2: FilterOnPkt

        private static IEnumerable<Assembly> FilterOnPkt(IEnumerable<Assembly> assemblies, AssemblyName assmName)
        {
            if (assmName.GetPublicKeyToken() != null)
            {
                var r = assemblies.Where(a => a.GetName().GetPublicKeyToken().SequenceEqual(assmName.GetPublicKeyToken()));
                if (!r.Any())
                    return assemblies;
                else
                    return r;
            }

            return assemblies;
        }
开发者ID:henjuv,项目名称:coapp-vse,代码行数:13,代码来源:CoAppApplication.cs

示例3: CurrentDomain_AssemblyResolve

        static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            if (!args.Name.StartsWith(prefix))
                return null;

            var name = new AssemblyName(args.Name.Substring(prefix.Length));
            if (name.GetPublicKeyToken() != null && name.GetPublicKeyToken().Length > 0)
                return null;
            name.SetPublicKeyToken(publicKeyToken);
            name.Version = vsVersion;
            Debug.WriteLine("Ref12: Redirecting load of " + args.Name + ",\tfrom " + (args.RequestingAssembly == null ? "(unknown)" : args.RequestingAssembly.FullName));

            return Assembly.Load(name);
        }
开发者ID:jerriclynsjohn,项目名称:Ref12,代码行数:14,代码来源:AssemblyRedirector.cs

示例4: TryGetPregeneratedPInvoke

        /// <summary>
        /// Returns pregenerated interop code for given PInvoke method if one exist
        /// </summary>
        public static MethodDesc TryGetPregeneratedPInvoke(MethodDesc method)
        {
            Debug.Assert(method.IsPInvoke);

            var metadataType = (MetadataType)method.OwningType;
            var module = metadataType.Module;

            var assemblyName = ((IAssemblyDesc)module).GetName();

            var interopAssemblyName = new AssemblyName();

            interopAssemblyName.Name = assemblyName.Name + AssemblyNameSuffix;
            interopAssemblyName.Version = assemblyName.Version;
            interopAssemblyName.SetPublicKeyToken(interopAssemblyName.GetPublicKeyToken());
            interopAssemblyName.CultureName = assemblyName.CultureName;
            interopAssemblyName.ContentType = assemblyName.ContentType;

            var interopModule = module.Context.ResolveAssembly(interopAssemblyName, false);
            if (interopModule == null)
                return null;

            var pregeneratedMethod = GetMatchingMethod(interopModule, method);
            if (pregeneratedMethod == null)
            {
                // TODO: Better error message
                throw new MissingMemberException("Missing method in " + interopAssemblyName.Name + ":" + method.ToString());
            }
            return pregeneratedMethod;
        }
开发者ID:pootow,项目名称:corert,代码行数:32,代码来源:McgInteropSupport.cs

示例5: AddName

        public void AddName(AssemblyName name)
        {
            ListViewItem item = new ListViewItem(name.Name);

            item.SubItems.Add(name.Version.ToString());

            StringBuilder builder = new StringBuilder();

            byte[] publicKey = name.GetPublicKeyToken();

            if (publicKey == null)
            {
                item.SubItems.Add("null");
            }
            else
            {
                foreach (byte b in publicKey)
                {
                    builder.AppendFormat("{0:X02}", b);
                }
                item.SubItems.Add(builder.ToString());
            }

            item.Tag = name;

            Items.Add(item);
        }
开发者ID:michyer,项目名称:canape,代码行数:27,代码来源:AssemblyNameListView.cs

示例6: AssemblyQualifiedNameEquals

 internal static bool AssemblyQualifiedNameEquals(Type t1, Type t2)
 {
     if (object.ReferenceEquals(t1, null))
     {
         return object.ReferenceEquals(t2, null);
     }
     if (object.ReferenceEquals(t2, null))
     {
         return false;
     }
     if (t1.FullName != t2.FullName)
     {
         return false;
     }
     if (t1.Assembly.FullName == t2.Assembly.FullName)
     {
         return true;
     }
     AssemblyName name = new AssemblyName(t1.Assembly.FullName);
     AssemblyName name2 = new AssemblyName(t2.Assembly.FullName);
     if (!(name.Name == name2.Name))
     {
         return IsWindowsBaseToSystemXamlComparison(t1.Assembly, t2.Assembly, name, name2);
     }
     return (name.CultureInfo.Equals(name2.CultureInfo) && SafeSecurityHelper.IsSameKeyToken(name.GetPublicKeyToken(), name2.GetPublicKeyToken()));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:LooseTypeExtensions.cs

示例7: SetAssemblyName

 public void SetAssemblyName(AssemblyName assemblyName)
 {
     Name = assemblyName.Name;
     Version = assemblyName.Version.ToString();
     Culture = (assemblyName.CultureInfo == null) ? string.Empty : assemblyName.CultureInfo.Name;
     PublicKeyToken = ToHexString(assemblyName.GetPublicKeyToken());
     ProcessorArchitecture = assemblyName.ProcessorArchitecture;
 }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:8,代码来源:AssemblyNameEdit.cs

示例8: MonoAssemblyName

		public MonoAssemblyName(string name, string directory)
		{
			AssemblyName assemblyName = new AssemblyName(name);
			this.name = assemblyName.Name;
			version = assemblyName.Version;
			cultureInfo = assemblyName.CultureInfo;
			publicKeyToken = assemblyName.GetPublicKeyToken();
			this.directory = directory;
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:9,代码来源:MonoAssemblyName.cs

示例9: LookupFullName

 protected string LookupFullName(string name)
 {
     AssemblyName asm = new AssemblyName(name);
     if (asm.Version != null || asm.GetPublicKeyToken() != null || asm.GetPublicKey() != null)
     {
         return name;
     }
     return _assemblyFullNames.ContainsKey(name.ToLower()) ? _assemblyFullNames[name.ToLower()] : name;
 }
开发者ID:cperler,项目名称:Python-Via-Silverlight,代码行数:9,代码来源:Keggy.xaml.cs

示例10: AssemblyNameEquals

 internal static bool AssemblyNameEquals(AssemblyName thisName, AssemblyName thatName)
 {
     if ((thisName.Name == null) || (thatName.Name == null))
     {
         return false;
     }
     if (!thatName.Name.Equals(thisName.Name))
     {
         return false;
     }
     Version version = thatName.Version;
     if (((version != null) && (version != emptyVersion)) && (version != thisName.Version))
     {
         return false;
     }
     CultureInfo cultureInfo = thatName.CultureInfo;
     if ((cultureInfo != null) && !cultureInfo.Equals(CultureInfo.InvariantCulture))
     {
         CultureInfo parent = thisName.CultureInfo;
         if (parent == null)
         {
             return false;
         }
         while (!cultureInfo.Equals(parent))
         {
             parent = parent.Parent;
             if (parent.Equals(CultureInfo.InvariantCulture))
             {
                 return false;
             }
         }
     }
     byte[] publicKeyToken = thatName.GetPublicKeyToken();
     if ((publicKeyToken != null) && (publicKeyToken.Length != 0))
     {
         byte[] buffer2 = thisName.GetPublicKeyToken();
         if (buffer2 == null)
         {
             return false;
         }
         if (publicKeyToken.Length != buffer2.Length)
         {
             return false;
         }
         for (int i = 0; i < publicKeyToken.Length; i++)
         {
             if (publicKeyToken[i] != buffer2[i])
             {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:54,代码来源:ParseHelpers.cs

示例11: TryRedirect

        private static bool TryRedirect(AssemblyName name, byte[] token, int major, int minor, int revision, int build)
        {
            var version = new Version(major, minor, revision, build);
            if (KeysEqual(name.GetPublicKeyToken(), token) && name.Version < version)
            {
                name.Version = version;
                return true;
            }

            return false;
        }
开发者ID:lachbaer,项目名称:roslyn,代码行数:11,代码来源:AssemblyResolution.cs

示例12: DefinitionIdentity

 public DefinitionIdentity(AssemblyName asmName)
 {
     this._idComPtr = System.Deployment.Internal.Isolation.IsolationInterop.IdentityAuthority.CreateDefinition();
     this["name"] = asmName.Name;
     this["version"] = asmName.Version.ToString();
     if (asmName.CultureInfo != null)
     {
         this["culture"] = asmName.CultureInfo.Name;
     }
     byte[] publicKeyToken = asmName.GetPublicKeyToken();
     if ((publicKeyToken != null) && (publicKeyToken.Length > 0))
     {
         this["publicKeyToken"] = HexString.FromBytes(publicKeyToken);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:DefinitionIdentity.cs

示例13: AssemblyName

			int IComparer.Compare(object lhs, object rhs)
			{
				AssemblyName assemblyName = new AssemblyName((string)lhs);
				AssemblyName assemblyName2 = (AssemblyName)rhs;
				int num = string.Compare(assemblyName.Name, assemblyName2.Name, StringComparison.OrdinalIgnoreCase);
				if (num != 0)
				{
					return num;
				}
				byte[] publicKeyToken = assemblyName.GetPublicKeyToken();
				byte[] publicKeyToken2 = assemblyName2.GetPublicKeyToken();
				if (publicKeyToken == null)
				{
					return -1;
				}
				if (publicKeyToken2 == null)
				{
					return 1;
				}
				if (publicKeyToken.Length < publicKeyToken2.Length)
				{
					return -1;
				}
				if (publicKeyToken.Length > publicKeyToken2.Length)
				{
					return 1;
				}
				for (int i = 0; i < publicKeyToken.Length; i++)
				{
					byte b = publicKeyToken[i];
					byte b2 = publicKeyToken2[i];
					if (b < b2)
					{
						return -1;
					}
					if (b > b2)
					{
						return 1;
					}
				}
				return 0;
			}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:42,代码来源:AppDomain.cs

示例14: AreWeReferringToTheSameAssembly

        private bool AreWeReferringToTheSameAssembly(AssemblyName simple, AssemblyName fullyQualified)
        {
            var result = simple.Name == fullyQualified.Name;
            if (simple.Version != null)
                result &= simple.Version <= fullyQualified.Version;
            if (simple.ProcessorArchitecture != ProcessorArchitecture.None)
            {
                result &= simple.ProcessorArchitecture == fullyQualified.ProcessorArchitecture;
            }

            if (simple.CultureInfo != null)
            {
                result &= simple.CultureInfo.Equals(fullyQualified.CultureInfo);
            }

            if (simple.GetPublicKeyToken() != null)
            {
                result &= simple.GetPublicKeyToken().SequenceEqual(fullyQualified.GetPublicKeyToken());
            }

            return result;
        }
开发者ID:ericschultz,项目名称:xaml-reference-fixifier,代码行数:22,代码来源:FixXAMLReferencesTask.cs

示例15: Matches

        /// <summary>
        /// Matches the name of <paramref name="assembly"/> with <paramref name="assemblyNameToMatch"/>.
        /// </summary>
        /// <param name="assembly">The assembly to match.</param>
        /// <param name="assemblyNameToMatch">The assembly name to match.</param>
        /// <returns><see langword="true"/> if the name matches; otherwise <see langword="false"/>.</returns>
        public static bool Matches(Assembly assembly, AssemblyName assemblyNameToMatch)
        {
            if (assembly == null) return false;
            if (assemblyNameToMatch == null) return false;

            var assemblyName = assembly.GetName();

            if (assemblyName.Name == assemblyNameToMatch.Name)
            {
                if (assemblyNameToMatch.Version != null &&
                    assemblyNameToMatch.Version.CompareTo(assemblyName.Version) != 0)
                {
                    return false;
                }
                byte[] requestedAsmPublicKeyToken = assemblyNameToMatch.GetPublicKeyToken();
                if (requestedAsmPublicKeyToken != null)
                {
                    byte[] cachedAssemblyPublicKeyToken = assemblyName.GetPublicKeyToken();

                    if (Convert.ToBase64String(requestedAsmPublicKeyToken) != Convert.ToBase64String(cachedAssemblyPublicKeyToken))
                    {
                        return false;
                    }
                }

                var requestedAssemblyCulture = assemblyNameToMatch.CultureInfo;
                if (requestedAssemblyCulture != null && requestedAssemblyCulture.LCID != CultureInfo.InvariantCulture.LCID)
                {
                    if (assemblyName.CultureInfo.LCID != requestedAssemblyCulture.LCID)
                    {
                        return false;
                    }
                }

                return true;
            }

            return false;
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:45,代码来源:AssemblyNameMatcher.cs


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