本文整理汇总了C#中Connect.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# Connect.GetService方法的具体用法?C# Connect.GetService怎么用?C# Connect.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connect
的用法示例。
在下文中一共展示了Connect.GetService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
/// <summary>
/// Converts the service request database instance to IService instance
/// </summary>
/// <param name="service">ServiceRequest instance</param>
/// <returns>IService instance</returns>
/// <exception cref="Siminov.Connect.Exception.ServiceException">ServiceException If any exception occur while converting the instance</exception>
public IService Convert(Connect.Model.ServiceRequest service)
{
IService iService = (IService) ClassUtils.CreateClassInstance(service.GetInstanceOf());
iService.SetRequestId(service.GetRequestId());
iService.SetService(service.GetService());
iService.SetRequest(service.GetRequest());
IEnumerator<ServiceRequestResource> serviceRequestResources = service.GetServiceRequestResources();
while(serviceRequestResources.MoveNext())
{
ServiceRequestResource serviceResource = serviceRequestResources.Current;
iService.AddResource(serviceResource.GetName(), serviceResource.GetValue());
}
ServiceDescriptor serviceDescriptor = resourceManager.RequiredServiceDescriptorBasedOnName(service.GetService());
iService.SetServiceDescriptor(serviceDescriptor);
ResourceUtils.Resolve(iService);
return iService;
}
示例2: ContainService
/**
* Check whether it contains the requested service or not
* @param service Service
* @return (true/false) TRUE: If service request already exists | FALSE: If service does not exists
* @throws ServiceException If there is any exception while checking for request
*/
public bool ContainService(Connect.Model.ServiceRequest service)
{
Connect.Model.ServiceRequest[] services = null;
try
{
services = (Connect.Model.ServiceRequest[]) new Connect.Model.ServiceRequest().Select().Execute();
}
catch(DatabaseException de)
{
Log.Error(typeof(AsyncServiceWorker).Name, "ContainService", "DatabaseException caught while getting services from database, " + de.GetMessage());
throw new ServiceException(typeof(AsyncServiceWorker).Name, "ContainService", de.GetMessage());
}
if(services == null || services.Length <= 0)
{
return false;
}
for(int i = 0;i < services.Length;i++)
{
Connect.Model.ServiceRequest savedService = services[i];
if(service.GetService().Equals(savedService.GetService(), StringComparison.OrdinalIgnoreCase))
{
if(service.GetRequest().Equals(savedService.GetRequest(), StringComparison.OrdinalIgnoreCase))
{
bool contain = true;
IEnumerator<ServiceRequestResource> serviceRequestResources = service.GetServiceRequestResources();
while(serviceRequestResources.MoveNext())
{
ServiceRequestResource serviceResource = serviceRequestResources.Current;
ServiceRequestResource savedRequestResource = savedService.GetServiceRequestResource(serviceResource.GetName());
if(savedRequestResource == null)
{
contain = false;
break;
}
if(!serviceResource.GetName().Equals(savedRequestResource.GetName(), StringComparison.OrdinalIgnoreCase))
{
contain = false;
break;
}
else if(!serviceResource.GetValue().Equals(savedRequestResource.GetValue(), StringComparison.OrdinalIgnoreCase))
{
contain = false;
break;
}
}
if(contain)
{
return true;
}
}
}
}
return false;
}