コード例 #1
0
        /// <summary>Initializes a new instance of the NServiceKit.ServiceHost.ServiceController class.</summary>
        ///
        /// <param name="resolveServicesFn">The resolve services function.</param>
        /// <param name="metadata">         The metadata.</param>
        public ServiceController(Func <IEnumerable <Type> > resolveServicesFn, ServiceMetadata metadata = null)
        {
            this.Metadata = metadata ?? new ServiceMetadata();

            this.RequestTypeFactoryMap    = new Dictionary <Type, Func <IHttpRequest, object> >();
            this.EnableAccessRestrictions = true;
            this.ResolveServicesFn        = resolveServicesFn;
        }
コード例 #2
0
ファイル: TestBase.cs プロジェクト: Qasemt/NServiceKit
        /// <summary>Initializes a new instance of the NServiceKit.WebHost.Endpoints.Tests.Support.MetadataTestBase class.</summary>
		protected MetadataTestBase()
		{
            Metadata = new ServiceMetadata();
		    var dummyServiceType = GetType();
            Metadata.Add(dummyServiceType, typeof(GetCustomer), typeof(GetCustomerResponse));
            Metadata.Add(dummyServiceType, typeof(GetCustomers), typeof(GetCustomersResponse));
            Metadata.Add(dummyServiceType, typeof(StoreCustomer), null);
		}
コード例 #3
0
        /// <summary>Initializes a new instance of the NServiceKit.ServiceHost.MetadataPagesConfig class.</summary>
        ///
        /// <param name="metadata">          The metadata.</param>
        /// <param name="metadataConfig">    The metadata configuration.</param>
        /// <param name="ignoredFormats">    The ignored formats.</param>
        /// <param name="contentTypeFormats">The content type formats.</param>
        public MetadataPagesConfig(
            ServiceMetadata metadata,
            ServiceEndpointsMetadataConfig metadataConfig,
            HashSet <string> ignoredFormats,
            List <string> contentTypeFormats)
        {
            this.ignoredFormats = ignoredFormats;
            this.metadata       = metadata;

            metadataConfigMap = new Dictionary <string, MetadataConfig> {
                { "xml", metadataConfig.Xml },
                { "json", metadataConfig.Json },
                { "jsv", metadataConfig.Jsv },
                { "soap11", metadataConfig.Soap11 },
                { "soap12", metadataConfig.Soap12 },
            };

            AvailableFormatConfigs = new List <MetadataConfig>();

            var config = GetMetadataConfig("xml");

            if (config != null)
            {
                AvailableFormatConfigs.Add(config);
            }
            config = GetMetadataConfig("json");
            if (config != null)
            {
                AvailableFormatConfigs.Add(config);
            }
            config = GetMetadataConfig("jsv");
            if (config != null)
            {
                AvailableFormatConfigs.Add(config);
            }

            foreach (var format in contentTypeFormats)
            {
                metadataConfigMap[format] = metadataConfig.Custom.Create(format);

                config = GetMetadataConfig(format);
                if (config != null)
                {
                    AvailableFormatConfigs.Add(config);
                }
            }

            config = GetMetadataConfig("soap11");
            if (config != null)
            {
                AvailableFormatConfigs.Add(config);
            }
            config = GetMetadataConfig("soap12");
            if (config != null)
            {
                AvailableFormatConfigs.Add(config);
            }
        }
コード例 #4
0
        /// <summary>Renders the operations.</summary>
        ///
        /// <param name="writer">  The writer.</param>
        /// <param name="httpReq"> The HTTP request.</param>
        /// <param name="metadata">The metadata.</param>
		protected override void RenderOperations(HtmlTextWriter writer, IHttpRequest httpReq, ServiceMetadata metadata)
		{
			var defaultPage = new OperationsControl {
				Title = EndpointHost.Config.ServiceName,
                OperationNames = metadata.GetOperationNamesForMetadata(httpReq, Format),
				MetadataOperationPageBodyHtml = EndpointHost.Config.MetadataOperationPageBodyHtml,
			};

			defaultPage.RenderControl(writer);
		}
コード例 #5
0
        /// <summary>
        /// Inject alternative container and strategy for resolving Service Types
        /// </summary>
        public ServiceManager(Container container, ServiceController serviceController)
        {
            if (serviceController == null)
            {
                throw new ArgumentNullException("serviceController");
            }

            this.Container         = container ?? new Container();
            this.Metadata          = serviceController.Metadata; //always share the same metadata
            this.ServiceController = serviceController;
        }
