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


C# AssemblyName.IsSystemAssembly方法代码示例

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


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

示例1: ResolveFrameworkAssemblyVersioning

        /// <summary>
        /// An event handler for resolving Silverlight framework assembly versioning.
        /// </summary>
        /// <remarks>
        /// When a previous version of a Silverlight assembly is sought, the targeted version
        /// of that Silverlight assembly will be returned.
        /// </remarks>
        /// <param name="sender">The event sender.</param>
        /// <param name="args">The assembly resolution event arguments.</param>
        /// <returns>The <see cref="Assembly"/> from the targeted version of Silverlight, or <c>null</c>.</returns>
        private static Assembly ResolveFrameworkAssemblyVersioning(object sender, ResolveEventArgs args)
        {
            FrameworkManifest frameworkManifest = (FrameworkManifest)AppDomain.CurrentDomain.GetData(AppDomainUtilities.FrameworkManifestKey);
            System.Diagnostics.Debug.Assert(frameworkManifest != null, "The FrameworkManifest must have been set on the AppDomain");

            AssemblyName requestedAssembly = new AssemblyName(args.Name);

            // If the requested assembly is a System assembly and it's an older version
            // than the framework manifest has, then we'll need to resolve to its newer version
            bool isOldVersion = requestedAssembly.Version.CompareTo(frameworkManifest.SystemVersion) < 0;

            if (isOldVersion && requestedAssembly.IsSystemAssembly())
            {
                // Now we need to see if the requested assembly is part of the framework manifest (as opposed to an SDK assembly)
                var silverlightAssembly = (from assembly in frameworkManifest.Assemblies
                                           where assembly.Name == requestedAssembly.Name
                                           select assembly).SingleOrDefault();

                // If the assembly is part of the framework manifest, then we need to "redirect" its resolution
                // to the current framework version.
                if (silverlightAssembly != null)
                {
                    // Find the Silverlight framework assembly from the already-loaded assemblies
                    var matches = from assembly in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()
                                  let assemblyName = assembly.GetName()
                                  where assemblyName.Name == silverlightAssembly.Name
                                     && assemblyName.GetPublicKeyToken().SequenceEqual(silverlightAssembly.PublicKeyTokenBytes)
                                     && assemblyName.Version.CompareTo(silverlightAssembly.Version) == 0
                                  select assembly;

                    return matches.SingleOrDefault();
                }
            }

            return null;
        }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:46,代码来源:AppDomainUtilities.cs


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