Example #1
0
 /// <summary>
 /// See <see cref="IReferenceResolver.GetReferences"/>
 /// </summary>
 /// <param name="context"></param>
 /// <param name="includeAssemblies"></param>
 /// <returns></returns>
 public IEnumerable <CompilerReference> GetReferences(TypeContext context = null, IEnumerable <CompilerReference> includeAssemblies = null)
 {
     return(CompilerServicesUtility
            .GetLoadedAssemblies()
            .Where(a => !a.IsDynamic && !a.FullName.Contains("Version=0.0.0.0") && File.Exists(a.Location) && !a.Location.Contains("CompiledRazorTemplates.Dynamic"))
            .GroupBy(a => a.GetName().Name).Select(grp => grp.First(y => y.GetName().Version == grp.Max(x => x.GetName().Version))) // only select distinct assemblies based on FullName to avoid loading duplicate assemblies
            .Select(a => CompilerReference.From(a))
            .Concat(includeAssemblies ?? Enumerable.Empty <CompilerReference>()));
 }
 /// <summary>
 /// See <see cref="IReferenceResolver.GetReferences"/>
 /// </summary>
 /// <param name="context"></param>
 /// <param name="includeAssemblies"></param>
 /// <returns></returns>
 public IEnumerable <CompilerReference> GetReferences(TypeContext context = null, IEnumerable <CompilerReference> includeAssemblies = null)
 {
     return(CompilerServicesUtility
            .GetLoadedAssemblies()
            .Where(IsValidAssembly)
            .GroupBy(a => a.GetName().Name).Select(grp => grp.First(y => y.GetName().Version == grp.Max(x => x.GetName().Version))) // only select distinct assemblies based on FullName to avoid loading duplicate assemblies
            .Select(a => CompilerReference.From(a))
            .Concat(includeAssemblies ?? Enumerable.Empty <CompilerReference>()));
 }