コード例 #6
0
        /// <summary>Renders the operations.</summary>
        ///
        /// <param name="writer">  The writer.</param>
        /// <param name="httpReq"> The HTTP request.</param>
        /// <param name="metadata">The metadata.</param>
    	protected override void RenderOperations(HtmlTextWriter writer, IHttpRequest httpReq, ServiceMetadata metadata)
    	{
			var defaultPage = new IndexOperationsControl {
				HttpRequest = httpReq,
                MetadataConfig = EndpointHost.Config.MetadataPagesConfig,                
				Title = EndpointHost.Config.ServiceName,
				Xsds = XsdTypes.Xsds,
				XsdServiceTypesIndex = 1,
                OperationNames = metadata.GetOperationNamesForMetadata(httpReq),
				MetadataPageBodyHtml = EndpointHost.Config.MetadataPageBodyHtml,
			};

			defaultPage.RenderControl(writer);
		}
コード例 #7
0
        //public ServiceOperations ServiceOperations { get; set; }
        //public ServiceOperations AllServiceOperations { get; set; }

        /// <summary>Inject alternative container and strategy for resolving Service Types.</summary>
        ///
        /// <exception cref="ArgumentException">Thrown when one or more arguments have unsupported or illegal values.</exception>
        ///
        /// <param name="assembliesWithServices">A variable-length parameters list containing assemblies with services.</param>
        public ServiceManager(params Assembly[] assembliesWithServices)
        {
            if (assembliesWithServices == null || assembliesWithServices.Length == 0)
            {
                throw new ArgumentException(
                          "No Assemblies provided in your AppHost's base constructor.\n"
                          + "To register your services, please provide the assemblies where your web services are defined.");
            }

            this.Container = new Container {
                DefaultOwner = Owner.External
            };
            this.Metadata          = new ServiceMetadata();
            this.ServiceController = new ServiceController(() => GetAssemblyTypes(assembliesWithServices), this.Metadata);
        }
コード例 #8
0
        /// <summary>Initializes a new instance of the NServiceKit.ServiceHost.MetadataPagesConfig class.</summary>
        ///
        /// <param name="metadata">          The metadata.</param>
        /// <param name="metadataConfig">    The metadata configuration.</param>
        /// <param name="ignoredFormats">    The ignored formats.</param>
        /// <param name="contentTypeFormats">The content type formats.</param>
        public MetadataPagesConfig(
            ServiceMetadata metadata,
            ServiceEndpointsMetadataConfig metadataConfig,
            HashSet<string> ignoredFormats,
            List<string> contentTypeFormats)
        {
            this.ignoredFormats = ignoredFormats;
            this.metadata = metadata;

            metadataConfigMap = new Dictionary<string, MetadataConfig> {
                {"xml", metadataConfig.Xml},
                {"json", metadataConfig.Json},
                {"jsv", metadataConfig.Jsv},
                {"soap11", metadataConfig.Soap11},
                {"soap12", metadataConfig.Soap12},
            };

            AvailableFormatConfigs = new List<MetadataConfig>();

            var config = GetMetadataConfig("xml");
            if (config != null) AvailableFormatConfigs.Add(config);
            config = GetMetadataConfig("json");
            if (config != null) AvailableFormatConfigs.Add(config);
            config = GetMetadataConfig("jsv");
            if (config != null) AvailableFormatConfigs.Add(config);

            foreach (var format in contentTypeFormats)
            {
                metadataConfigMap[format] = metadataConfig.Custom.Create(format);

                config = GetMetadataConfig(format);
                if (config != null) AvailableFormatConfigs.Add(config);
            }

            config = GetMetadataConfig("soap11");
            if (config != null) AvailableFormatConfigs.Add(config);
            config = GetMetadataConfig("soap12");
            if (config != null) AvailableFormatConfigs.Add(config);
        }
コード例 #9
0
 /// <summary>Initializes a new instance of the NServiceKit.ServiceHost.XsdMetadata class.</summary>
 ///
 /// <param name="metadata">The metadata.</param>
 /// <param name="flash">   true to flash.</param>
 public XsdMetadata(ServiceMetadata metadata, bool flash = false)
 {
     Metadata = metadata;
     Flash    = flash;
 }
コード例 #10
0
ファイル: ServiceMetadata.cs プロジェクト: Qasemt/NServiceKit
 /// <summary>Initializes a new instance of the NServiceKit.ServiceHost.XsdMetadata class.</summary>
 ///
 /// <param name="metadata">The metadata.</param>
 /// <param name="flash">   true to flash.</param>
 public XsdMetadata(ServiceMetadata metadata, bool flash = false)
 {
     Metadata = metadata;
     Flash = flash;
 }