public ResolvedUsingScope(CSharpTypeResolveContext context, UsingScope usingScope) { if (context == null) { throw new ArgumentNullException("context"); } if (usingScope == null) { throw new ArgumentNullException("usingScope"); } this.parentContext = context; this.usingScope = usingScope; if (usingScope.Parent != null) { if (context.CurrentUsingScope == null) { throw new InvalidOperationException(); } } else { if (context.CurrentUsingScope != null) { throw new InvalidOperationException(); } } }
/// <summary> /// Creates a new nested using scope. /// </summary> /// <param name="parent">The parent using scope.</param> /// <param name="shortName">The short namespace name.</param> public UsingScope(UsingScope parent, string shortName) { if (parent == null) { throw new ArgumentNullException("parent"); } if (shortName == null) { throw new ArgumentNullException("shortName"); } this.parent = parent; this.shortName = shortName; }
CSharp.TypeSystem.UsingScope CreateUsingScope(HashSet <string> requiredNamespacesSuperset) { var usingScope = new CSharp.TypeSystem.UsingScope(); foreach (var ns in requiredNamespacesSuperset) { string[] parts = ns.Split('.'); AstType nsType = new SimpleType(parts[0]); for (int i = 1; i < parts.Length; i++) { nsType = new MemberType { Target = nsType, MemberName = parts[i] }; } var reference = nsType.ToTypeReference(CSharp.Resolver.NameLookupMode.TypeInUsingDeclaration) as CSharp.TypeSystem.TypeOrNamespaceReference; if (reference != null) { usingScope.Usings.Add(reference); } } return(usingScope); }