Microsoft.JScript.Vsa.VsaEngine.TryToAddImplicitAssemblyReference C# (CSharp) Method

TryToAddImplicitAssemblyReference() private method

private TryToAddImplicitAssemblyReference ( String name ) : void
name String
return void
      internal void TryToAddImplicitAssemblyReference(String name){
        if (!this.autoRef) return;
        
        String key;
        SimpleHashtable implictAssemblyCache = this.implicitAssemblyCache;
        if (implicitAssemblyCache == null) {
          //Populate cache with things that should not be autoref'd. Canonical form is lower case without extension.
          implicitAssemblyCache = new SimpleHashtable(50);
          
          //PEFileName always includes an extension and is never NULL.
          implicitAssemblyCache[Path.GetFileNameWithoutExtension(this.PEFileName).ToLowerInvariant()] = true;
          
          foreach (Object item in this.vsaItems){
            VsaReference assemblyReference = item as VsaReference;
            if (assemblyReference == null || assemblyReference.AssemblyName == null) continue;
            key = Path.GetFileName(assemblyReference.AssemblyName).ToLowerInvariant();
            if (key.EndsWith(".dll", StringComparison.Ordinal))
              key = key.Substring(0, key.Length-4);
            implicitAssemblyCache[key] = true;
          }          
          this.implicitAssemblyCache = implicitAssemblyCache;          
        }
        
        key = name.ToLowerInvariant();
        if (implicitAssemblyCache[key] != null) return;
        implicitAssemblyCache[key] = true;
        
        try{
          VsaReference assemblyReference = new VsaReference(this, name + ".dll");
          if (assemblyReference.Compile(false)){
            ArrayList implicitAssemblies = this.implicitAssemblies;
            if (implicitAssemblies == null) {
               implicitAssemblies = new ArrayList();
               this.implicitAssemblies = implicitAssemblies;
            }
            implicitAssemblies.Add(assemblyReference.Assembly);
          }
        }catch(VsaException){
        }
      }

Usage Example

 internal WrappedNamespace(String name, VsaEngine engine, bool AddReferences)
   : base(null) {
   this.name = name;
   this.engine = engine;
   this.isKnownAtCompileTime = true;
   if (name.Length > 0 && AddReferences)
     engine.TryToAddImplicitAssemblyReference(name);
 }