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


C# INameService.RandomName方法代码示例

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


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

示例1: PreRename

        public void PreRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
        {
            var module = def as ModuleDefMD;
            if (module == null || !parameters.GetParameter<bool>(context, def, "renXaml", true))
                return;

            var wpfResInfo = context.Annotations.Get<Dictionary<string, Dictionary<string, BamlDocument>>>(module, BAMLKey);
            if (wpfResInfo == null)
                return;

            foreach (var res in wpfResInfo.Values)
                foreach (var doc in res.Values) {
                    List<IBAMLReference> references;
                    if (bamlRefs.TryGetValue(doc.DocumentName, out references)) {
                        var newName = doc.DocumentName.ToUpperInvariant();

                        #region old code

                        //if (newName.EndsWith(".BAML"))
                        //    newName = service.RandomName(RenameMode.Letters).ToLowerInvariant() + ".baml";
                        //else if (newName.EndsWith(".XAML"))
                        //    newName = service.RandomName(RenameMode.Letters).ToLowerInvariant() + ".xaml";

                        #endregion

                        #region Niks patch fix

                        /*
                         * Nik's patch for maintaining relative paths. If the xaml file is referenced in this manner
                         * "/some.namespace;component/somefolder/somecontrol.xaml"
                         * then we want to keep the relative path and namespace intact. We should be obfuscating it like this - /some.namespace;component/somefolder/asjdjh2398498dswk.xaml
                        * */

                        string[] completePath = newName.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                        string newShinyName = string.Empty;
                        for (int i = 0; i <= completePath.Length - 2; i++) {
                            newShinyName += completePath[i].ToLowerInvariant() + "/";
                        }
                        if (newName.EndsWith(".BAML"))
                            newName = newShinyName + service.RandomName(RenameMode.Letters).ToLowerInvariant() + ".baml";
                        else if (newName.EndsWith(".XAML"))
                            newName = newShinyName + service.RandomName(RenameMode.Letters).ToLowerInvariant() + ".xaml";

                        context.Logger.Debug(String.Format("Preserving virtual paths. Replaced {0} with {1}", doc.DocumentName, newName));

                        #endregion

                        bool renameOk = true;
                        foreach (var bamlRef in references)
                            if (!bamlRef.CanRename(doc.DocumentName, newName)) {
                                renameOk = false;
                                break;
                            }

                        if (renameOk) {
                            foreach (var bamlRef in references)
                                bamlRef.Rename(doc.DocumentName, newName);
                            doc.DocumentName = newName;
                        }
                    }
                }
        }
开发者ID:RSchwoerer,项目名称:ConfuserEx,代码行数:62,代码来源:WPFAnalyzer.cs

示例2: PreRename

        public void PreRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
        {
            var module = def as ModuleDefMD;
            if (module == null || !parameters.GetParameter<bool>(context, def, "renXaml", true))
                return;

            var wpfResInfo = context.Annotations.Get<Dictionary<string, Dictionary<string, BamlDocument>>>(module, BAMLKey);
            if (wpfResInfo == null)
                return;

            foreach (var res in wpfResInfo.Values)
                foreach (var doc in res.Values) {
                    List<IBAMLReference> references;
                    if (bamlRefs.TryGetValue(doc.DocumentName, out references)) {
                        var newName = doc.DocumentName.ToUpperInvariant();
                        if (newName.EndsWith(".BAML"))
                            newName = service.RandomName(RenameMode.Letters).ToLowerInvariant() + ".baml";
                        else if (newName.EndsWith(".XAML"))
                            newName = service.RandomName(RenameMode.Letters).ToLowerInvariant() + ".xaml";

                        bool renameOk = true;
                        foreach (var bamlRef in references)
                            if (!bamlRef.CanRename(doc.DocumentName, newName)) {
                                renameOk = false;
                                break;
                            }

                        if (renameOk) {
                            foreach (var bamlRef in references)
                                bamlRef.Rename(doc.DocumentName, newName);
                            doc.DocumentName = newName;
                        }
                    }
                }
        }
开发者ID:Praetorian11,项目名称:ConfuserEx,代码行数:35,代码来源:WPFAnalyzer.cs


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