ICSharpCode.NRefactory.CSharp.Resolver.FindReferences.RenameReferencesInFile C# (CSharp) Méthode

RenameReferencesInFile() public méthode

public RenameReferencesInFile ( IList searchScopes, string newName, ICSharpCode.NRefactory.CSharp.Resolver.CSharpAstResolver resolver, Action callback, Action errorCallback, CancellationToken cancellationToken = default(CancellationToken) ) : void
searchScopes IList
newName string
resolver ICSharpCode.NRefactory.CSharp.Resolver.CSharpAstResolver
callback Action
errorCallback Action
cancellationToken System.Threading.CancellationToken
Résultat void
		public void RenameReferencesInFile(IList<IFindReferenceSearchScope> searchScopes, string newName, CSharpAstResolver resolver,
		                                   Action<RenameCallbackArguments> callback, Action<Error> errorCallback, CancellationToken cancellationToken = default (CancellationToken))
		{
			FindReferencesInFile(
				searchScopes,
				resolver,
				delegate(AstNode astNode, ResolveResult result) {
					var nodeToReplace = GetNodeToReplace(astNode);
					if (nodeToReplace == null) {
						errorCallback (new Error (ErrorType.Error, "no node to replace found."));
						return;
					}
					callback (new RenameCallbackArguments(nodeToReplace, Identifier.Create(newName)));
				},
				cancellationToken);
		}
		#endregion

Usage Example

        IList <AstNode> Rename(string fullyQualifiedName, string newName, bool includeOverloads)
        {
            var sym = GetSymbol(compilation, fullyQualifiedName);

            Assert.NotNull(sym);
            var graph = new TypeGraph(compilation.Assemblies);
            var col   = new SymbolCollector();

            col.IncludeOverloads = includeOverloads;
            col.GroupForRenaming = true;
            var            scopes = findReferences.GetSearchScopes(col.GetRelatedSymbols(graph, sym));
            List <AstNode> result = new List <AstNode>();

            findReferences.RenameReferencesInFile(
                scopes,
                newName,
                new CSharpAstResolver(compilation, syntaxTree, unresolvedFile),
                delegate(RenameCallbackArguments obj) {
                result.Add(obj.NodeToReplace);
            },
                delegate(Error obj) {
            });
            return(result);
        }