本文整理汇总了C#中INameService类的典型用法代码示例。如果您正苦于以下问题:C# INameService类的具体用法?C# INameService怎么用?C# INameService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
INameService类属于命名空间,在下文中一共展示了INameService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Analyze
// i.e. Inter-Assembly References, e.g. InternalVisibleToAttributes
public void Analyze(ConfuserContext context, INameService service, IDnlibDef def)
{
var module = def as ModuleDefMD;
if (module == null) return;
MDTable table;
uint len;
// MemberRef
table = module.TablesStream.Get(Table.MemberRef);
len = table.Rows;
for (uint i = 1; i <= len; i++) {
MemberRef memberRef = module.ResolveMemberRef(i);
TypeDef declType = memberRef.DeclaringType.ResolveTypeDefThrow();
if (declType.Module != module && context.Modules.Contains((ModuleDefMD)declType.Module)) {
var memberDef = (IDnlibDef)declType.ResolveThrow(memberRef);
service.AddReference(memberDef, new MemberRefReference(memberRef, memberDef));
}
}
// TypeRef
table = module.TablesStream.Get(Table.TypeRef);
len = table.Rows;
for (uint i = 1; i <= len; i++) {
TypeRef typeRef = module.ResolveTypeRef(i);
TypeDef typeDef = typeRef.ResolveTypeDefThrow();
if (typeDef.Module != module && context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
service.AddReference(typeDef, new TypeRefReference(typeRef, typeDef));
}
}
}
开发者ID:GavinHwa,项目名称:ConfuserEx,代码行数:34,代码来源:InterReferenceAnalyzer.cs
示例2: AXAClaimController
public AXAClaimController(IUnityContainer unityContainer, IClaimClientService claimClientService, IMetadataClientService metadataClientService, ApplicationModel applicationModel, AXAClaimModel claimModel, ClaimsPayloadManager claimPayloadManager, ClaimsRetrievalManager claimsRetrievalManager, IClaimNameSearchHandler claimNameSearchHandler, AppModel appModel, IClaimViewResolver viewResolver, AXAClaimAmountHistoryController claimAmountHistoryController, ISearchServiceHandler searchService, IClaimTreeviewResolver treeviewResolver, INameService nameService, IEventAggregator eventAggregator, IShellRulesHelper rulesHelper, IClaimsCodeLookupService claimscodelookupservice)
: base(claimClientService, metadataClientService, claimModel, claimPayloadManager, claimsRetrievalManager, claimNameSearchHandler, appModel, viewResolver, claimAmountHistoryController, treeviewResolver, eventAggregator, rulesHelper, searchService, unityContainer, claimscodelookupservice)
{
this.appModel = appModel;
this._gdiModel = Container.Resolve<AXAGenericDataItemModel>();
this.claimModel = claimModel;
this.claimModel.GenericDataItemModel = this._gdiModel;
this._payloadManager = claimPayloadManager;
this._nameSearchHandler = claimNameSearchHandler;
this.claimModel.ReloadTotals += new EventHandler(this.Model_ReloadTotals);
this.claimModel.ReloadClaimants += new EventHandler(this.ClaimModel_ReloadClaimants);
this.claimModel.DuplicateClaimCheckClick += new EventHandler<XIAP.Frontend.Infrastructure.Events.CommandEventArgs<ClaimHeaderDto>>(this.ClaimModel_DuplicateClaimCheckClick);
this.claimModel.CustomCoverageVerification += new EventHandler(this.ClaimModel_CustomCoverageVerification);
this.claimModel.NameInvolvementModel.GetNameForNameInvolvement += new EventHandler(this.NameInvolvementModel_GetNameForNameInvolvement);
this.searchService = searchService;
this.claimModel.TargetHeaderStatusCodeChanged += new EventHandler(this.ClaimModel_TargetHeaderStatusCodeChanged);
this._genericDataSetBuilder = new ClaimsDataBuilder(claimPayloadManager);
this._gdsController = new AXAGenericDataSetController((ClaimControllerBase<ClaimModel>)this, claimModel, this._gdiModel, this.Container, metadataClientService, this._genericDataSetBuilder);
this.SetNumberOfGenericDataItemNodesToBeLoaded();
this._nameService = nameService;
this.claimModel.ValidateClaim += new EventHandler(this.ClaimModel_ValidateClaim);
this.claimAmountHistoryController = claimAmountHistoryController;
this.claimAmountHistoryController.OnPaymentCancellation += new EventHandler(this.ClaimAmountHistoryController_OnPaymentCancellation);
(this.claimModel.DocumentModel as AXADocumentModel).OnSaveClick += new EventHandler(this.AXAClaimController_OnSaveClick);
this.retrievalManager = claimsRetrievalManager;
(this.claimModel.DocumentModel as AXADocumentModel).RetrievalManager = claimsRetrievalManager;
this.Model.HeaderPropertyChanged += new EventHandler<PropertyChangedEventArgs>(this.AXAClaimController_HeaderPropertyChanged);
this.claimModel.OnINACTReviewClick += new EventHandler(this.ClaimModel_OnINACTReviewClick);
this.claimModel.OnInactRecoveryReviewClick += new EventHandler(this.ClaimModel_OnInactRecoveryReviewClick);
}
开发者ID:victorxata,项目名称:261120,代码行数:30,代码来源:AXAClaimController.cs
示例3: Analyze
// i.e. Inter-Assembly References, e.g. InternalVisibleToAttributes
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
{
var module = def as ModuleDefMD;
if (module == null) return;
// MemberRef/MethodSpec
var methods = module.GetTypes().SelectMany(type => type.Methods);
foreach(var methodDef in methods) {
foreach (var ov in methodDef.Overrides) {
ProcessMemberRef(context, service, module, ov.MethodBody);
ProcessMemberRef(context, service, module, ov.MethodDeclaration);
}
if (!methodDef.HasBody)
continue;
foreach (var instr in methodDef.Body.Instructions) {
if (instr.Operand is MemberRef || instr.Operand is MethodSpec)
ProcessMemberRef(context, service, module, (IMemberRef)instr.Operand);
}
}
// TypeRef
var table = module.TablesStream.Get(Table.TypeRef);
uint len = table.Rows;
for (uint i = 1; i <= len; i++) {
TypeRef typeRef = module.ResolveTypeRef(i);
TypeDef typeDef = typeRef.ResolveTypeDefThrow();
if (typeDef.Module != module && context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
service.AddReference(typeDef, new TypeRefReference(typeRef, typeDef));
}
}
}
开发者ID:ReyAleman,项目名称:ConfuserEx,代码行数:34,代码来源:InterReferenceAnalyzer.cs
示例4: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) {
var method = def as MethodDef;
if (method == null || !method.HasBody)
return;
// When a ldtoken instruction reference a definition,
// most likely it would be used in reflection and thus probably should not be renamed.
// Also, when ToString is invoked on enum,
// the enum should not be renamed.
for (int i = 0; i < method.Body.Instructions.Count; i++) {
Instruction instr = method.Body.Instructions[i];
if (instr.OpCode.Code == Code.Ldtoken) {
if (instr.Operand is MemberRef) {
IMemberForwarded member = ((MemberRef)instr.Operand).ResolveThrow();
if (context.Modules.Contains((ModuleDefMD)member.Module))
service.SetCanRename(member, false);
}
else if (instr.Operand is IField) {
FieldDef field = ((IField)instr.Operand).ResolveThrow();
if (context.Modules.Contains((ModuleDefMD)field.Module))
service.SetCanRename(field, false);
}
else if (instr.Operand is IMethod) {
var im = (IMethod)instr.Operand;
if (!im.IsArrayAccessors()) {
MethodDef m = im.ResolveThrow();
if (context.Modules.Contains((ModuleDefMD)m.Module))
service.SetCanRename(method, false);
}
}
else if (instr.Operand is ITypeDefOrRef) {
if (!(instr.Operand is TypeSpec)) {
TypeDef type = ((ITypeDefOrRef)instr.Operand).ResolveTypeDefThrow();
if (context.Modules.Contains((ModuleDefMD)type.Module) &&
HandleTypeOf(context, service, method, i)) {
var t = type;
do {
DisableRename(service, t, false);
t = t.DeclaringType;
} while (t != null);
}
}
}
else
throw new UnreachableException();
}
else if ((instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt) &&
((IMethod)instr.Operand).Name == "ToString") {
HandleEnum(context, service, method, i);
}
else if (instr.OpCode.Code == Code.Ldstr) {
TypeDef typeDef = method.Module.FindReflection((string)instr.Operand);
if (typeDef != null)
service.AddReference(typeDef, new StringTypeReference(instr, typeDef));
}
}
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:57,代码来源:LdtokenEnumAnalyzer.cs
示例5: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
{
if (def is TypeDef)
Analyze(context, service, (TypeDef)def, parameters);
else if (def is MethodDef)
Analyze(context, service, (MethodDef)def, parameters);
else if (def is PropertyDef)
Analyze(context, service, (PropertyDef)def, parameters);
else if (def is FieldDef)
Analyze(context, service, (FieldDef)def, parameters);
}
开发者ID:RSchwoerer,项目名称:ConfuserEx,代码行数:11,代码来源:JsonAnalyzer.cs
示例6: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
{
var module = def as ModuleDef;
if (module == null) return;
string asmName = module.Assembly.Name.String;
if (!string.IsNullOrEmpty(module.Assembly.Culture) &&
asmName.EndsWith(".resources")) {
// Satellite assembly
var satellitePattern = new Regex(string.Format("^(.*)\\.{0}\\.resources$", module.Assembly.Culture));
string nameAsmName = asmName.Substring(0, asmName.Length - ".resources".Length);
ModuleDef mainModule = context.Modules.SingleOrDefault(mod => mod.Assembly.Name == nameAsmName);
if (mainModule == null) {
context.Logger.ErrorFormat("Could not find main assembly of satellite assembly '{0}'.", module.Assembly.FullName);
throw new ConfuserException(null);
}
string format = "{0}." + module.Assembly.Culture + ".resources";
foreach (Resource res in module.Resources) {
Match match = satellitePattern.Match(res.Name);
if (!match.Success)
continue;
string typeName = match.Groups[1].Value;
TypeDef type = mainModule.FindReflectionThrow(typeName);
if (type == null) {
context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName);
continue;
}
service.ReduceRenameMode(type, RenameMode.ASCII);
service.AddReference(type, new ResourceReference(res, type, format));
}
}
else {
string format = "{0}.resources";
foreach (Resource res in module.Resources) {
Match match = ResourceNamePattern.Match(res.Name);
if (!match.Success)
continue;
string typeName = match.Groups[1].Value;
if (typeName.EndsWith(".g")) // WPF resources, ignore
continue;
TypeDef type = module.FindReflection(typeName);
if (type == null) {
context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName);
continue;
}
service.ReduceRenameMode(type, RenameMode.ASCII);
service.AddReference(type, new ResourceReference(res, type, format));
}
}
}
开发者ID:MulleDK19,项目名称:ConfuserEx,代码行数:53,代码来源:ResourceAnalyzer.cs
示例7: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) {
var method = def as MethodDef;
if (method != null) {
if (!method.HasBody)
return;
AnalyzeMethod(context, service, method);
}
var module = def as ModuleDefMD;
if (module != null) {
AnalyzeResources(context, service, module);
}
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:13,代码来源:WPFAnalyzer.cs
示例8: When_initialize_viewmodel
public When_initialize_viewmodel()
{
// Setup test service with dummy data
_service = Substitute.For<INameService>();
_service.GetNames().Returns(Task.FromResult(new[] { "Hello", "World" }.AsEnumerable()));
var testScheduler = new TestScheduler();
_sut = new MainWindowViewModel(AsyncMethod.OnScheduler, _service, testScheduler);
_sut.Initialize();
// The service has been subscribed to and everything is setup - just need kick it off
testScheduler.Start();
}
开发者ID:niallmcdermott4,项目名称:RxSample,代码行数:14,代码来源:Test.cs
示例9: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) {
if (def is ModuleDef) {
foreach (var type in ((ModuleDef)def).GetTypes())
foreach (var prop in type.Properties)
properties.AddListEntry(prop.Name, prop);
return;
}
var method = def as MethodDef;
if (method == null || !method.HasBody)
return;
AnalyzeMethod(context, service, method);
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:14,代码来源:WinFormsAnalyzer.cs
示例10: PostRename
public void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
{
var module = def as ModuleDefMD;
if (module == null)
return;
var wpfResInfo = context.Annotations.Get<Dictionary<string, Dictionary<string, BamlDocument>>>(module, BAMLKey);
if (wpfResInfo == null)
return;
foreach (EmbeddedResource res in module.Resources.OfType<EmbeddedResource>())
{
Dictionary<string, BamlDocument> resInfo;
if (!wpfResInfo.TryGetValue(res.Name, out resInfo))
continue;
var stream = new MemoryStream();
var writer = new ResourceWriter(stream);
res.Data.Position = 0;
var reader = new ResourceReader(new ImageStream(res.Data));
IDictionaryEnumerator enumerator = reader.GetEnumerator();
while (enumerator.MoveNext())
{
var name = (string)enumerator.Key;
string typeName;
byte[] data;
reader.GetResourceData(name, out typeName, out data);
BamlDocument document;
if (resInfo.TryGetValue(name, out document))
{
var docStream = new MemoryStream();
docStream.Position = 4;
BamlWriter.WriteDocument(document, docStream);
docStream.Position = 0;
docStream.Write(BitConverter.GetBytes((int)docStream.Length - 4), 0, 4);
data = docStream.ToArray();
name = document.DocumentName;
}
writer.AddResourceData(name, typeName, data);
}
writer.Generate();
res.Data = MemoryImageStream.Create(stream.ToArray());
}
}
开发者ID:nik-net,项目名称:ConfuserEx,代码行数:48,代码来源:WPFAnalyzer.cs
示例11: ProcessMemberRef
void ProcessMemberRef(ConfuserContext context, INameService service, ModuleDefMD module, IMemberRef r) {
var memberRef = r as MemberRef;
if (r is MethodSpec)
memberRef = ((MethodSpec)r).Method as MemberRef;
if (memberRef != null) {
if (memberRef.DeclaringType.TryGetArraySig() != null)
return;
TypeDef declType = memberRef.DeclaringType.ResolveTypeDefThrow();
if (declType.Module != module && context.Modules.Contains((ModuleDefMD)declType.Module)) {
var memberDef = (IDnlibDef)declType.ResolveThrow(memberRef);
service.AddReference(memberDef, new MemberRefReference(memberRef, memberDef));
}
}
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:16,代码来源:InterReferenceAnalyzer.cs
示例12: HandleEnum
void HandleEnum(ConfuserContext context, INameService service, MethodDef method, int index) {
var target = (IMethod)method.Body.Instructions[index].Operand;
if (target.FullName == "System.String System.Object::ToString()" ||
target.FullName == "System.String System.Enum::ToString(System.String)") {
int prevIndex = index - 1;
while (prevIndex >= 0 && method.Body.Instructions[prevIndex].OpCode.Code == Code.Nop)
prevIndex--;
if (prevIndex < 0)
return;
Instruction prevInstr = method.Body.Instructions[prevIndex];
TypeSig targetType;
if (prevInstr.Operand is MemberRef) {
var memberRef = (MemberRef)prevInstr.Operand;
targetType = memberRef.IsFieldRef ? memberRef.FieldSig.Type : memberRef.MethodSig.RetType;
}
else if (prevInstr.Operand is IField)
targetType = ((IField)prevInstr.Operand).FieldSig.Type;
else if (prevInstr.Operand is IMethod)
targetType = ((IMethod)prevInstr.Operand).MethodSig.RetType;
else if (prevInstr.Operand is ITypeDefOrRef)
targetType = ((ITypeDefOrRef)prevInstr.Operand).ToTypeSig();
else if (prevInstr.GetParameter(method.Parameters) != null)
targetType = prevInstr.GetParameter(method.Parameters).Type;
else if (prevInstr.GetLocal(method.Body.Variables) != null)
targetType = prevInstr.GetLocal(method.Body.Variables).Type;
else
return;
ITypeDefOrRef targetTypeRef = targetType.ToBasicTypeDefOrRef();
if (targetTypeRef == null)
return;
TypeDef targetTypeDef = targetTypeRef.ResolveTypeDefThrow();
if (targetTypeDef != null && targetTypeDef.IsEnum && context.Modules.Contains((ModuleDefMD)targetTypeDef.Module))
DisableRename(service, targetTypeDef);
}
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:45,代码来源:LdtokenEnumAnalyzer.cs
示例13: DisableRename
void DisableRename(INameService service, TypeDef typeDef, bool memberOnly = true)
{
service.SetCanRename(typeDef, false);
foreach (MethodDef m in typeDef.Methods)
service.SetCanRename(m, false);
foreach (FieldDef field in typeDef.Fields)
service.SetCanRename(field, false);
foreach (PropertyDef prop in typeDef.Properties)
service.SetCanRename(prop, false);
foreach (EventDef evt in typeDef.Events)
service.SetCanRename(evt, false);
foreach (TypeDef nested in typeDef.NestedTypes)
DisableRename(service, nested, false);
}
开发者ID:cybercircuits,项目名称:ConfuserEx,代码行数:19,代码来源:LdtokenEnumAnalyzer.cs
示例14: Analyze
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) {
var type = def as TypeDef;
if (type == null || type.DeclaringType != null)
return;
if (type.Name.Contains("ViewModel")) {
string viewNs = type.Namespace.Replace("ViewModels", "Views");
string viewName = type.Name.Replace("PageViewModel", "Page").Replace("ViewModel", "View");
TypeDef view = type.Module.Find(viewNs + "." + viewName, true);
if (view != null) {
service.SetCanRename(type, false);
service.SetCanRename(view, false);
}
// Test for Multi-view
string multiViewNs = type.Namespace + "." + type.Name.Replace("ViewModel", "");
foreach (var t in type.Module.Types)
if (t.Namespace == multiViewNs) {
service.SetCanRename(type, false);
service.SetCanRename(t, false);
}
}
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:22,代码来源:CaliburnAnalyzer.cs
示例15: AXADocumentDataController
public AXADocumentDataController(IUnityContainer container, DocumentDataModel model, INameService nameService, AppModel appModel, IShellRulesHelper rulesHelper)
: base(model, nameService, appModel, rulesHelper, container)
{
}
开发者ID:victorxata,项目名称:261120,代码行数:4,代码来源:AXADocumentDataController.cs
示例16: BAMLAnalyzer
public BAMLAnalyzer(ConfuserContext context, INameService service)
{
this.context = context;
this.service = service;
PreInit();
}
开发者ID:2sic4you,项目名称:ConfuserEx,代码行数:6,代码来源:BAMLAnalyzer.cs
示例17: AnalyzeResources
void AnalyzeResources(ConfuserContext context, INameService service, ModuleDefMD module)
{
if (analyzer == null) {
analyzer = new BAMLAnalyzer(context, service);
analyzer.AnalyzeElement += AnalyzeBAMLElement;
}
var wpfResInfo = new Dictionary<string, Dictionary<string, BamlDocument>>();
foreach (EmbeddedResource res in module.Resources.OfType<EmbeddedResource>()) {
Match match = ResourceNamePattern.Match(res.Name);
if (!match.Success)
continue;
var resInfo = new Dictionary<string, BamlDocument>();
res.Data.Position = 0;
var reader = new ResourceReader(new ImageStream(res.Data));
IDictionaryEnumerator enumerator = reader.GetEnumerator();
while (enumerator.MoveNext()) {
var name = (string)enumerator.Key;
if (!name.EndsWith(".baml"))
continue;
string typeName;
byte[] data;
reader.GetResourceData(name, out typeName, out data);
BamlDocument document = analyzer.Analyze(module, name, data);
document.DocumentName = name;
resInfo.Add(name, document);
}
if (resInfo.Count > 0)
wpfResInfo.Add(res.Name, resInfo);
}
if (wpfResInfo.Count > 0)
context.Annotations.Set(module, BAMLKey, wpfResInfo);
}
开发者ID:RSchwoerer,项目名称:ConfuserEx,代码行数:38,代码来源:WPFAnalyzer.cs
示例18: AnalyzeMethod
void AnalyzeMethod(ConfuserContext context, INameService service, MethodDef method)
{
var dpRegInstrs = new List<Tuple<bool, Instruction>>();
var routedEvtRegInstrs = new List<Instruction>();
for (int i = 0; i < method.Body.Instructions.Count; i++) {
Instruction instr = method.Body.Instructions[i];
if ((instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt)) {
var regMethod = (IMethod)instr.Operand;
if (regMethod.DeclaringType.FullName == "System.Windows.DependencyProperty" &&
regMethod.Name.String.StartsWith("Register")) {
dpRegInstrs.Add(Tuple.Create(regMethod.Name.String.StartsWith("RegisterAttached"), instr));
}
else if (regMethod.DeclaringType.FullName == "System.Windows.EventManager" &&
regMethod.Name.String == "RegisterRoutedEvent") {
routedEvtRegInstrs.Add(instr);
}
}
else if (instr.OpCode.Code == Code.Newobj) {
var methodRef = (IMethod)instr.Operand;
if (methodRef.DeclaringType.FullName == "System.Windows.Data.PropertyGroupDescription" &&
methodRef.Name == ".ctor" && i - 1 >= 0 && method.Body.Instructions[i - 1].OpCode.Code == Code.Ldstr) {
foreach (var property in analyzer.LookupProperty((string)method.Body.Instructions[i - 1].Operand))
service.SetCanRename(property, false);
}
}
else if (instr.OpCode == OpCodes.Ldstr) {
var operand = ((string)instr.Operand).ToUpperInvariant();
if (operand.EndsWith(".BAML") || operand.EndsWith(".XAML")) {
var match = UriPattern.Match(operand);
if (match.Success)
operand = match.Groups[1].Value;
else if (operand.Contains("/"))
context.Logger.WarnFormat("Fail to extract XAML name from '{0}'.", instr.Operand);
var reference = new BAMLStringReference(instr);
operand = operand.TrimStart('/');
var baml = operand.Substring(0, operand.Length - 5) + ".BAML";
var xaml = operand.Substring(0, operand.Length - 5) + ".XAML";
bamlRefs.AddListEntry(baml, reference);
bamlRefs.AddListEntry(xaml, reference);
}
}
}
if (dpRegInstrs.Count == 0)
return;
var traceSrv = context.Registry.GetService<ITraceService>();
MethodTrace trace = traceSrv.Trace(method);
bool erred = false;
foreach (var instrInfo in dpRegInstrs) {
int[] args = trace.TraceArguments(instrInfo.Item2);
if (args == null) {
if (!erred)
context.Logger.WarnFormat("Failed to extract dependency property name in '{0}'.", method.FullName);
erred = true;
continue;
}
Instruction ldstr = method.Body.Instructions[args[0]];
if (ldstr.OpCode.Code != Code.Ldstr) {
if (!erred)
context.Logger.WarnFormat("Failed to extract dependency property name in '{0}'.", method.FullName);
erred = true;
continue;
}
var name = (string)ldstr.Operand;
TypeDef declType = method.DeclaringType;
bool found = false;
if (instrInfo.Item1) // Attached DP
{
MethodDef accessor;
if ((accessor = declType.FindMethod("Get" + name)) != null && accessor.IsStatic) {
service.SetCanRename(accessor, false);
found = true;
}
if ((accessor = declType.FindMethod("Set" + name)) != null && accessor.IsStatic) {
service.SetCanRename(accessor, false);
found = true;
}
}
// Normal DP
// Find CLR property for attached DP as well, because it seems attached DP can be use as normal DP as well.
PropertyDef property = null;
if ((property = declType.FindProperty(name)) != null) {
service.SetCanRename(property, false);
found = true;
if (property.GetMethod != null)
service.SetCanRename(property.GetMethod, false);
if (property.SetMethod != null)
service.SetCanRename(property.SetMethod, false);
if (property.HasOtherMethods) {
foreach (MethodDef accessor in property.OtherMethods)
//.........这里部分代码省略.........
开发者ID:RSchwoerer,项目名称:ConfuserEx,代码行数:101,代码来源:WPFAnalyzer.cs
示例19: 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
示例20: Analyze
public void Analyze(ConfuserContext context, INameService service, IDnlibDef def)
{
var module = def as ModuleDefMD;
if (module == null) return;
MDTable table;
uint len;
// MemberRef
table = module.TablesStream.Get(Table.Method);
len = table.Rows;
IEnumerable<MethodDef> methods = Enumerable.Range(1, (int)len)
.Select(rid => module.ResolveMethod((uint)rid));
foreach (MethodDef method in methods) {
foreach (MethodOverride methodImpl in method.Overrides) {
if (methodImpl.MethodBody is MemberRef)
AnalyzeMemberRef(context, service, (MemberRef)methodImpl.MethodBody);
if (methodImpl.MethodDeclaration is MemberRef)
AnalyzeMemberRef(context, service, (MemberRef)methodImpl.MethodDeclaration);
}
if (!method.HasBody)
continue;
foreach (Instruction instr in method.Body.Instructions) {
if (instr.Operand is MemberRef)
AnalyzeMemberRef(context, service, (MemberRef)instr.Operand);
else if (instr.Operand is MethodSpec) {
var spec = (MethodSpec)instr.Operand;
if (spec.Method is MemberRef)
AnalyzeMemberRef(context, service, (MemberRef)spec.Method);
}
}
}
// CustomAttribute
table = module.TablesStream.Get(Table.CustomAttribute);
len = table.Rows;
IEnumerable<CustomAttribute> attrs = Enumerable.Range(1, (int)len)
.Select(rid => module.ResolveHasCustomAttribute(module.TablesStream.ReadCustomAttributeRow((uint)rid).Parent))
.Distinct()
.SelectMany(owner => owner.CustomAttributes);
foreach (CustomAttribute attr in attrs) {
if (attr.Constructor is MemberRef)
AnalyzeMemberRef(context, service, (MemberRef)attr.Constructor);
foreach (CAArgument arg in attr.ConstructorArguments)
AnalyzeCAArgument(context, service, arg);
foreach (CANamedArgument arg in attr.Fields)
AnalyzeCAArgument(context, service, arg.Argument);
foreach (CANamedArgument arg in attr.Properties)
AnalyzeCAArgument(context, service, arg.Argument);
TypeDef attrType = attr.AttributeType.ResolveTypeDefThrow();
if (!context.Modules.Contains((ModuleDefMD)attrType.Module))
continue;
foreach (CANamedArgument fieldArg in attr.Fields) {
FieldDef field = attrType.FindField(fieldArg.Name, new FieldSig(fieldArg.Type));
if (field == null)
context.Logger.WarnFormat("Failed to resolve CA field '{0}::{1} : {2}'.", attrType, fieldArg.Name, fieldArg.Type);
else
service.AddReference(field, new CAMemberReference(fieldArg, field));
}
foreach (CANamedArgument propertyArg in attr.Properties) {
PropertyDef property = attrType.FindProperty(propertyArg.Name, new PropertySig(true, propertyArg.Type));
if (property == null)
context.Logger.WarnFormat("Failed to resolve CA property '{0}::{1} : {2}'.", attrType, propertyArg.Name, propertyArg.Type);
else
service.AddReference(property, new CAMemberReference(propertyArg, property));
}
}
}
开发者ID:MetSystem,项目名称:ConfuserEx,代码行数:73,代码来源:TypeBlobAnalyzer.cs
注:本文中的INameService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论