GetService() public method

Retrieves a service from the refactoring context. If the service is not found in the Services container.
public GetService ( Type serviceType ) : object
serviceType System.Type
return object
        protected static bool HidesMember(BaseRefactoringContext ctx, AstNode node, string variableName, out IMember member)
        {
            MemberCollectionService mcs = (MemberCollectionService)ctx.GetService(typeof(MemberCollectionService));

            if (mcs == null)
            {
                lock (ctx) {
                    if ((mcs = (MemberCollectionService)ctx.GetService(typeof(MemberCollectionService))) == null)
                    {
                        mcs = new MemberCollectionService();
                        ctx.Services.AddService(typeof(MemberCollectionService), mcs);
                    }
                }
            }

            var typeDecl = node.GetParent <TypeDeclaration>();

            member = null;
            if (typeDecl == null)
            {
                return(false);
            }
            var entityDecl          = node.GetParent <EntityDeclaration>();
            var memberResolveResult = ctx.Resolve(entityDecl) as MemberResolveResult;

            if (memberResolveResult == null)
            {
                return(false);
            }
            var typeResolveResult = ctx.Resolve(typeDecl) as TypeResolveResult;

            if (typeResolveResult == null)
            {
                return(false);
            }

            var sourceMember = memberResolveResult.Member;

            member = mcs.GetMembers(typeResolveResult.Type, variableName).FirstOrDefault(m2 => IsAccessible(sourceMember, m2));
            return(member != null);
        }
 public GatherVisitor(BaseRefactoringContext ctx, InconsistentNamingIssue inspector) : base(ctx)
 {
     this.inspector = inspector;
     service        = (NamingConventionService)ctx.GetService(typeof(NamingConventionService));
 }
Beispiel #3
0
 public GatherVisitor(BaseRefactoringContext ctx) : base(ctx)
 {
     service = (NamingConventionService)ctx.GetService(typeof(NamingConventionService));
 }
 public GatherVisitor(BaseRefactoringContext ctx)
     : base(ctx)
 {
     service = (NamingConventionService)ctx.GetService (typeof (NamingConventionService));
 }
			public GatherVisitor (BaseRefactoringContext ctx, InconsistentNamingIssue inspector) : base (ctx)
			{
				this.inspector = inspector;
				service = (NamingConventionService)ctx.GetService (typeof (NamingConventionService));
			}