internal ModelOperationsCatalog(IHostEnvironment env) { Contracts.AssertValue(env); _env = env; }
/// <summary> /// Create an output "file" and return a handle to it. /// </summary> public static IFileHandle CreateOutputFile(this IHostEnvironment env, string path) { Contracts.AssertValue(env); Contracts.CheckNonWhiteSpace(path, nameof(path)); return(new SimpleFileHandle(env, path, needsWrite: true, autoDelete: false)); }
internal DataOperations(IHostEnvironment env) { Contracts.AssertValue(env); Environment = env; }
public TelemetryException(Exception exception) { Contracts.AssertValue(exception); Exception = exception; }
/// <summary> /// Make sure the given assemblies are loaded and that their loadable classes have been catalogued. /// </summary> public static void LoadAndRegister(IHostEnvironment env, string[] assemblies) { Contracts.AssertValue(env); if (Utils.Size(assemblies) > 0) { foreach (string path in assemblies) { Exception ex = null; try { // REVIEW: Will LoadFrom ever return null? Contracts.CheckNonEmpty(path, nameof(path)); var assem = LoadAssembly(env, path); if (assem != null) { continue; } } catch (Exception e) { ex = e; } // If it is a zip file, load it that way. ZipArchive zip; try { zip = ZipFile.OpenRead(path); } catch (Exception e) { // Couldn't load as an assembly and not a zip, so warn the user. ex = ex ?? e; Console.Error.WriteLine("Warning: Could not load '{0}': {1}", path, ex.Message); continue; } string dir; try { dir = CreateTempDirectory(); } catch (Exception e) { throw Contracts.ExceptIO(e, "Creating temp directory for extra assembly zip extraction failed: '{0}'", path); } try { zip.ExtractToDirectory(dir); } catch (Exception e) { throw Contracts.ExceptIO(e, "Extracting extra assembly zip failed: '{0}'", path); } LoadAssembliesInDir(env, dir, false); } } }