public void RegisterCore(IEtpSession session) { if (session.IsClient) { session.Register <ICoreClient, CoreClientHandler>(); } else { session.Register <ICoreServer, CoreServerHandler>(); } }
/// <summary> /// Resolves the discovery store handler. /// </summary> /// <param name="etpSession">The ETP session.</param> /// <param name="container">The composition container.</param> /// <param name="contractName">The contract name.</param> /// <param name="callback">The callback.</param> /// <returns>An <see cref="IProtocolHandler"/> instance.</returns> public static IProtocolHandler RegisterDiscoveryStore(this IEtpSession etpSession, IContainer container, string contractName = null, Action <IProtocolHandler> callback = null) { if (etpSession.SupportedVersion == EtpVersion.v11) { var handler = container.Resolve <Energistics.Etp.v11.Protocol.Discovery.IDiscoveryStore>(contractName); callback?.Invoke(handler); etpSession.Register(() => handler); return(handler); } else { var handler = container.Resolve <Energistics.Etp.v12.Protocol.Discovery.IDiscoveryStore>(contractName); callback?.Invoke(handler); etpSession.Register(() => handler); return(handler); } }
/// <summary> /// Registers the channel data load producer. /// </summary> /// <param name="etpSession">The ETP session.</param> /// <param name="container">The composition container.</param> /// <param name="contractName">The contract name.</param> /// <param name="callback">The callback.</param> /// <returns></returns> public static IDataLoadProducer RegisterChannelDataLoadProducer(this IEtpSession etpSession, IContainer container, string contractName = null, Action <IDataLoadProducer> callback = null) { var handler = container.Resolve <Energistics.Etp.v12.Protocol.ChannelDataLoad.IChannelDataLoadProducer>(contractName); var producer = handler as IDataLoadProducer; callback?.Invoke(producer); etpSession.Register(() => handler); return(producer); }
/// <summary> /// Registers the store customer. /// </summary> /// <param name="etpSession">The ETP session.</param> /// <param name="container">The container.</param> /// <param name="contractName">Name of the contract.</param> /// <param name="callback">The callback.</param> /// <returns></returns> public static IEtpStoreCustomer RegisterStoreCustomer(this IEtpSession etpSession, IContainer container, string contractName = null, Action <IEtpStoreCustomer> callback = null) { if (etpSession.SupportedVersion == EtpVersion.v11) { var handler = container.Resolve <Energistics.Etp.v11.Protocol.Store.IStoreCustomer>(contractName); var customer = handler as IEtpStoreCustomer; callback?.Invoke(customer); etpSession.Register(() => handler); return(customer); } else { var handler = container.Resolve <Energistics.Etp.v12.Protocol.Store.IStoreCustomer>(contractName); var customer = handler as IEtpStoreCustomer; callback?.Invoke(customer); etpSession.Register(() => handler); return(customer); } }
/// <summary> /// Resolves the channel streaming producer handler. /// </summary> /// <param name="etpSession">The ETP session.</param> /// <param name="container">The composition container.</param> /// <param name="contractName">The contract name.</param> /// <param name="callback">The callback.</param> /// <returns>An <see cref="IStreamingProducer"/> instance.</returns> public static IStreamingProducer RegisterChannelStreamingProducer(this IEtpSession etpSession, IContainer container, string contractName = null, Action <IStreamingProducer> callback = null) { if (etpSession.SupportedVersion == EtpVersion.v11) { var handler = container.Resolve <Energistics.Etp.v11.Protocol.ChannelStreaming.IChannelStreamingProducer>(contractName); var producer = handler as IStreamingProducer; callback?.Invoke(producer); etpSession.Register(() => handler); return(producer); } else { var handler = container.Resolve <Energistics.Etp.v12.Protocol.ChannelStreaming.IChannelStreamingProducer>(contractName); var producer = handler as IStreamingProducer; callback?.Invoke(producer); etpSession.Register(() => handler); return(producer); } }