Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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}");
                }
            }
        }
Esempio n. 3
0
 /// <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);
     }
 }
Esempio n. 4
0
 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.");
         }
     }
 }
Esempio n. 5
0
 /// <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);
 }
Esempio n. 6
0
 /// <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);
 }
Esempio n. 7
0
        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));
		}
Esempio n. 9
0
 public static void Initialize()
 {
     PipeBridge.Bridge.PipeOpened += (s, e) =>
     {
         while (cache.Count > 0)
         {
             PipeBridge.Bridge.Post(JsonConvert.SerializeObject(cache.Dequeue()));
             LoggingManager.Debug($"dequeue");
         }
     };
 }
Esempio n. 10
0
        /// <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);
        }
Esempio n. 11
0
 /// <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
     }
 }
Esempio n. 12
0
        /// <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);
        }
Esempio n. 13
0
        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;
            }
        }
Esempio n. 14
0
        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);
            }
        }
Esempio n. 15
0
 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);
 }
Esempio n. 16
0
 private static void ConfirmStop(string pathName)
 {
     LoggingManager.Debug(pathName);
     NurseryPage.Page.TogglSwitch(pathName, false);
 }
Esempio n. 17
0
 private void OpenServiceHost(ServiceHost serviceHost)
 {
     serviceHost.Open();
     LoggingManager.Debug("Opened Host: " + serviceHost.BaseAddresses[0].ToString());
 }
Esempio n. 18
0
 private void CloseServiceHost(ServiceHost serviceHost)
 {
     LoggingManager.Debug("Closed Host: " + serviceHost.BaseAddresses[0].ToString());
     serviceHost.Close();
 }