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


C# AssemblyName.EndsWith方法代码示例

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


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

示例1: FindAssemblies

        public Assembly FindAssemblies(object sender, ResolveEventArgs args)
        {
            // If a linkable component loads additional assemblies OmiEd might
            // have issues resolving them
            // This will help by guessing that the additional assembly might be
            // in the same folder as the linkable component assembly and trying that.
            // Not guarantied to work but definitely does help in some cases.

            var name = new AssemblyName(args.Name).Name;

            if (name.EndsWith(".resources") || name.StartsWith("System.") || name.EndsWith(".XmlSerializers"))
            {
                // don't clutter session log with these
                return null;
            }

            Assembly assembly;
            string file;
            FileInfo fi;
            var sb = new StringBuilder();
            bool loaded = false;

            try
            {
                sb.Append(string.Format("AssemblyLoader({0}).FindAssemblies({1})",
                    _caption, name));

                if (_loaded.TryGetValue(name, out assembly))
                {
                    sb.AppendLine();
                    sb.AppendLine(string.Format("\tPreviously loaded as({0})", assembly.EscapedCodeBase));
                    return assembly;
                }

                if (args.RequestingAssembly != null)
                {
                    var uri = Utilities.AssemblyUri(args.RequestingAssembly);

                    AddSearchUri(uri);
                }

                var folderpath = string.Empty;

                foreach (string extension in _potentialAssemblyExtensions)
                {
                    file = name;

                    if (!file.EndsWith(extension))
                        file = name + extension;

                    foreach (var uri in _uris)
                    {
                        if (!Utilities.UriIsExistingFolderPath(uri, out folderpath))
                            continue;

                        fi = new FileInfo(Path.Combine(folderpath, file));

                        if (!fi.Exists)
                            continue;

                        sb.AppendLine();
                        sb.Append(string.Format("\tLoadFrom({0})", fi.FullName));

                        assembly = Assembly.LoadFrom(fi.FullName);

                        if (assembly != null)
                        {
                            loaded = true;

                            _loaded.Add(name, assembly);

                            return assembly;
                        }
                    }
                }

                return null;
            }
            finally
            {
                if (args.RequestingAssembly != null)
                    sb.AppendFormat("\t\tRequestingAssembly\r\n\t\t\t{0}\r\n\t\t\t{1}\r\n",
                        args.RequestingAssembly.FullName,
                        args.RequestingAssembly.CodeBase);

                if (loaded)
                    Trace.TraceInformation(sb.ToString());
                else
                {
                    sb.Append(", unfound");
                    Trace.TraceWarning(sb.ToString());
                }
            }
        }
开发者ID:CNH-Hyper-Extractive,项目名称:parallel-sdk,代码行数:94,代码来源:AssemblyLoader.cs

示例2: HandlerImpl

        private Assembly HandlerImpl(object sender, ResolveEventArgs args) {
            if (_ignore) return null;

            var id = new AssemblyName(args.Name).Name;

            Assembly result;
            if (_cached.TryGetValue(id, out result)) return result;
            
            if (string.Equals(id, "System.Web", StringComparison.OrdinalIgnoreCase)) {
                if (MessageBox.Show("Looks like you don’t have .NET 4.5.2 installed. Would you like to install it?", "Error",
                        MessageBoxButton.YesNo, MessageBoxImage.Asterisk) == MessageBoxResult.Yes) {
                    Process.Start("http://www.microsoft.com/en-us/download/details.aspx?id=42642");
                }

                Environment.Exit(10);
            }

#if LOCALIZABLE
            if (name == "Content Manager.resources" && _first) {
                Log(">> Content Manager.resources <<");
                return null;
            }

            if (name.EndsWith(".resources")) {
                var culture = splitted.ElementAtOrDefault(2)?.Split(new[] { "Culture=" }, StringSplitOptions.None).ElementAtOrDefault(1);
                Log("culture: " + culture);
                if (culture == "neutral") return null;

                var resourceId = CultureInfo.CurrentUICulture.IetfLanguageTag;
                if (!string.Equals(resourceId, "en-US", StringComparison.OrdinalIgnoreCase)) {
                    name = name.Replace(".resources", "." + resourceId);
                    Log("localized: " + name);
                } else {
                    Log("skip: " + args.Name);
                    return null;
                }
            }
#else
            if (id.StartsWith("PresentationFramework") || id.EndsWith(".resources")) return null;
#endif

            if (id == "Magick.NET-x86") return null;

            if (_logFilename != null) {
                Log("Resolve: " + args.Name + " as " + id);
            }

            try {
                _ignore = true;
                result = Extract(id);

                if (OptionCache) {
                    _cached[id] = result;
                }

                return result;
            } finally {
                _ignore = false;
            }
        }
开发者ID:gro-ove,项目名称:actools,代码行数:60,代码来源:PackedHelper.cs


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