本文整理汇总了C#中ServiceType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceType.ToString方法的具体用法?C# ServiceType.ToString怎么用?C# ServiceType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceType
的用法示例。
在下文中一共展示了ServiceType.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateName
private string GenerateName(ServiceType type)
{
var counter = 0;
string proposedName;
do
{
counter++;
proposedName = type.ToString().Substring(0, 1).ToLower() + counter;
} while (_services.ContainsKey(proposedName));
return proposedName;
}
示例2: StopService
public void StopService(IServiceAddress machine, ServiceType serviceType)
{
if (serviceType == ServiceType.Admin)
throw new ArgumentException("Invalid service type.", "serviceType");
InspectNetwork();
// Check machine is in the schema,
MachineProfile machine_p = CheckMachineInNetwork(machine);
if ((machine_p.ServiceType & serviceType) == 0)
throw new NetworkAdminException("Manager not assigned to machine " + machine);
ChangeRole(machine_p, "dispose", serviceType.ToString().ToLower());
}
示例3: StartService
public void StartService(IServiceAddress machine, ServiceType serviceType)
{
if (serviceType == ServiceType.Admin)
throw new ArgumentException("Invalid service type.", "serviceType");
InspectNetwork();
// Check machine is in the schema,
MachineProfile machine_p = CheckMachineInNetwork(machine);
if (serviceType == ServiceType.Manager) {
MachineProfile current_manager = ManagerServer;
if (current_manager != null)
throw new NetworkAdminException("Manager already assigned on machine " + current_manager);
}
if ((machine_p.ServiceType & serviceType) != 0)
throw new NetworkAdminException("Role '" + serviceType + "' already assigned on machine " + machine);
ChangeRole(machine_p, "init", serviceType.ToString().ToLower());
}
示例4: RegisterService
private void RegisterService(IServiceAddress address, ServiceType serviceType)
{
InspectNetwork();
// Check machine is in the schema,
MachineProfile machine_p = CheckMachineInNetwork(address);
MachineProfile currentManager = ManagerServer;
if (currentManager == null)
throw new NetworkAdminException("No manager server found");
if ((machine_p.ServiceType & serviceType) == 0)
throw new NetworkAdminException("Machine '" + address + "' is not assigned as a " + serviceType.ToString().ToLower() +
" role");
string messageName = serviceType == ServiceType.Block ? "registerBlockServer" : "registerRootServer";
RequestMessage request = new RequestMessage(messageName);
request.Arguments.Add(address);
Message m = Command(currentManager.Address, ServiceType.Manager, request);
if (m.HasError)
throw new NetworkAdminException(m.ErrorMessage, m.ErrorStackTrace);
}
示例5: GetPrice
public decimal GetPrice(Delivery delivery, string currencyCode)
{
decimal decRate = 0;
try
{
ServiceType stType = new ServiceType();
switch (delivery.ShippingOption.ShippingOptionName)
{
case "FedExPriorityOvernight":
stType = ServiceType.PRIORITY_OVERNIGHT;
break;
case "FedExStandardOvernight":
stType = ServiceType.STANDARD_OVERNIGHT;
break;
}
CurrentUserInfo uinfo = MembershipContext.AuthenticatedUser;
RateReply reply = new RateReply();
// Cache the data for 10 minutes with a key
using (CachedSection<RateReply> cs = new CachedSection<RateReply>(ref reply, 60, true, null, "FexExRatesAPI-" + stType.ToString().Replace(" ", "-") + uinfo.UserID + "-" + delivery.DeliveryAddress.AddressZip + "-" + ValidationHelper.GetString(delivery.Weight, "")))
{
if (cs.LoadData)
{
//Create the request
RateRequest request = CreateRateRequest(delivery, stType);
//Create the service
RateService service = new RateService();
// Call the web service passing in a RateRequest and returning a RateReply
reply = service.getRates(request);
cs.Data = reply;
}
reply = cs.Data;
}
if (reply.HighestSeverity == NotificationSeverityType.SUCCESS)
{
foreach (RateReplyDetail repDetail in reply.RateReplyDetails)
{
foreach (RatedShipmentDetail rsd in repDetail.RatedShipmentDetails)
{
//Add an offset to handle the differencse in the testing envinronment
decRate = ValidationHelper.GetDecimal(rsd.ShipmentRateDetail.TotalNetFedExCharge.Amount * 1.08m, 0);
}
}
}
else
{
//Clean up the cached value so the next time the value is pulled again
CacheHelper.ClearCache("FexExRatesAPI-" + stType.ToString().Replace(" ", "-") + uinfo.UserID + "-" + delivery.DeliveryAddress.AddressZip + "-" + ValidationHelper.GetString(delivery.Weight, ""));
}
}
catch (Exception ex)
{
//Log the error
EventLogProvider.LogException("FedExCarrier - GetPrice", "EXCEPTION", ex);
//Set some base rate for the shipping
decRate = 10;
}
return decRate;
}
示例6: GetServiceTypeName
protected string GetServiceTypeName(ServiceType type)
{
string serviceType = "";
if ((type & ServiceType.InteractiveProcess) != 0)
{
serviceType = "Interactive ";
type -= ServiceType.InteractiveProcess;
}
switch (type)
{
case ServiceType.Adapter:
serviceType += "Adapter";
break;
case ServiceType.FileSystemDriver:
case ServiceType.KernelDriver:
case ServiceType.RecognizerDriver:
serviceType += "Driver";
break;
case ServiceType.Win32OwnProcess:
serviceType += "Win32 Service Process";
break;
case ServiceType.Win32ShareProcess:
serviceType += "Win32 Shared Process";
break;
default:
serviceType += "unknown type " + type.ToString();
break;
}
return serviceType;
}