/// <summary>
        /// Find the object to pass the method call through to.
        /// </summary>
        /// <typeparam name="T">Type implementing method.</typeparam>
        /// <param name="query">Query string in URI format.</param>
        /// <param name="wcfserviceParams">WCF service connection parameters.</param>
        /// <param name="services">Object registry.</param>
        /// <param name="createService1">Function to create Dbus Service taking service connection parameters.</param>
        /// <param name="createService2">Function to create Dbus Service taking service connection parameters and Dbus connection parameters.</param>
        /// <param name="defaultConnectionParameters">Default Dbus connection parameters for Dbus Service.</param>
        /// <returns>Object implementing method.</returns>
        static public T GetWCFMethodTarget <T>(string query
                                               , Udbus.WCF.Host.WCFServiceParams wcfserviceParams
                                               , System.Collections.Generic.IDictionary <DbusServiceKey, T> services
                                               , System.Func <Udbus.Core.ServiceConnectionParams, T> createService1
                                               , System.Func <Udbus.Core.ServiceConnectionParams, Udbus.Serialization.DbusConnectionParameters, T> createService2
                                               , Udbus.Serialization.ReadonlyDbusConnectionParameters defaultConnectionParameters)
        {
            // Look for query parameters.
            string busnameValue;
            string pathValue;

            GetDbusParametersFromQuery(query, out busnameValue, out pathValue);

            // Lookup existing service.
            DbusServiceKey find = new DbusServiceKey(busnameValue, pathValue);
            T result;

            if (services.TryGetValue(find, out result) == false) // If object not in registry
            {
                result = CreateDbusService(wcfserviceParams, createService1, createService2, defaultConnectionParameters, busnameValue, pathValue);

                // Store new service for future generations.
                services[find] = result;
            } // Ends if object not in registry

            return(result);
        }
 /// <summary>
 /// Create a Dbus Service based on the supplied parameters.
 /// </summary>
 /// <typeparam name="T">Dbus Service type.</typeparam>
 /// <param name="wcfserviceParams">WCF service connection parameters.</param>
 /// <param name="createService1">Function to create Dbus Service taking service connection parameters.</param>
 /// <param name="createService2">Function to create Dbus Service taking service connection parameters and Dbus connection parameters.</param>
 /// <param name="defaultConnectionParameters">Default Dbus connection parameters for Dbus Service.</param>
 /// <returns>new Dbus Service instance.</returns>
 public static T CreateDbusService <T>(Udbus.WCF.Host.WCFServiceParams wcfserviceParams
                                       , System.Func <Udbus.Core.ServiceConnectionParams, T> createService1
                                       , System.Func <Udbus.Core.ServiceConnectionParams, Udbus.Serialization.DbusConnectionParameters, T> createService2
                                       , Udbus.Serialization.ReadonlyDbusConnectionParameters defaultConnectionParameters)
 {
     return(CreateDbusService(System.ServiceModel.OperationContext.Current.IncomingMessageHeaders.To.Query,
                              wcfserviceParams, createService1, createService2, defaultConnectionParameters));
 }
 /// <summary>
 /// Find the object to pass the method call through to, using query information embedded in current WCF method invocation.
 /// </summary>
 /// <typeparam name="T">Type implementing method.</typeparam>
 /// <param name="wcfserviceParams">WCF service connection parameters.</param>
 /// <param name="services">Object registry.</param>
 /// <param name="createService1">Function to create Dbus Service taking service connection parameters.</param>
 /// <param name="createService2">Function to create Dbus Service taking service connection parameters and Dbus connection parameters.</param>
 /// <param name="defaultConnectionParameters">Default Dbus connection parameters for Dbus Service.</param>
 /// <returns>Object implementing method.</returns>
 static public T GetWCFMethodTarget <T>(Udbus.WCF.Host.WCFServiceParams wcfserviceParams
                                        , System.Collections.Generic.IDictionary <DbusServiceKey, T> services
                                        , System.Func <Udbus.Core.ServiceConnectionParams, T> createService1
                                        , System.Func <Udbus.Core.ServiceConnectionParams, Udbus.Serialization.DbusConnectionParameters, T> createService2
                                        , Udbus.Serialization.ReadonlyDbusConnectionParameters defaultConnectionParameters)
 {
     return(GetWCFMethodTarget(System.ServiceModel.OperationContext.Current.IncomingMessageHeaders.To.Query,
                               wcfserviceParams, services, createService1, createService2, defaultConnectionParameters));
 }
        /// <summary>
        /// Create a Dbus Service based on the supplied parameters.
        /// </summary>
        /// <typeparam name="T">Dbus Service type.</typeparam>
        /// <param name="query">Query string in URI format.</param>
        /// <param name="wcfserviceParams">WCF service connection parameters.</param>
        /// <param name="createService1">Function to create Dbus Service taking service connection parameters.</param>
        /// <param name="createService2">Function to create Dbus Service taking service connection parameters and Dbus connection parameters.</param>
        /// <param name="defaultConnectionParameters">Default Dbus connection parameters for Dbus Service.</param>
        /// <returns>new Dbus Service instance.</returns>
        public static T CreateDbusService <T>(string query
                                              , Udbus.WCF.Host.WCFServiceParams wcfserviceParams
                                              , System.Func <Udbus.Core.ServiceConnectionParams, T> createService1
                                              , System.Func <Udbus.Core.ServiceConnectionParams, Udbus.Serialization.DbusConnectionParameters, T> createService2
                                              , Udbus.Serialization.ReadonlyDbusConnectionParameters defaultConnectionParameters)
        {
            string busname;
            string path;

            GetDbusParametersFromQuery(query, out busname, out path);
            return(CreateDbusService(wcfserviceParams, createService1, createService2, defaultConnectionParameters, busname, path));
        }
        /// <summary>
        /// Create a Dbus Service based on the supplied parameters.
        /// </summary>
        /// <typeparam name="T">Dbus Service type.</typeparam>
        /// <param name="wcfserviceParams">WCF service connection parameters.</param>
        /// <param name="createService1">Function to create Dbus Service taking service connection parameters.</param>
        /// <param name="createService2">Function to create Dbus Service taking service connection parameters and Dbus connection parameters.</param>
        /// <param name="defaultConnectionParameters">Default Dbus connection parameters for Dbus Service.</param>
        /// <param name="busname">Dbus bus name for Dbus Service.</param>
        /// <param name="path">Dbus path for Dbus Service.</param>
        /// <returns>new Dbus Service instance.</returns>
        public static T CreateDbusService <T>(Udbus.WCF.Host.WCFServiceParams wcfserviceParams
                                              , System.Func <Udbus.Core.ServiceConnectionParams, T> createService1
                                              , System.Func <Udbus.Core.ServiceConnectionParams, Udbus.Serialization.DbusConnectionParameters, T> createService2
                                              , Udbus.Serialization.ReadonlyDbusConnectionParameters defaultConnectionParameters
                                              , string busname, string path)
        {
            T result;

            if (string.IsNullOrEmpty(busname) && string.IsNullOrEmpty(path)) // If no parameters provided
            {
                if (wcfserviceParams.DbusConnectionParameters.HasValue)      // If WCF Service was initialised with some settings
                {
                    // Create Dbus Service with WCF service's dbus connect settings.
                    result = createService2(wcfserviceParams.ServiceConnectionParams, wcfserviceParams.DbusConnectionParameters.Value);
                }    // Ends if WCF Service was initialised with some settings
                else // Else WCF Service was not initialised with some settings
                {
                    // Create Dbus Service with default dbus connect settings.
                    result = createService1(wcfserviceParams.ServiceConnectionParams);
                } // Ends else WCF Service was not initialised with some settings
            }     // Ends if no parameters provided
            else  // Else parameters provided
            {
                Udbus.Serialization.DbusConnectionParameters connectionParameters;
                if (wcfserviceParams.DbusConnectionParameters.HasValue) // If WCF Service was initialised with some settings
                {
                    // Use WCF service's dbus connect settings as starting point.
                    connectionParameters = wcfserviceParams.DbusConnectionParameters.Value;
                }    // Ends if WCF Service was initialised with some settings
                else // Else WCF Service was not initialised with some settings
                {
                    // Use default dbus connect settings as starting point.
                    connectionParameters = defaultConnectionParameters;
                } // Ends else WCF Service was not initialised with some settings

                if (!string.IsNullOrEmpty(busname)) // If busname supplied
                {
                    connectionParameters.Destination = busname;
                } // Ends if busname supplied

                if (!string.IsNullOrEmpty(path)) // If path supplied
                {
                    connectionParameters.Path = path;
                } // Ends if path supplied

                result = createService2(wcfserviceParams.ServiceConnectionParams, connectionParameters);
            } // Ends else parameters provided

            return(result);
        }
