コード例 #1
0
 public ResolvedUsingScope(CSharpTypeResolveContext context, UsingScope usingScope)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     if (usingScope == null)
     {
         throw new ArgumentNullException(nameof(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();
         }
     }
 }
コード例 #2
0
ファイル: UsingScope.cs プロジェクト: quitec/ilspy
 /// <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(nameof(parent));
     }
     if (shortName == null)
     {
         throw new ArgumentNullException(nameof(shortName));
     }
     this.parent    = parent;
     this.shortName = shortName;
 }
コード例 #3
0
        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);
        }