public void ReplayTo(ILogPrinter anotherPrinter) { Debug.Assert(anotherPrinter != null && anotherPrinter != this); foreach (Log.LogEntry entry in log.Entries()) { if (entry.ErrorCode == 0) { if (entry.Message.Length == 0) { anotherPrinter.Separate(); continue; } else if (entry.Message == IndentMarker) { anotherPrinter.Indent(); continue; } else if (entry.Message == UnindentMarker) { anotherPrinter.Unindent(); continue; } } // ordinary entry anotherPrinter.PrintEntry(entry.Severity, entry.ErrorCode, entry.Message); } }
void SerializeArray(object instance, Type type, IKey inKey, ILogPrinter inLogger) { //if (string.IsNullOrEmpty(inKey.GetName())) //inKey.SetName("Values"); Type declaredItemType = type.GetElementType(); bool atomic_member = declaredItemType.IsAtomic(); Array multi_dim_array = instance as Array; CMultiArrayIndexer indexer = new CMultiArrayIndexer(multi_dim_array); while (indexer.MoveNext()) { object value = multi_dim_array.GetValue(indexer.Current); IKey dim_child = GetOrCreateKeyByArrayIndex(inKey, indexer.Current, indexer.Lengthes, atomic_member); if (atomic_member) { AddValueToKey(dim_child, value); } else { IKey child = dim_child.CreateArrayKey(); Serialize(value, declaredItemType, child, 0, inLogger); } } }
/// <summary> /// Release resources. /// </summary> /// <param name = "disposing"> /// If disposing equals true, managed and unmanaged resources are disposed. /// If false, only unmanaged resources can be disposed. /// </param> protected virtual void Dispose(bool disposing) { if (!this.disposed) { // If disposing equals true, dispose all managed and unmanaged resources. if (disposing) { // Free managed resources & other reference types: if (this.httpServerTransport != null) { this.httpServerTransport.Dispose(); this.httpServerTransport = null; } if (this.httpListenerContext != null) { this.httpListenerContext = null; } if (this.logger != null) { this.logger = null; } } } // Call the appropriate methods to clean up unmanaged resources. // If disposing is false, only the following code is executed: this.disposed = true; }
public IKey SerializeToKey(object instance, string inRootName, ILogPrinter inLogger) { IKey root = IKeyFactory.CreateKey(inRootName); Serialize(instance, root, inLogger); return(root); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null && signature != null); if (hasForwardDeclaration) { printer.Print(OutputType.Keyword, "struct"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.Identifier, Name); printer.Indent(); printer.PrintLn(OutputType.Operator, "{"); // will print "ret_type (call_conv *ptr)(params)" signature.PrintTo(printer, logPrinter, flags); printer.Unindent(); printer.PrintLn(); printer.Print(OutputType.Operator, "};"); } else { printer.Print(OutputType.Keyword, "typedef"); printer.Print(OutputType.Other, " "); // will print "ret_type (call_conv *name)(params)" signature.PrintTo(printer, logPrinter, flags); } }
/// <summary> /// Initializes a new instance of the PCHCServer class /// with the specified osted Cache Mode Listen Port and IPAddress type. /// </summary> /// <param name="transferProtocol">The transport type will be used</param> /// <param name="hostedCacheModeListenPort"> /// The specified BranchCache service's listen port in hosted cache mode. /// </param> /// <param name="ipaddressType">The IP address type.</param> /// <param name="logger">The logger.</param> public PCHCServer( TransferProtocol transferProtocol, int hostedCacheModeListenPort, IPAddressType ipaddressType, ILogPrinter logger) { if (logger == null) { throw new ArgumentNullException("logger", "The input parameter \"logger\" is null."); } this.logger = logger; this.httpServerTransport = new HttpServerTransport( transferProtocol, hostedCacheModeListenPort, ipaddressType, PCHCRESOURCE, logger); this.httpServerTransport.HttpRequestEventHandle += new EventHandler <HttpRequestEventArg>(this.ReceiveHttpRequest); this.logger.AddDebug(@"Register the delegate EventHandle with generic parameter HttpRequestEverntArg and the handle method is ReceiveHttpRequest."); }
/// <summary> /// Dispose(bool disposing) executes in two distinct scenarios. /// If disposing equals true, the method has been called directly /// or indirectly by a user's code. Managed and unmanaged resources /// can be disposed. /// If disposing equals false, the method has been called by the /// runtime from inside the finalizer and you should not reference /// other objects. Only unmanaged resources can be disposed /// </summary> /// <param name="disposing">Specify which scenario is used.</param> private void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { if (this.httpServerTransport != null) { this.httpServerTransport.Dispose(); this.httpServerTransport = null; } if (this.httpRequest != null) { this.httpRequest = null; } if (this.logger != null) { this.logger = null; } } } // Note disposing has been done. this.disposed = true; }
public static Func <object> CreateParameterlessConstructorHandler(Type type, ILogPrinter inLogger) { var dynam = new DynamicMethod(string.Empty, typeof(object), Type.EmptyTypes, Module, true); ILGenerator il = dynam.GetILGenerator(); if (type.IsValueType) { il.DeclareLocal(type); il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Box, type); } else { ConstructorInfo ci = type.GetConstructor(Type.EmptyTypes); if (ci == null) { inLogger.LogError(string.Format("Type {0} hasnt default constructor", type.Name)); return(null); } il.Emit(OpCodes.Newobj, ci); } il.Emit(OpCodes.Ret); return((Func <object>)dynam.CreateDelegate(typeof(Func <object>))); }
public IKey Parse(string inFileName, string inText, ILogPrinter inLogger, object inContextData) { if (!string.IsNullOrEmpty(inFileName)) { _parsed.RemoveAll(p => string.Equals(p.FileName, inFileName)); } var supporter = new CSupportOwner(this, inLogger, inContextData, inFileName); _sentenser.ParseText(inText, supporter.GetLogger()); List <CTokenLine> lines = new List <CTokenLine>(); for (int i = 0; i < _sentenser.SentenseCount; i++) { CSentense sentense = _sentenser[i]; CTokenLine tl = new CTokenLine(); tl.Init(sentense, supporter.GetLogger()); lines.Add(tl); } string root_name = Path.GetFileNameWithoutExtension(inFileName); CKey root = CTreeBuilder.Build(root_name, lines, supporter); _parsed.Add(new CParsed(root, lines, inFileName)); return(root); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); base.PrintTo(printer, logPrinter, flags); PrintNameTo(typeName, indirections, printer, flags); }
/// <summary> /// Initializes a new instance of the <see cref="PccrrClient"/> class. /// </summary> /// <param name="server">The server name.</param> /// <param name="serverPort">The server port.</param> /// <param name="pccrrPath">The HTTP request uri.</param> /// <param name="method">The HTTP request method.</param> /// <param name="logger">The specified logger.</param> public PccrrClient( string server, int serverPort, string pccrrPath, HttpMethod method, ILogPrinter logger) { if (server == null) { throw new ArgumentNullException("server"); } if (pccrrPath == null) { throw new ArgumentNullException("pccrrPath"); } if (logger == null) { throw new ArgumentNullException("logger"); } this.serverName = server; this.serverPort = serverPort; this.url = pccrrPath; this.method = method; this.logger = logger; this.httpClientTransport = new HttpClientTransport(TransferProtocol.HTTP, server, serverPort, pccrrPath, logger); }
internal void Build(IKey inChildsKey, ILogPrinter inLogger) { SWinKeyInfo[] keys = Utils.GetWinKeyInfos(inChildsKey, _window_type_descrs, inLogger); List <CBaseWindow> unused_windows_cache = new List <CBaseWindow>(_childs); List <CBaseWindow> new_childs = new List <CBaseWindow>(); for (int i = 0; i < keys.Length; i++) { SWinKeyInfo window_key_info = keys[i]; CBaseWindow window = Utils.FindMostSuitableWindow(unused_windows_cache, window_key_info); if (window == null) { window = new CBaseWindow(this, window_key_info.Name, window_key_info.WinType, new Rect(0, 0, 10, 10), _gui_realization, _window_type_descrs); } else { unused_windows_cache.Remove(window); } new_childs.Add(window); window.CheckChanging(window_key_info, inLogger); } for (int i = 0; i < unused_windows_cache.Count; i++) { unused_windows_cache[i].Dispose(); } _childs.Clear(); _childs = new_childs; }
/// <summary> /// Prints preview of all methods under the specified node to the provided printers according to the current settings. /// </summary> private void PrintMethodPreview(TreeNode node, ICodePrinter printer, ILogPrinter logPrinter, bool printDefs, bool defsFirst) { // this can take some time - try to not appear hung int tick_count1 = Environment.TickCount; int tick_count2 = unchecked (tick_count1 + 1); Cursor original_cursor = Cursor.Current; // this is a node representing a type - get signatures of all its methods ILogPrinter mem_log = new LogMemoryPrinter(); bool first = true; try { foreach (TreeNode child in node.Nodes) { MethodDescriptor method_descr = child.Tag as MethodDescriptor; if (method_descr != null) { if (!first) { codePrinter.PrintLn(); codePrinter.PrintLn(); } else { first = false; } // print no messages and no definitions PrintMethod(method_descr, codePrinter, mem_log, printDefs, defsFirst); int ticks = Environment.TickCount; if (ticks != tick_count1 && ticks != tick_count2) { // it's taking too long tick_count1 = Environment.TickCount; tick_count2 = unchecked (tick_count1 + 1); Application.DoEvents(); // re-set the selection on rich text box controls because DoEvents may have // included some undesired user input richTextBoxCode.Select(richTextBoxCode.TextLength, 0); richTextBoxMessages.Select(richTextBoxMessages.TextLength, 0); Cursor.Current = Cursors.WaitCursor; } } } } finally { Cursor.Current = original_cursor; } logPrinter.PrintEntry( Severity.Info, 0, "Please select an individual method in the tree to view additional information."); }
public void WriteKey(IKey key, object instance, ILogPrinter inLogger) { Vector3 v = (Vector3)instance; key.AddValue(v.x); key.AddValue(v.y); key.AddValue(v.z); }
public PrintContext(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); this.printer = printer; this.logPrinter = logPrinter; this.flags = flags; }
public override object Instantiate(Type type, ILogPrinter inLogger) { if (type.IsArray) { return(Array.CreateInstance(type.GetElementType(), 0)); } return(Activator.CreateInstance(type)); }
public void Serialize(object instance, IKey inKey, ILogPrinter inLogger) { Type type = instance.GetType(); Serialize(instance, type, inKey, 0, inLogger); //if (inKey.GetChildCount() == 1 && type.IsClass && string.IsNullOrEmpty(inKey.GetName())) // inKey.SetName(type.Name); }
public void WriteKey(IKey key, object instance, ILogPrinter inLogger) { NamedId[] arr = (NamedId[])instance; for (int i = 0; i < arr.Length; i++) { key.AddValue(arr[i].name); } }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { base.PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Keyword, (definition.isUnion ? "union" : "struct")); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, Name); printer.Print(OutputType.Operator, ";"); }
public override void PrintLog(ILogPrinter logPrinter, PrintFlags flags, string messagePrefix) { base.PrintLog(logPrinter, flags, messagePrefix); if (arrayKind != ArrayKind.Invalid) { elementType.PrintLog(logPrinter, flags, messagePrefix); } }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); base.PrintTo(printer, logPrinter, flags); switch (arrayKind) { case ArrayKind.Invalid: { // void */PVOID PrimitiveNativeType.PrintNameTo(TypeName.Void, 1, printer, flags); break; } case ArrayKind.SafeArray: { // prefix with const if in-only if (isInOnly) { printer.Print(OutputType.Keyword, "const"); printer.Print(OutputType.Other, " "); } // SAFEARRAY * or LPSAFEARRAY if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) { TypeName.PrintTo(printer, TypeName.SafeArray.PlainC); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, "*"); } else { TypeName.PrintTo(printer, "LP" + TypeName.SafeArray.WinApi); } break; } default: { elementType.PrintTo(printer, logPrinter, flags); break; } } if (indirections > 0) { // We'll suppress the [] suffix in this case; one indirection will be provided by the // element itself because the ByRefParam flag has been inherited by it. int stars = indirections; while (stars-- > 0) { printer.Print(OutputType.Operator, "*"); } } }
/// <summary> /// Prints one method to the provided printers according to the current settings. /// </summary> private void PrintMethod(MethodDescriptor descriptor, ICodePrinter printer, ILogPrinter logPrinter, bool printDefs, bool defsFirst) { // this is a node representing a method - get the signature (cached by the descriptor) SignatureGenerator.NativeSignature native_sig = descriptor.GetNativeSignature( aNSITargetPlatformToolStripMenuItem.Checked, bit64TargetPlatformToolStripMenuItem.Checked); PrintSignature(native_sig, printer, logPrinter, printDefs, defsFirst); }
public object ReadKey(IKey key, ILogPrinter inLogger) { Vector3 v = new Vector3(); v.x = key.GetValue(0).ToFloat(); v.y = key.GetValue(1).ToFloat(); v.z = key.GetValue(2).ToFloat(); return(v); }
//public string SerializeToCascade(object instance, string inRootName, ILogPrinter inLogger) public string SerializeToCascade(object instance, ILogPrinter inLogger) { //IKey key = SerializeToKey(instance, string.Empty, inLogger); IKey key = IKeyFactory.CreateArrayKey(null); Serialize(instance, key, inLogger); string text = key.SaveToString(); return(text); }
/// <summary> /// Initializes a new instance of the WsDiscoveryService class with logger and specified transport type /// </summary> /// <param name="transportType"> The transport type</param> /// <param name="logger"> The logger</param> public WsDiscoveryService(TransportType transportType, ILogPrinter logger) : this(transportType) { if (null == logger) { throw new ArgumentNullException("logger", "The input parameter \"logger\" is null."); } this.logger = logger; }
public override object Instantiate(Type type, ILogPrinter inLogger) { var ctor = EmitHelper.CreateParameterlessConstructorHandler(type, inLogger); if (ctor == null) { return(null); } return(ctor()); }
public void DeserializationFromCscd(IKey key, ILogPrinter inLogger) { if (key.GetValuesCount() != 3) { return; } x = key.GetValue(0).ToFloat(); y = key.GetValue(1).ToFloat(); z = key.GetValue(2).ToFloat(); }
public Map(GameEngine game, ILogPrinter lp, Vector2 size = default(Vector2)) : base(game) { if (size == default(Vector2)) { size = new Vector2(50, 50); } this.Game = game; this.fullBoard = new ListGameAware <MapComponent>(game); this.SizeOfMap = size; }
/// <summary> /// Prints one delegate to the provided printers according to the current settings. /// </summary> private void PrintDelegate(TypeDescriptor descriptor, ICodePrinter printer, ILogPrinter logPrinter, bool printDefs, bool defsFirst) { Debug.Assert(descriptor.IsDelegate); // this is a node representing a delegate - get the signature (cached by the descriptor) SignatureGenerator.NativeSignature native_sig = descriptor.GetNativeSignature( aNSITargetPlatformToolStripMenuItem.Checked, bit64TargetPlatformToolStripMenuItem.Checked); PrintSignature(native_sig, printer, logPrinter, printDefs, defsFirst); }
public object ReadKey(IKey key, ILogPrinter inLogger) { int count = key.GetValuesCount(); var arr = new NamedId[count]; for (int i = 0; i < count; i++) { arr[i] = NamedId.GetNamedId(key.GetValueAsString(i)); } return(arr); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); Debug.Assert(fields != null); printer.Print(OutputType.Keyword, "enum"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.TypeName, name); printer.Print(OutputType.Other, " "); // always explicitly print the underlying type printer.Print(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); underlyingType.PrintTo(printer, logPrinter, flags); printer.PrintLn(); printer.Indent(); printer.Print(OutputType.Operator, "{"); try { decimal next_value = 0; for (int i = 0; i < fields.Length; i++) { // field name [ = field value ][,] printer.PrintLn(); if (isFlagsEnum) { // explicitly list all field values for [Flags] enums next_value = Decimal.MaxValue; } fields[i].PrintTo(printer, flags, ref next_value); if (i < fields.Length - 1) { // comma after all but the last field printer.Print(OutputType.Operator, ","); } } } finally { printer.Unindent(); printer.PrintLn(); printer.Print(OutputType.Operator, "};"); } }
/// <summary> /// Initializes a new instance of the HttpClientTransport class. /// Constructor of class HttpClientTransport to generate HTTP or HTTPs URI. /// </summary> /// <param name="transfer">Indicates the transfer protocol is HTTP or HTTPs.</param> /// <param name="serverAddress">The address of HTTP server.</param> /// <param name="port">The port number of HTTP server.</param> /// <param name="fileName">The requested file name.</param> /// <param name="logger">An instance of ILogPrinter.</param> public HttpClientTransport( TransferProtocol transfer, string serverAddress, int port, string fileName, ILogPrinter logger) : this(transfer, serverAddress, port, fileName, null, null, null) { if (null == logger) { throw new ArgumentNullException("logger", "The input parameter \"logger\" is null."); } this.logger = logger; this.logger.AddInfo("The HTTP client transport is created successfully."); }
/// <summary> /// Initializes a new instance of the PccrtpServer class with specified logger instance. /// </summary> /// <param name="listenPort">Indicates the PCCRTP server's listen port.</param> /// <param name="addressType">Indicates the PCCRTP server's address type is Ipv4 or Ipv6.</param> /// <param name="logger">An instance of ILogPrinter.</param> public PccrtpServer(int listenPort, IPAddressType addressType, ILogPrinter logger) { if (logger == null) { throw new ArgumentNullException("logger", "The input parameter \"logger\" is null."); } this.logger = logger; this.httpServerTransport = new HttpServerTransport( TransferProtocol.HTTP, listenPort, addressType, null, this.logger); this.httpServerTransport.HttpRequestEventHandle += new EventHandler<HttpRequestEventArg>(this.OnHttpRequestMessageReceived); }
public void PrintTo(ILogPrinter logPrinter) { if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); logPrinter.PrintEntry(Severity, ErrorCode, Message); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); Debug.Assert(signature != null); if (hasForwardDeclaration) { printer.Print(OutputType.Keyword, "struct"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.Identifier, Name); printer.Indent(); printer.PrintLn(OutputType.Operator, "{"); // will print "ret_type (call_conv *ptr)(params)" signature.PrintTo(printer, logPrinter, flags); printer.Unindent(); printer.PrintLn(); printer.Print(OutputType.Operator, "};"); } else { printer.Print(OutputType.Keyword, "typedef"); printer.Print(OutputType.Other, " "); // will print "ret_type (call_conv *name)(params)" signature.PrintTo(printer, logPrinter, flags); } }
/// <summary> /// Initializes a new instance of the HttpServerTransport class. /// </summary> /// <param name="transferProtocol">The transport type will be used</param> /// <param name="listenPort">The listen port.</param> /// <param name="ipaddressType">The IP address type.</param> /// <param name="resource">The resource.</param> /// <param name="logger">The logger.</param> public HttpServerTransport( TransferProtocol transferProtocol, int listenPort, IPAddressType ipaddressType, string resource, ILogPrinter logger) { if (logger == null) { throw new ArgumentNullException("logger", "The input parameter \"logger\" is null."); } this.logger = logger; this.httpListener = new HttpListener(); string prefix = this.GetListenPrefix(transferProtocol, listenPort, resource); this.httpListener.Prefixes.Add(prefix); this.logger.AddDebug(string.Format( "Initialize the http server transport and add prefix: {0} to http listener.", prefix)); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); if (isUndefined && (flags & PrintFlags.UseDefinedComInterfaces) == PrintFlags.UseDefinedComInterfaces) { PrintNameTo(TypeName.IUnknown, indirections - 1, printer, flags); } else { PrintNameTo(typeName, indirections, printer, flags); } }
/// <summary> /// Initializes a new instance of the <see cref="PccrdServer"/>class /// </summary> /// <param name="logger"> The specified logger.</param> public PccrdServer(ILogPrinter logger) { this.service = new WsDiscoveryService(logger); this.service.MessageArrived += new MessageArrivedEventArgs(this.HandleRequest); }
/// <summary> /// Initializes a new instance of the <see cref="WsDiscoveryClient"/> class /// </summary> /// <param name="logger">A instance used to output log</param> public WsDiscoveryClient(ILogPrinter logger) : this(TransportType.SoapOverUdp, logger) { }
/// <summary> /// Initializes a new instance of the PccrtpClient class. /// </summary> /// <param name="logger">An instance of ILogPrinter.</param> public PccrtpClient(ILogPrinter logger) { this.logger = logger; }
public void Print(ILogPrinter printer, string messagePrefix) { Debug.Assert(printer != null); foreach (LogEntry entry in Entries()) { if (!String.IsNullOrEmpty(messagePrefix)) { printer.PrintEntry(entry.Severity, entry.ErrorCode, String.Format("{0}: {1}", messagePrefix, entry.Message)); } else { printer.PrintEntry(entry.Severity, entry.ErrorCode, entry.Message); } } }
/// <summary> /// Initializes a new instance of the PCHCClient class /// With the specified http transport type, server name, linsten port number and resource. /// </summary> /// <param name="httpTransportType">Http transport type.</param> /// <param name="serverName">The server name.</param> /// <param name="port">The listening port.</param> /// <param name="resource">The resource.</param> /// <param name="logger">The logger.</param> public PCHCClient(TransferProtocol httpTransportType, string serverName, int port, string resource, ILogPrinter logger) { if (logger == null) { throw new ArgumentNullException("logger", "The input parameter \"logger\" is null."); } this.logger = logger; if (httpTransportType != TransferProtocol.HTTP && httpTransportType != TransferProtocol.HTTPS) { throw new ArgumentException( "httpTransportType contains invalid not supported transport type", "httpTransportType"); } this.httpClientTransport = new HttpClientTransport(httpTransportType, serverName, port, resource, logger); }
/// <summary> /// Dispose(bool disposing) executes in two distinct scenarios. /// If disposing equals true, the method has been called directly /// or indirectly by a user's code. Managed and unmanaged resources /// can be disposed. /// If disposing equals false, the method has been called by the /// runtime from inside the finalizer and you should not reference /// other objects. Only unmanaged resources can be disposed /// </summary> /// <param name="disposing">Specify which scenario is used.</param> private void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { if (this.logger != null) { this.logger = null; } if (this.RunState != State.Stopped) { this.StopHttpServer(); } if (this.httpRequestManagerThread != null) { this.httpRequestManagerThread.Abort(); this.httpRequestManagerThread = null; } if (this.httpListener != null) { this.httpListener.Close(); this.httpListener = null; } } } // Note disposing has been done. this.disposed = true; }
/// <summary> /// Initializes a new instance of the PCHCServer class /// with the specified osted Cache Mode Listen Port and IPAddress type. /// </summary> /// <param name="transferProtocol">The transport type will be used</param> /// <param name="hostedCacheModeListenPort"> /// The specified BranchCache service's listen port in hosted cache mode. /// </param> /// <param name="ipaddressType">The IP address type.</param> /// <param name="logger">The logger.</param> public PCHCServer( TransferProtocol transferProtocol, int hostedCacheModeListenPort, IPAddressType ipaddressType, ILogPrinter logger) { if (logger == null) { throw new ArgumentNullException("logger", "The input parameter \"logger\" is null."); } this.logger = logger; this.httpServerTransport = new HttpServerTransport( transferProtocol, hostedCacheModeListenPort, ipaddressType, PCHCRESOURCE, logger); this.httpServerTransport.HttpRequestEventHandle += new EventHandler<HttpRequestEventArg>(this.ReceiveHttpRequest); this.logger.AddDebug(@"Register the delegate EventHandle with generic parameter HttpRequestEverntArg and the handle method is ReceiveHttpRequest."); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); printer.Print(OutputType.Identifier, "MIDL_INTERFACE"); printer.Print(OutputType.Operator, "("); printer.Print(OutputType.Literal, Utility.StringToLiteral("FB6AB00F-5096-3AF8-A33D-D7885A5FA829")); printer.PrintLn(OutputType.Operator, ")"); printer.Print(OutputType.TypeName, InterfaceName); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Keyword, "public"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.TypeName, "IDispatch"); printer.PrintLn(OutputType.Operator, "{"); printer.Print(OutputType.Keyword, "public"); printer.PrintLn(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.Comment, "// methods omitted"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Keyword, "virtual"); printer.Print(OutputType.Other, " "); new PrimitiveNativeType(TypeName.Error, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) printer.Print(OutputType.Keyword, "__stdcall"); else printer.Print(OutputType.TypeName, "STDMETHODCALLTYPE"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "DynamicInvoke"); printer.Print(OutputType.Operator, "("); new PrimitiveNativeType(TypeName.SafeArray, 1, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "args"); printer.Print(OutputType.Operator, ","); printer.Print(OutputType.Other, " "); new PrimitiveNativeType(TypeName.Variant, 1, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "pRetVal"); printer.Print(OutputType.Operator, ")"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, "="); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Literal, "0"); printer.PrintLn(OutputType.Operator, ";"); printer.Print(OutputType.Operator, "};"); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); base.PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Keyword, "struct"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, Name); printer.Print(OutputType.Operator, ";"); }
/// <summary> /// Initializes a new instance of the PCHCServer class /// with specified logger instance and the default transport type: Https; hosted cache server listen port: 443; IPAddress type: IPv4; /// </summary> /// <param name="logger">The logger.</param> public PCHCServer(ILogPrinter logger) : this(TransferProtocol.HTTPS, 443, IPAddressType.IPv4, logger) { }
public void Print(ILogPrinter printer, string messagePrefix) { if (printer == null) throw new ArgumentNullException(nameof(printer)); foreach (LogEntry entry in Entries()) { if (!String.IsNullOrEmpty(messagePrefix)) { printer.PrintEntry(entry.Severity, entry.ErrorCode, String.Format("{0}: {1}", messagePrefix, entry.Message)); } else { printer.PrintEntry(entry.Severity, entry.ErrorCode, entry.Message); } } }
/// <summary> /// Initializes a new instance of the <see cref="WsDiscoveryClient"/> class /// </summary> /// <param name="transportType">Transport type</param> /// <param name="logger">A instance used to output log</param> public WsDiscoveryClient(TransportType transportType, ILogPrinter logger) : this(transportType) { if (null == logger) { throw new ArgumentNullException("logger", "The input parameter \"logger\" is null."); } this.logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="PccrdClient"/>class with logger /// </summary> /// <param name="logger">The logger record the debug information</param> public PccrdClient(ILogPrinter logger) { this.discoveryClient = new WsDiscoveryClient(logger); this.discoveryClient.MessageArrived += new MessageArrivedEventArgs(this.ReceiveMessage); }
/// <summary> /// Initializes a new instance of the <see cref="PccrrServer"/> class. /// </summary> /// <param name="serverPort">The server port.</param> /// <param name="pccrrPath">The pccrr path.</param> /// <param name="addressType">The IP address type.</param> /// <param name="logger">The specified logger.</param> public PccrrServer( int serverPort, string pccrrPath, IPAddressType addressType, ILogPrinter logger) { if (pccrrPath == null) { throw new ArgumentNullException("pccrrPath"); } if (logger == null) { throw new ArgumentNullException("logger"); } this.serverPort = serverPort; this.url = pccrrPath; this.addressType = addressType; this.logger = logger; this.httpServerTransport = new HttpServerTransport(TransferProtocol.HTTP, serverPort, addressType, pccrrPath, logger); this.httpServerTransport.HttpRequestEventHandle += new EventHandler<HttpRequestEventArg>(this.HttpServerTransport_ReceiveFrom); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); if (isUndefined && (flags & PrintFlags.UseDefinedComInterfaces) == PrintFlags.UseDefinedComInterfaces) { PrintNameTo(TypeName.IUnknown, indirections - 1, printer, flags); } else { PrintNameTo(typeName, indirections, printer, flags); } }
static void Main(string[] args) { options = new CommandLineOptions(args); // code will go to standard output if (options.UseColorConsoleOutput) { var console_printer = new ConsolePrinter(); codePrinter = console_printer; logPrinter = console_printer; // ConsolePrinter writes log to stderr } else { codePrinter = new TextWriterPrinter(Console.Out); logPrinter = new TextWriterPrinter(Console.Error); } try { string assembly_path = options.AssemblyFilePath; Debug.Assert(!String.IsNullOrEmpty(assembly_path)); // load the assembly try { assembly = Assembly.Load(assembly_path); } catch (Exception) { assembly = null; } if (assembly == null) { try { assembly = Assembly.LoadFrom(assembly_path); } catch (Exception e) { LogLoadException(e, false, options.AssemblyFilePath); } } if (assembly != null) { Generate(); } } finally { IDisposable disp = logPrinter as IDisposable; if (disp != null) disp.Dispose(); disp = codePrinter as IDisposable; if (disp != null) disp.Dispose(); } #if DEBUG // wait for Enter only if we run under VS if (Process.GetCurrentProcess().MainModule.ModuleName.Contains("vshost")) { Console.ReadLine(); } #endif }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); base.PrintTo(printer, logPrinter, flags); switch (arrayKind) { case ArrayKind.Invalid: { // void */PVOID PrimitiveNativeType.PrintNameTo(TypeName.Void, 1, printer, flags); break; } case ArrayKind.SafeArray: { // prefix with const if in-only if (isInOnly) { printer.Print(OutputType.Keyword, "const"); printer.Print(OutputType.Other, " "); } // SAFEARRAY * or LPSAFEARRAY if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) { TypeName.PrintTo(printer, TypeName.SafeArray.PlainC); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, "*"); } else { TypeName.PrintTo(printer, "LP" + TypeName.SafeArray.WinApi); } break; } default: { elementType.PrintTo(printer, logPrinter, flags); break; } } if (indirections > 0) { // We'll suppress the [] suffix in this case; one indirection will be provided by the // element itself because the ByRefParam flag has been inherited by it. int stars = indirections; while (stars-- > 0) printer.Print(OutputType.Operator, "*"); } }
public void PrintTo(ILogPrinter logPrinter, params object[] args) { if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); logPrinter.PrintEntry(Severity, ErrorCode, String.Format(Message, args)); }