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


C# INameService类代码示例

本文整理汇总了C#中INameService的典型用法代码示例。如果您正苦于以下问题:C# INameService类的具体用法?C# INameService怎么用?C# INameService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


INameService类属于命名空间,在下文中一共展示了INameService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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