public static string[] FindServices(Type serviceType) { LoggingManager.Debug("Looking for service of type " + serviceType.FullName); try { DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint()); var discoveredServices = discoveryClient.Find(new FindCriteria(serviceType)); discoveryClient.Close(); var serviceEndpointAdresses = discoveredServices.Endpoints.Select(e => e.Address.ToString()); if (!serviceEndpointAdresses.Any()) { LoggingManager.Debug("No service of type " + serviceType.FullName); } else { LoggingManager.Debug("Found services."); } return(serviceEndpointAdresses.ToArray()); } catch (Exception ex) { LoggingManager.LogSciendoSystemError(ex); throw; } }
public static void Send(object sdu) { MessageStruct?pdu = null; switch (sdu) { case ActionStruct ass: pdu = PDU(MessageType.action, JsonConvert.SerializeObject(ass)); break; case LoggingStruct ls: pdu = PDU(MessageType.logging, JsonConvert.SerializeObject(ls)); break; case NurseryStruct ns: pdu = PDU(MessageType.nursery, JsonConvert.SerializeObject(ns)); break; case Pages.Settings.SettingStruct ss: pdu = PDU(MessageType.setting, JsonConvert.SerializeObject(ss)); break; default: LoggingManager.Warn("Invalid message SDU type"); break; } if (pdu != null) { if (!PipeBridge.Bridge.Post(JsonConvert.SerializeObject(pdu))) { cache.Enqueue(pdu); LoggingManager.Debug($"enqueue{pdu?.content}"); } } }
/// <summary> /// This acts on the client only /// </summary> /// <param name="reply"></param> /// <param name="correlationState"></param> public void AfterReceiveReply(ref Message reply, object correlationState) { if (ConfigAllows()) { LoggingManager.Debug(reply); } }
private static IEnumerable <Assembly> GetAssemblies(string assemblyFilters, char assemblyFiltersSeparator) { foreach (var assemblyFilter in assemblyFilters.Split(new[] { assemblyFiltersSeparator })) { var foundAssemblyForFilter = false; foreach (var fileName in GetFiles(assemblyFilter)) { Assembly assembly = null; try { assembly = Assembly.LoadFrom(fileName); foundAssemblyForFilter = true; } catch (Exception ex) { LoggingManager.LogSciendoSystemError("Assembly Load Error for assembly: " + fileName, ex); } if (assembly != null) { yield return(assembly); } } if (!foundAssemblyForFilter) { LoggingManager.Debug("No assembly found for filter " + assemblyFilter + " in folder: " + AppDomain.CurrentDomain.BaseDirectory + " or its bin sub folder."); } } }
/// <summary> /// This acts on the server only /// </summary> /// <param name="request"></param> /// <param name="channel"></param> /// <param name="instanceContext"></param> /// <returns></returns> public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { if (ConfigAllows()) { LoggingManager.Debug(request); } return(null); }
/// <summary> /// This acts on the client only /// </summary> /// <param name="request"></param> /// <param name="channel"></param> /// <returns></returns> public object BeforeSendRequest(ref Message request, IClientChannel channel) { if (ConfigAllows()) { LoggingManager.Debug(request); } return(null); }
public void LogDebug_Ok() { var expectedText = "I wrote something in here"; LoggingManager.Debug(expectedText); using (TextReader tr = File.OpenText("SciendoCoreDebug.log")) { var lineLogged = tr.ReadLine(); Assert.True(lineLogged.Contains(expectedText)); } }
public void Debug_Calls_ILoggingProvider_Level_Debug() { var loggingProviderMock1 = new Mock<ILoggingProvider>(); var loggingProviderMock2 = new Mock<ILoggingProvider>(); var loggingManager = new LoggingManager(new[] { loggingProviderMock1.Object, loggingProviderMock2.Object }); loggingManager.Debug(this, "message"); loggingProviderMock1.Verify(x => x.Log(LogLevel.Debug, this, "message"), Times.Exactly(1)); loggingProviderMock2.Verify(x => x.Log(LogLevel.Debug, this, "message"), Times.Exactly(1)); }
public static void Initialize() { PipeBridge.Bridge.PipeOpened += (s, e) => { while (cache.Count > 0) { PipeBridge.Bridge.Post(JsonConvert.SerializeObject(cache.Dequeue())); LoggingManager.Debug($"dequeue"); } }; }
/// <summary> /// returns a channelFactory that connects to a service of contract type T /// identified by the given endpointName /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public ChannelFactory <T> GetChannelFactory <T>(string serverAddress, List <IEndpointBehavior> endpointBehaviors) { LoggingManager.Debug("Trying to get channelfactory for endpoint: " + serverAddress); ChannelFactory <T> channelFactory; if (!TryGetChannelFactory(serverAddress, out channelFactory)) { channelFactory = CreateAndCache <T>(serverAddress, endpointBehaviors); } LoggingManager.Debug("Got channel factory for:" + channelFactory.Endpoint.Address); return(channelFactory); }
/// <summary> /// This acts on the server only /// </summary> /// <param name="reply"></param> /// <param name="correlationState"></param> public void BeforeSendReply(ref Message reply, object correlationState) { try { if (ConfigAllows()) { LoggingManager.Debug(reply); } } catch { //swallow everything to return whatever comes from the server to client } }
/// <summary> /// returns a channelFactory that connects to a service of contract type T /// identified by the given endpointName /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public DuplexChannelFactory <T> GetChannelFactory(string serverAddress, List <IEndpointBehavior> endpointBehaviors, InstanceContext callbackInstance) { LoggingManager.Debug("Trying to get channelfactory for endpoint: " + serverAddress); DuplexChannelFactory <T> channelFactory; if (!TryGetChannelFactory(serverAddress, out channelFactory)) { channelFactory = CreateAndCache(serverAddress, endpointBehaviors, callbackInstance); } LoggingManager.Debug("Got channel factory for:" + channelFactory.Endpoint.Address); return(channelFactory); }
public void InitiateUsingServerAddress(string serverAddress) { LoggingManager.Debug("Initating using serverAddress: " + serverAddress); using (LoggingManager.LogSciendoPerformance()) { ChannelFactory <T> channelFactory; try { channelFactory = ChannelFactoryPool.Instance.GetChannelFactory <T>(serverAddress, GetEndpointBehaviors()); } catch (Exception ex) { throw ex; } Proxy = channelFactory.CreateChannel(); _channel = (ICommunicationObject)Proxy; } }
public void InitiateDuplexUsingServerAddress(string serverAddress, InstanceContext callbackInstance) { LoggingManager.Debug("Initating duplex using serverAddress: " + serverAddress); using (LoggingManager.LogSciendoPerformance()) { DuplexChannelFactory <T> channelFactory; try { channelFactory = DuplexChannelFactoryPool <T> .Instance.GetChannelFactory(serverAddress, GetEndpointBehaviors(), callbackInstance); } catch (Exception ex) { throw ex; } Proxy = channelFactory.CreateChannel(); _channel = (ICommunicationObject)Proxy; ((IContextChannel)Proxy).OperationTimeout = TimeSpan.FromSeconds(15); } }
public ConfiguredContainer AddAllFromFilteredAssemblies <T>(LifeStyle lifeStyle, string additionalQualifier = null) { if (LoadedAssemblies != null && LoadedAssemblies.Any()) { foreach (var key in LoadedAssemblies.Keys) { var regTypes = _scanner.From(LoadedAssemblies[key].Distinct(new AssemblyEqualityComparer()).ToArray()) .BasedOn <T>() .IdentifiedBy(key + ((additionalQualifier) ?? "")) .With(lifeStyle).ToArray(); if (!regTypes.Any()) { LoggingManager.Debug( string.Format( "No {0} implementation found in any of the assemblies {1} registered under they key: {2}", typeof(T).FullName, string.Join(", ", LoadedAssemblies[key].Select(a => a.FullName)), key) ); } _container.Add(regTypes); } } return(this); }
private static void ConfirmStop(string pathName) { LoggingManager.Debug(pathName); NurseryPage.Page.TogglSwitch(pathName, false); }
private void OpenServiceHost(ServiceHost serviceHost) { serviceHost.Open(); LoggingManager.Debug("Opened Host: " + serviceHost.BaseAddresses[0].ToString()); }
private void CloseServiceHost(ServiceHost serviceHost) { LoggingManager.Debug("Closed Host: " + serviceHost.BaseAddresses[0].ToString()); serviceHost.Close(); }