当前位置: 首页>>代码示例>>C#>>正文


C# IService.GetResource方法代码示例

本文整理汇总了C#中IService.GetResource方法的典型用法代码示例。如果您正苦于以下问题:C# IService.GetResource方法的具体用法?C# IService.GetResource怎么用?C# IService.GetResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IService的用法示例。


在下文中一共展示了IService.GetResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

            /// <summary>
            /// It converts IService instance to database service request instance
            /// </summary>
            /// <param name="iService">IService instance</param>
            /// <returns>ServiceRequest Instance</returns>
		    public Connect.Model.ServiceRequest Convert(IService iService) 
            {
			
			    Connect.Model.ServiceRequest serviceRequest = new Connect.Model.ServiceRequest();
			    serviceRequest.SetRequestId(iService.GetRequestId());
			    serviceRequest.SetService(iService.GetService());
			    serviceRequest.SetRequest(iService.GetRequest());
			    serviceRequest.SetInstanceOf(iService.GetType().Name);
			
			    IEnumerator<String> resources = iService.GetResources();
			    while(resources.MoveNext()) 
                {
				    String resourceName = resources.Current;
				    Object resourceValue = iService.GetResource(resourceName);
				
				    if(!(resourceValue is String)) 
                    {
					    continue;
				    }
				
				    ServiceRequestResource serviceRequestResource = new ServiceRequestResource();
				    serviceRequestResource.SetServiceRequest(serviceRequest);
				    serviceRequestResource.SetName(resourceName);
				    serviceRequestResource.SetValue((String) resourceValue);
				
				    serviceRequest.AddServiceRequestResource(serviceRequestResource);
			    }
			
			    return serviceRequest;
		    }
开发者ID:gitter-badger,项目名称:connect-1,代码行数:35,代码来源:AsyncServiceWorker.cs

示例2: Resolve

        /// <summary>
        /// It resolve service descriptor instance 
        /// </summary>
        /// <param name="service">Service instance</param>
        /// <exception cref="Siminov.Connect.Exception.ServiceException">If any exception occur while resolving dynamic resources</exception>
	    public static void Resolve(IService service) 
        {

		    /*
		     * Resolve Service Descriptor Properties
		     */
		    ServiceDescriptor serviceDescriptor = service.GetServiceDescriptor();
		
		    IEnumerator<String> resources = service.GetResources();
		    while(resources.MoveNext()) 
            {
			    String resourceName = resources.Current;
			    Object resourceValue = service.GetResource(resourceName);
			
			    if(resourceValue is String) 
                {
				    serviceDescriptor.AddProperty(resourceName, (String) resourceValue);
			    }
		    }
		
		
		    IEnumerator<String> serviceDescriptorProperties = serviceDescriptor.GetProperties();
            IDictionary<String, String> changedServiceDescriptorProperties = new Dictionary<String, String>();

		    while(serviceDescriptorProperties.MoveNext()) 
            {
			
			    String serviceDescriptorProperty = serviceDescriptorProperties.Current;
			    String serviceDescriptorValue = serviceDescriptor.GetProperty(serviceDescriptorProperty);

                var serviceDescriptors = new List<IDescriptor>();
                serviceDescriptors.Add(serviceDescriptor);
                
                serviceDescriptorValue = ResourceUtils.Resolve(serviceDescriptorValue, serviceDescriptors.ToArray());

                changedServiceDescriptorProperties.Add(serviceDescriptorProperty, serviceDescriptorValue);
		    }

            foreach (String changedServiceDescriptorProperty in changedServiceDescriptorProperties.Keys) 
            {
                serviceDescriptor.AddProperty(changedServiceDescriptorProperty, changedServiceDescriptorProperties[changedServiceDescriptorProperty]);
            }
		
		
		    /*
		     * Resolve API Properties
		     */
		    Connect.Model.ServiceDescriptor.Request request = serviceDescriptor.GetRequest(service.GetRequest());
		    IEnumerator<String> apiProperties = request.GetProperties();
            IDictionary<String, String> changedApiProperties = new Dictionary<String, String>();

            while(apiProperties.MoveNext()) 
            {
			
			    String apiProperty = apiProperties.Current;
			    String apiValue = request.GetProperty(apiProperty);

                var serviceDescriptors = new List<IDescriptor>();
                serviceDescriptors.Add(serviceDescriptor);

			    apiValue = ResourceUtils.Resolve(apiValue, serviceDescriptors.ToArray());

                changedApiProperties.Add(apiProperty, apiValue);
		    }

            foreach (String changedApiProperty in changedApiProperties.Keys)
            {
                request.AddProperty(changedApiProperty, changedApiProperties[changedApiProperty]);
            }
		
		    /*
		     * Resolve API Query Parameters
		     */
		    IEnumerator<Connect.Model.ServiceDescriptor.Request.QueryParameter> queryParameters = request.GetQueryParameters();
            while(queryParameters.MoveNext()) 
            {
			
			    Connect.Model.ServiceDescriptor.Request.QueryParameter queryParameter = queryParameters.Current;
			
			    String queryValue = queryParameter.GetValue();

                var serviceDescriptors = new List<IDescriptor>();
                serviceDescriptors.Add(serviceDescriptor);

			    queryValue = ResourceUtils.Resolve(queryValue, serviceDescriptors.ToArray());
			
			    queryParameter.SetValue(queryValue);
		    }

		
		    /*
		     * Resolve API Query Parameters
		     */
		    IEnumerator<Connect.Model.ServiceDescriptor.Request.HeaderParameter> headerParameters = request.GetHeaderParameters();
            while(headerParameters.MoveNext()) 
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:connect-1,代码行数:101,代码来源:ResourceUtils.cs

示例3: Handle

        /// <summary>
        /// It handles the service request
        /// </summary>
        /// <param name="service">Service instance</param>
        /// <exception cref="Siminov.Connect.Exception.ServiceException">If any exception occur while handling the service request</exception>
	    public void Handle(IService service) 
        {

		    ServiceDescriptor serviceDescriptor = service.GetServiceDescriptor();
		    if(serviceDescriptor == null) 
            {
			    serviceDescriptor = resourceManager.RequiredServiceDescriptorBasedOnName(service.GetService());
			    service.SetServiceDescriptor(serviceDescriptor);
		    }


		    IEnumerator<String> resources = service.GetResources();
		    while(resources.MoveNext()) 
            {
			    String resourceName = resources.Current;
			    Object resourceValue = service.GetResource(resourceName);
			
			    if(resourceValue is String) 
                {
				    serviceDescriptor.AddProperty(resourceName, (String) resourceValue);
			    }
		    }

		
		    Connect.Model.ServiceDescriptor.Request request = serviceDescriptor.GetRequest(service.GetRequest());
            var serviceDescriptors = new List<Core.Model.IDescriptor>();
            serviceDescriptors.Add(serviceDescriptor);

		    String mode = ResourceUtils.Resolve(request.GetMode(), serviceDescriptors.ToArray());
		
		    if(mode.Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_SYNC_REQUEST_MODE, StringComparison.OrdinalIgnoreCase)) 
            {

			    ResourceUtils.Resolve(service);
			    syncServiceWorker.Process(service);
		    } 
            else if(mode.Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_ASYNC_REQUEST_MODE, StringComparison.OrdinalIgnoreCase)) 
            {
			    asyncServiceWorker.AddRequest(service);
		    }
	    }
开发者ID:gitter-badger,项目名称:connect-1,代码行数:46,代码来源:ServiceHandler.cs


注:本文中的IService.GetResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。