/// <summary> /// Loads a layer chain from the given directory. /// The method looks for a chain.txt file with layer names, /// and it looks for dll files to create the corresponding layers /// /// Subchains can be packaged in directories. Just provide another /// chain.txt file in that directory with the corresponding layers, /// and include the corresponding dlls. /// /// Then, in the parent directory, make sure chain.txt lists the folder name /// as a layer. /// </summary> /// <returns>The chain.</returns> /// <param name="dir">Dir.</param> public static List <LayerWrapper> LoadChain(string appName, string dir) { var toreturn = new List <LayerWrapper>(); //Get the proposed chain from the text file chain.txt, //and by also recursively visiting subdirectories //Then create seed layers based on those names and available dlls //Then use those seed layers to create actual layers for each item in the chain PythonScriptHost.Instance.ResetEngine(); var layerinfos = RecursiveGetLayerInfos(dir); var seeds = GetSeedLayers(layerinfos, PythonScriptHost.Instance); int index = 0; foreach (LayerInfo info in layerinfos) { LayerSeed seed = GetLayerByName(seeds, info.Name); if (seed == null) { throw new Exception("Could not find layer " + info.Name + " in directory " + info.Directory); } LayerWrapper toadd = seed.CreateLayerFromSeed(appName, info, index); index++; toreturn.Add(toadd); } return(toreturn); }
private static List <LayerWrapper> LoadChainFromSeedLayers( string appName, List <LayerSeed> layers, List <Dictionary <string, object> > parameters) { var chain = new List <LayerWrapper>(); for (int i = 0; i < layers.Count; i++) { LayerSeed layer = layers[i]; var param = parameters[i]; LayerInfo info = new LayerInfo(null, layer.Seed.Name, param); LayerWrapper toadd = layer.CreateLayerFromSeed(appName, info, i); chain.Add(toadd); } return(chain); }