public Entity Add() { Entity entity = new Entity(); ServerComponent server = new ServerComponent() { Address = "127.0.0.1" }; entity.Add(server); MachineComponent machine = new ServerMachineComponent(); entity.Add(machine); SessionComponent session = new SessionComponent(); entity.Add(session); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif Add(entity); return(entity); }
public Entity Add() { Entity entity = new Entity(); ServerComponent server = new ServerComponent() { Name = Environment.MachineName, Address = "127.0.0.1" }; entity.Add(server); ServerOptionsComponent options = new ServerOptionsComponent(); entity.Add(options); ServerStatusComponent status = new ServerStatusComponent(); entity.Add(status); MachineComponent machine = new ServerMachineComponent(); entity.Add(machine); SessionMapComponent sessions = new SessionMapComponent(); entity.Add(sessions); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif Add(entity); return(entity); }
public static void Append(TraceEventType eventType, int tick, LogComponent component, string thread, string header, string message) { byte[] buffer = s_buffer; if (buffer == null) { s_buffer = buffer = new byte[MaxPayload]; } var writer = s_writer; if (writer == null) { s_writer = writer = new BinaryWriter(new MemoryStream(buffer)); } else { writer.Seek(0, SeekOrigin.Begin); } int len = LogEntry.Write(writer, DateTime.UtcNow, eventType, tick, component, thread, header, message); s_indexMutex.WaitOne(); int idx = IncrementCurrentIndex(); WriteArray(idx, buffer, len); s_indexMutex.ReleaseMutex(); }
public void Download(FileComponent comp) { Debug.Assert(comp != null); Entity entity = new Entity(); EntityIdleComponent idle = new EntityIdleComponent(); entity.Add(idle); EntityStoreComponent store = new EntityStoreComponent(comp.Owner); entity.Add(store); FileComponent file = new FileComponent(comp); entity.Add(file); TransferComponent transfer = new TransferComponent(); entity.Add(transfer); DownloadMachineComponent machine = new DownloadMachineComponent(); entity.Add<MachineComponent>(machine); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif Add(entity); }
public void Add(ClientComponent client, ServerComponent server, GroupComponent group) { Entity entity = new Entity(); entity.Add(client); ClientOptionsComponent options = new ClientOptionsComponent(); entity.Add(options); entity.Add(server); entity.Add(group); FolderListComponent folderList = new FolderListComponent(); entity.Add(folderList); FileMapComponent fileMap = new FileMapComponent(); entity.Add(fileMap); FolderMapComponent folderMap = new FolderMapComponent(); entity.Add(folderMap); ClientMachineComponent machine = new ClientMachineComponent(); entity.Add <MachineComponent>(machine); SessionComponent session = new SessionComponent(); entity.Add(session); FileComponent file = new FileComponent(); entity.Add(file); SearchListComponent search = new SearchListComponent(SearchController.Dispatcher); entity.Add(search); BrowseComponent browse = new BrowseComponent(); entity.Add(browse); DownloadListComponent download = new DownloadListComponent(DownloadController.Dispatcher); entity.Add(download); UploadListComponent upload = new UploadListComponent(UploadController.Dispatcher); entity.Add(upload); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif Add(entity); }
public Entity Add() { Entity entity = new Entity(); ServerComponent server = new ServerComponent() { Name = Environment.MachineName, Address = "127.0.0.1" }; entity.Add(server); ServerOptionsComponent options = new ServerOptionsComponent(); entity.Add(options); ServerStatusComponent status = new ServerStatusComponent(); entity.Add(status); MachineComponent machine = new RouterMachineComponent(); entity.Add(machine); ServerListComponent servers = new ServerListComponent(); entity.Add(servers); EntityMapComponent entities = new EntityMapComponent(); entity.Add(entities); SessionMapComponent sessions = new SessionMapComponent(); entity.Add(sessions); GroupListMapComponent groups = new GroupListMapComponent(); entity.Add(groups); ClientMapComponent clients = new ClientMapComponent(); entity.Add(clients); TransferMapComponent transfers = new TransferMapComponent(); entity.Add(transfers); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif Add(entity); return(entity); }
public static void Write(LogType type, LogComponent component, string message, params object[] args) { if ((_type & type) != 0 && (_components & component) != 0) { // // My log has something to tell you... // TODO: color based on type, etc. Console.WriteLine(_logIndex.ToString() + ": " + component.ToString() + ": " + message, args); _logIndex++; } }
public void WriteToLogTest_StringShouldBeAddedToLog() { //Arrange LogComponent logComponent = new LogComponent(); string testString = "Test"; //Act logComponent.WriteToLog(testString); //Assert Assert.AreEqual(testString, logComponent.GetEntry(0)); }
public static int Write(BinaryWriter writer, DateTime dateTime, TraceEventType eventType, int tick, LogComponent component, string thread, string header, string message) { writer.Write(dateTime.ToBinary()); writer.Write((int)eventType); writer.Write(tick); writer.Write((byte)component); writer.Write(thread); writer.Write(header); writer.Write(message); writer.Flush(); return (int)writer.BaseStream.Position; }
private void OnInteractUsing(EntityUid uid, LogComponent component, InteractUsingEvent args) { if (HasComp <SharpComponent>(args.Used)) { for (var i = 0; i < component.SpawnCount; i++) { var plank = Spawn(component.SpawnedPrototype, Transform(uid).Coordinates); plank.RandomOffset(0.25f); } QueueDel(uid); } }
public static int Write(BinaryWriter writer, DateTime dateTime, TraceEventType eventType, int tick, LogComponent component, string thread, string header, string message) { writer.Write(dateTime.ToBinary()); writer.Write((int)eventType); writer.Write(tick); writer.Write((byte)component); writer.Write(thread); writer.Write(header); writer.Write(message); writer.Flush(); return((int)writer.BaseStream.Position); }
public static void Write(LogType type, LogComponent component, string message, params object[] args) { if ((_type & type) != 0 && (_components & component) != 0) { // // My log has something to tell you... Console.WriteLine("[" + DateTime.Now + "] " + component.ToString() + ": " + message, args); if (_logStream != null) { _logStream.WriteLine(component.ToString() + ": " + message, args); } } }
static public void Init() { MarsRuntimeComponent.Init(new MarsCallback()); MarsRuntimeComponent.OnCreate(); MarsRuntimeComponent.OnForeground(true); StnComponent.SetClientVersion(200); StnComponent.SetLonglinkSvrAddr("www.marsopen.cn", new ushort[] { 8081 }); StnComponent.SetShortlinkSvrAddr(8080); StnComponent.MakesureLonglinkConnected(); LogComponent.AppenderOpen(TAppenderModeRuntime.kAppednerSync, ApplicationData.Current.LocalFolder.Path + "\\log", "sample"); LogComponent.AppenderSetConsoleLog(true); LogComponent.SetLogLevel(TLogLevelRuntime.kLevelDebug); //LogComponent.LogWrite(TLogLevelRuntime.kLevelDebug, "uwp sample", "", "", 0, 0, 0, 0, "test log"); }
public void GetLogTest_AddingThreeEntriesShouldMakeLogThreeEntriesLong() { //Arrange LogComponent logComponent = new LogComponent(); List <string> testStringList = new List <string> { "Test1", "Test2", "Test3" }; //Act foreach (string text in testStringList) { logComponent.WriteToLog(text); } //Assert Assert.AreEqual(testStringList.Count, logComponent.GetLog().Count); }
public void Log_ValidLogMessage() { try { LogComponent component1 = LogComponent.WRITER; LogComponent component2 = LogComponent.REPLICATOR_SENDER; LogComponent component3 = LogComponent.REPLICATOR_RECEIVER; LogComponent component4 = LogComponent.READER; LogComponent component5 = LogComponent.DATABASE; Logger.Log(component1, component2, DateTime.Now, "message1"); Logger.Log(component2, component3, DateTime.Now, "message2"); Logger.Log(component3, component4, DateTime.Now, "message3"); Logger.Log(component4, component5, DateTime.Now, "message4"); } catch (Exception) { Assert.Fail(); } Assert.Pass(); }
public void Execute(HttpRequest httpRequest) { // Connect NetworkChannel channel = new NetworkChannel(Connection); // Data Entity entity = new Entity(null); entity.EntityShutdown += Listener; EntityIdleComponent idle = new EntityIdleComponent(); entity.Add(idle); SessionComponent session = new SessionComponent() { Key = Key.Parse(httpRequest.Data) }; entity.Add(session); SessionMap.Add(session.Id, entity); Server.Sessions = SessionMap.Count; // TODO: Use Diffie–Hellman // // Response HttpResponse httpResponse = new HttpResponse(session.Id) { Data = SecurityUtil.Token }; channel.Send(httpResponse); #if DEBUG LogComponent log = new LogComponent(Log.Controller); entity.Add(log); Log.Add(httpRequest, httpResponse); #endif }
public static void LogError(LogComponent component, DateTime timestamp) { string line = string.Format($"[{timestamp}] {component.ToString()} ERROR"); StreamWriter sw; lock (syncLock) { if (!File.Exists(filename)) { sw = File.CreateText(filename); } else { sw = File.AppendText(filename); } sw.WriteLine(line); sw.Close(); } }
public void Log_ErrorLogMessage() { try { LogComponent component1 = LogComponent.WRITER; LogComponent component2 = LogComponent.REPLICATOR_SENDER; LogComponent component3 = LogComponent.REPLICATOR_RECEIVER; LogComponent component4 = LogComponent.READER; LogComponent component5 = LogComponent.DATABASE; Logger.LogError(component1, DateTime.Now); Logger.LogError(component2, DateTime.Now); Logger.LogError(component3, DateTime.Now); Logger.LogError(component4, DateTime.Now); Logger.LogError(component5, DateTime.Now); } catch (Exception) { Assert.Fail(); } Assert.Pass(); }
public static void Open(LogComponent logComponent) { _logComponent = logComponent; _openDebug = true; }
public static void Write(LogType type, LogComponent component, string message, params object[] args) { }
/// <summary> /// are you sure you want to construct your own LogManager? You may want to use /// SceneManager.GetInstance().GetLogManager() instead /// </summary> /// <param name="logComponent">a log component which houses the relevent prefab/UI elements</param> public LogManager(LogComponent logComponent) { m_logPrefab = logComponent.GetLogPrefab(); m_logContent = logComponent.GetLogContent(); }
public static void Append(TraceEventType eventType, int tick, LogComponent component, string thread, string header, string message) { byte[] buffer = s_buffer; if (buffer == null) s_buffer = buffer = new byte[MaxPayload]; var writer = s_writer; if (writer == null) s_writer = writer = new BinaryWriter(new MemoryStream(buffer)); else writer.Seek(0, SeekOrigin.Begin); int len = LogEntry.Write(writer, DateTime.UtcNow, eventType, tick, component, thread, header, message); s_indexMutex.WaitOne(); int idx = IncrementCurrentIndex(); WriteArray(idx, buffer, len); s_indexMutex.ReleaseMutex(); }
private void ReadClient(XmlReader reader) { if (reader.IsEmptyElement) { return; } bool loop = true; string name = null; // Components Entity entity = new Entity(); ClientComponent client = new ClientComponent(); ClientOptionsComponent options = new ClientOptionsComponent(); GroupComponent group = new GroupComponent(); ServerComponent server = new ServerComponent(); List <string> paths = new List <string>(); client.Enabled = bool.Parse(reader.GetAttribute(XmlTag.Enabled)); while (loop && reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: { name = reader.Name; switch (name) { case XmlTag.Router: { ReadRouter(reader, ref server); break; } case XmlTag.Options: { ReadOptions(reader, ref options); break; } case XmlTag.Folders: { ReadFolders(reader, ref paths); break; } } break; } case XmlNodeType.Text: { switch (name) { case XmlTag.Id: { entity.Id = reader.Value; break; } case XmlTag.Name: { client.Name = reader.Value; break; } case XmlTag.Download: { client.Download = reader.Value; break; } case XmlTag.Group: { group.Path = reader.Value; break; } } break; } case XmlNodeType.EndElement: { if (XmlTag.Client.Equals(reader.Name)) { loop = false; } break; } } } // Components entity.Add(client); entity.Add(options); entity.Add(group); entity.Add(server); FolderListComponent folderList = new FolderListComponent(); entity.Add(folderList); FileMapComponent fileMap = new FileMapComponent(); entity.Add(fileMap); FolderMapComponent folderMap = new FolderMapComponent(); entity.Add(folderMap); ClientMachineComponent machine = new ClientMachineComponent(); entity.Add <MachineComponent>(machine); SessionComponent session = new SessionComponent(); entity.Add(session); FileComponent file = new FileComponent(); entity.Add(file); SearchListComponent search = new SearchListComponent(SearchController.Dispatcher); entity.Add(search); BrowseComponent browse = new BrowseComponent(); entity.Add(browse); DownloadListComponent download = new DownloadListComponent(DownloadController.Dispatcher); entity.Add(download); UploadListComponent upload = new UploadListComponent(UploadController.Dispatcher); entity.Add(upload); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif ClientController.Add(entity); foreach (string path in paths) { FileComponent shared = new FileComponent(path) { Owner = entity }; folderList.Add(shared); } }
public MyTraceContext(string component) { switch (component) { case "Server": this.Component = LogComponent.Server; break; case "Client": this.Component = LogComponent.Client; break; default: throw new Exception(); } }
/// <summary> /// Logs a message without specifying type/severity for terseness; /// will not log if Type has been set to None. /// </summary> /// <param name="level"></param> /// <param name="message"></param> /// <param name="args"></param> public static void Write(LogComponent component, string message, params object[] args) { Write(LogType.Normal, component, message, args); }
private void ReadServer(XmlReader reader) { if (reader.IsEmptyElement) { return; } bool loop = true; string name = null; // Components Entity entity = new Entity(); ServerComponent server = new ServerComponent(); ServerOptionsComponent options = new ServerOptionsComponent(); server.Enabled = bool.Parse(reader.GetAttribute(XmlTag.Enabled)); while (loop && reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: { name = reader.Name; switch (name) { case XmlTag.Options: { ReadOptions(reader, ref options); break; } } break; } case XmlNodeType.Text: { switch (name) { case XmlTag.Id: { entity.Id = reader.Value; break; } case XmlTag.Name: { server.Name = reader.Value; break; } case XmlTag.Passphrase: { server.Passphrase = reader.Value; break; } case XmlTag.Address: { server.Address = reader.Value; break; } case XmlTag.Port: { server.Port = int.Parse(reader.Value); break; } } break; } case XmlNodeType.EndElement: { if (XmlTag.Server.Equals(reader.Name)) { loop = false; } break; } } } // Components entity.Add(server); entity.Add(options); ServerStatusComponent status = new ServerStatusComponent(); entity.Add(status); MachineComponent machine = new ServerMachineComponent(); entity.Add(machine); SessionMapComponent sessions = new SessionMapComponent(); entity.Add(sessions); #if DEBUG LogComponent log = new LogComponent(LogController); entity.Add(log); #endif Server.Add(entity); }