示例#6
0
 /// <summary>
 /// Replace the dbus connection parameters specified with those supplied at construction.
 /// </summary>
 /// <param name="wcfserviceparams">WCF Service creation paramters.</param>
 /// <param name="uriBase">Endpoing base addresses.</param>
 /// <returns>WCF ServiceHost with creation data.</returns>
 public Udbus.WCF.Service.Host.ServiceHostCreationData MakeServiceHostCreationData(Udbus.WCF.Host.WCFServiceParams wcfserviceparams, params Uri[] uriBase)
 {
     Udbus.WCF.Host.WCFServiceParams bam = new Udbus.WCF.Host.WCFServiceParams(wcfserviceparams.ServiceConnectionParams, this.dbusConnectionParams);
     return(this.target.MakeServiceHostCreationData(bam, uriBase));
 }
示例#7
0
 static public ICollection <Udbus.WCF.Service.Host.ServiceHostCreationData> BuildAllHosts(Udbus.WCF.Host.WCFServiceParams wcfserviceparams,
                                                                                          System.Uri uriBase, params Type[] exclude)
 {
     return(BuildAllHosts(wcfserviceparams, new System.Uri[] { uriBase }, exclude));
 }
 protected WCFDbusServiceBase(Udbus.WCF.Host.WCFServiceParams wcfserviceParams)
 {
     this.wcfserviceParams = wcfserviceParams;
 }
