ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver.WithCurrentTypeDefinition C# (CSharp) Method

WithCurrentTypeDefinition() public method

Sets the current type definition.
public WithCurrentTypeDefinition ( ITypeDefinition typeDefinition ) : CSharpResolver
typeDefinition ITypeDefinition
return CSharpResolver
		public CSharpResolver WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
		{
			if (this.CurrentTypeDefinition == typeDefinition)
				return this;
			
			TypeDefinitionCache newTypeDefinitionCache;
			if (typeDefinition != null)
				newTypeDefinitionCache = new TypeDefinitionCache(typeDefinition);
			else
				newTypeDefinitionCache = null;
			
			return new CSharpResolver(compilation, conversions, context.WithCurrentTypeDefinition(typeDefinition),
			                          checkForOverflow, isWithinLambdaExpression, newTypeDefinitionCache, localVariableStack, objectInitializerStack);
		}
		

Usage Example

		string ConvertHelper(AstNode node, Action<CSharpCodeProvider, CodeObject, TextWriter, CodeGeneratorOptions> action)
		{
			CSharpResolver resolver = new CSharpResolver(compilation);
			resolver = resolver.WithCurrentUsingScope(unresolvedFile.RootUsingScope.Resolve(compilation));
			resolver = resolver.WithCurrentTypeDefinition(compilation.FindType(KnownTypeCode.Object).GetDefinition());
			var codeObj = convertVisitor.Convert(node, new CSharpAstResolver(resolver, node));
			
			StringWriter writer = new StringWriter();
			writer.NewLine = " ";
			action(new CSharpCodeProvider(), codeObj, writer, new CodeGeneratorOptions { IndentString = " " });
			return Regex.Replace(writer.ToString(), @"\s+", " ").Trim();
		}
All Usage Examples Of ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver::WithCurrentTypeDefinition
CSharpResolver