コード例 #1
0
 /// <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));
 }
コード例 #2
0
 internal DataOperationsCatalog(IHostEnvironment env)
 {
     Contracts.AssertValue(env);
     _env = env;
 }
コード例 #3
0
 private protected TrainCatalogBase(IHostEnvironment env, string registrationName)
 {
     Contracts.CheckValue(env, nameof(env));
     env.CheckNonEmpty(registrationName, nameof(registrationName));
     Environment = env;
 }
コード例 #4
0
 internal bool TryFindColumn(string name, out Column column)
 {
     Contracts.CheckValue(name, nameof(name));
     column = _columns.FirstOrDefault(x => x.Name == name);
     return(column.IsValid);
 }
コード例 #5
0
 public SchemaShape(IEnumerable <Column> columns)
 {
     Contracts.CheckValue(columns, nameof(columns));
     _columns = columns.ToArray();
     Contracts.CheckParam(columns.All(c => c.IsValid), nameof(columns), "Some items are not initialized properly.");
 }
コード例 #6
0
        /// <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);
                }
            }
        }
コード例 #7
0
 public TelemetryException(Exception exception)
 {
     Contracts.AssertValue(exception);
     Exception = exception;
 }