示例#9
0
 static public ICollection <Udbus.WCF.Service.Host.ServiceHostCreationData> BuildAllHosts(IEnumerable <Udbus.WCF.Service.Host.IMakeServiceHostCreationData> hostMakers,
                                                                                          Udbus.WCF.Host.WCFServiceParams wcfserviceparams, System.Uri uriBase, params Type[] exclude)
 {
     return(BuildAllHosts(hostMakers, wcfserviceparams, new System.Uri[] { uriBase }, exclude));
 }
示例#10
0
        /// <summary>
        /// Build ALL the hosts ? Well all the ones with entries in "hostMakers", apart from any excluded by WCF Service type at run time.
        /// </summary>
        /// <param name="hostMakers">Objects capable of making WCF ServiceHost instances.</param>
        /// <param name="wcfserviceparams">WCF service parameters.</param>
        /// <param name="uriBase">Endpoint base addresses.</param>
        /// <param name="exclude">WCF Service types to exclude from creation.</param>
        /// <returns>Collection of created ServiceHost instances with accompanying creation data.</returns>
        static public ICollection <Udbus.WCF.Service.Host.ServiceHostCreationData> BuildAllHosts(IEnumerable <Udbus.WCF.Service.Host.IMakeServiceHostCreationData> hostMakers,
                                                                                                 Udbus.WCF.Host.WCFServiceParams wcfserviceparams, System.Uri[] uriBase, params Type[] exclude)
        {
            List <Udbus.WCF.Service.Host.ServiceHostCreationData> hosts = new List <Udbus.WCF.Service.Host.ServiceHostCreationData>();

            foreach (Udbus.WCF.Service.Host.IMakeServiceHostCreationData maker in hostMakers)
            {
                if (!maker.ContainsService(exclude))
                {
                    hosts.Add(maker.MakeServiceHostCreationData(wcfserviceparams, uriBase));
                }
            }

            return(hosts);
        }
 /// <summary>
 /// Replace the dbus connection parameters specified with those supplied at construction.
 /// </summary>
 /// <param name="wcfserviceparams">WCF Service creation paramters.</param>
 /// <param name="uriBase">Endpoing base addresses.</param>
 /// <returns>WCF ServiceHost with creation data.</returns>
 public Udbus.WCF.Service.Host.ServiceHostCreationData MakeServiceHostCreationData(Udbus.WCF.Host.WCFServiceParams wcfserviceparams, params Uri[] uriBase)
 {
     Udbus.WCF.Host.WCFServiceParams bam = new Udbus.WCF.Host.WCFServiceParams(wcfserviceparams.ServiceConnectionParams, this.dbusConnectionParams);
     return this.target.MakeServiceHostCreationData(bam, uriBase);
 }
示例#12
0
 protected WCFDbusServiceBase(Udbus.WCF.Host.WCFServiceParams wcfserviceParams)
 {
     this.wcfserviceParams = wcfserviceParams;
 }
 public Udbus.WCF.Service.Host.ServiceHostCreationData MakeServiceHostCreationData(Udbus.WCF.Host.WCFServiceParams wcfserviceparams, params System.Uri[] uriBase)
 {
     Udbus.WCF.Service.Host.ServiceHostCreationData create = Udbus.WCF.Service.Host.DbusServiceHost.CreateWithData <global::XenClientGuestService.wcf.XenClientGuestWCFService>(CreateServiceCreationData
                                                                                                                                                                                , uriBase);
     return(create);
 }