public void Execute(InstallEnvironment env) { Service service = new Service(Name, autoStart); service.ApplicationPath = ApplicationPath; Node <object> theNode = databaseManager.Find("/System/Runtime/Services"); if (!theNode.TypedStreamExists <Service>()) { theNode.AddTypedStream <Service>(StreamOptions.Indexed | StreamOptions.AllowDerivedTypes); } using (TypedStream <Service> ts = theNode.OpenForWriting <Service>()) { ts.Write(ts.Count, service); } }
private void DoInstall(InstallSource source, InstallDestination installDestination) { source.InstallEnvironment = environment; installDestination.InstallEnvironment = environment; ApplicationDesc app = source.OpenForReading <ApplicationDesc>().Object; using (TypedStream <ApplicationDesc> appstream = installDestination.OpenForWriting <ApplicationDesc>()) { appstream.Object = app; } /* register default bindings */ foreach (string type in app.DefaultBindings.Keys) { documentManagement.RegisterDocumentUsage( type, installDestination.ToString(), app.DefaultBindings[type]); } }
private int SetupGpxUrl(GpxFile gpx, List <LineString> addibleLines = null) { int traceId = 1; var fetcher = Substitute.For <IAuthClient>(); var fileResponse = new TypedStream { FileName = "file.gpx", Stream = new MemoryStream(new byte[0]) }; fetcher.GetTraceData(traceId).Returns(fileResponse); _dataContainerConverterService.Convert(Arg.Any <byte[]>(), Arg.Any <string>(), Arg.Any <string>()) .Returns(gpx.ToBytes()); _clientsFactory.CreateOAuthClient(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(fetcher); _addibleGpxLinesFinderService.GetLines(Arg.Any <List <LineString> >()).Returns( addibleLines ?? new List <LineString> { new LineString(new[] { new Coordinate(0, 0), new Coordinate(1, 1) }) }.AsEnumerable() ); return(traceId); }
void DoCopy(InstallSource source, InstallDestination destination) { source.InstallEnvironment = environment; destination.InstallEnvironment = environment; /* -- no, we don't do that anymore * if (destination.Exists) * { * destination.Delete(); * } */ foreach (Type t in source.Types) { // Console.Out.WriteLine("{0}[{1}] -> {1}", source, t.Name, destination); TypedStream <object> dstStream = destination.OpenForWriting(t); using (TypedStream <object> srcStream = source.OpenForReading(t)) { dstStream.Array = srcStream.Array; dstStream.Dispose(); } } }
/// <summary> /// Constructs object's index. /// </summary> /// <param name="obj"></param> /// <returns></returns> public static Dictionary <string, object> IndexOfObject <T>(StreamIndexTable table, TypedStream <T> typedStream, uint index, out T obj) { obj = default(T); return(null); }
public System.Reflection.Assembly Load(string requiredName, out string debug) { debug = ""; if (asmCache.Count == 0) { foreach (System.Reflection.Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { asmCache[asm.GetName().Name] = asm; Console.Out.WriteLine("Caching Assembly: {0}", asm.GetName().Name); } } AssemblyName asmName = new AssemblyName(requiredName); if (asmCache.ContainsKey(asmName.Name)) { return(asmCache[asmName.Name]); } else { foreach (string path in searchPaths) { string xpath = path + "/" + asmName.Name.Replace('.', '/'); debug += String.Format(" .. Assembly.Load, Probing Path '{0}'\n", xpath); if (mgr.Find(xpath) != null) { Node <object> node = mgr.Find(xpath); if (node != null && node.TypedStreamExists <SharpMedia.Components.Database.AssemblyDesc>()) { using (TypedStream <SharpMedia.Components.Database.AssemblyDesc> ts = node.OpenForReading <SharpMedia.Components.Database.AssemblyDesc>()) { Assembly asm = null; if (false && !ts.Object.Unmanaged) { asm = Assembly.Load(ts.Object.ByteContent); } else { File.WriteAllBytes(asmName + ".dll", ts.Object.ByteContent); // asm = Assembly.LoadFrom(Path.GetFullPath(asmName + ".dll")); string fullPath = Path.GetFullPath(asmName + ".dll"); asm = Assembly.LoadFile(fullPath); } asmCache[requiredName] = asm; return(asm); } } } } } debug += String.Format("> Failed to get Assembly {0}\n", requiredName); return(null); }
public static int ReadObject(ExecutionContext context, object[] values, out object[] inlineParameters) { inlineParameters = EmptyParameters; if (values.Length < 1 || values.Length > 4) { context.Error.WriteLine("Invalid syntax: ReadObject NodePath [TypedStream [Index]]"); return(-1); } string path = values[0].ToString(); Type type = null; uint index = 0; // We first get type. if (values.Length > 1) { type = Type.GetType(values[1].ToString()); if (type == null) { context.Error.WriteLine("Type '{0}' not resolved.", values[1].ToString()); return(-1); } } if (values.Length > 2) { if (values[2] is uint) { index = (uint)values[2]; } else if (values[3] is int) { index = (uint)((int)values[2]); } else if (!uint.TryParse(values[2].ToString(), out index)) { context.Error.WriteLine("The index is not a number: {0}", values[2].ToString()); return(-1); } } Node <object> node = context.ShellApp.WorkingDirectory.Find(path); if (node == null) { context.Error.WriteLine("Path '{0}' does not exist", path); return(-1); } TypedStream <object> typedStream = null; try { if (type == null) { typedStream = node.OpenForReading(); } else { typedStream = node.Open(type, OpenMode.Read); } if (typedStream == null) { context.Error.WriteLine("Typed stream '{0}' does not exist on path '{1}'", type, path); return(-1); } // We write it. inlineParameters = new object[] { typedStream.Read(index) }; } finally { if (typedStream != null) { typedStream.Dispose(); } } return(1); }
static List <Selectable> FindInternal <Selectable, T>(List <Selectable> result, Node <object> table, IQueryExpression <Selectable, T> expression) { TypedStream <T> typedStream = table.Open <T>(OpenMode.Read); if (typedStream == null) { throw new TypedStreamNotFoundException( string.Format("Typed stream of type {0} not found in '{1}'", typeof(T), table.Path)); } // We first obtain index table. IndexTable index2 = table.IndexTable; StreamIndexTable index = index2 != null ? index2[typeof(T)] : null; QueryFilter filter = expression.Filter; // We make sure it is disposed correcly. using (typedStream) { uint[] locations = typedStream.ObjectLocations; for (int i = 0; i < locations.Length; i++) { // We have object's location. uint primary = locations[i]; T processingObject = default(T); // 1) We now filter all objects, first by index. if ((filter & QueryFilter.Index) != 0) { Dictionary <string, object> indexData = StreamIndexTable.IndexOfObject <T>(index, typedStream, primary, out processingObject); // We now process through filter. if (!expression.IsSatisfied(primary, indexData)) { continue; } } // 2) Now we try the alternative filtering, by object. if ((filter & QueryFilter.Object) != 0) { // Force object loading, if not already by indexing. if (!object.ReferenceEquals(processingObject, null)) { processingObject = typedStream.Read(primary); } // We now process it. if (!expression.IsSatisfied(processingObject)) { continue; } } // 3) We now select it. result.Add(expression.Select(processingObject)); } } // 4) After all object are loaded, we sort them if ((filter & QueryFilter.Sort) != 0) { expression.Sort(result); } return(result); }