本文整理汇总了C#中Service.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Service.GetType方法的具体用法?C# Service.GetType怎么用?C# Service.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
IService service = new Service();
ISerializer serializer = new Serializer();
var signatures = SignatureGenerator.GetSignatureList(service.GetType());
using (var context = NetMQContext.Create())
using (var server = context.CreateResponseSocket())
{
server.Bind("tcp://*:5555");
while (true)
{
var msg = server.ReceiveMultipartMessage();
var methodName = msg.Pop().ConvertToString(); //Method signature
var method = signatures[methodName]; //Get method from list
var paramList = new List<object>();
var parameters = method.GetParameters();
if (parameters.Count() != msg.FrameCount) throw new Exception("Invalid parameters");
for (var i = 0; i < parameters.Count(); i++)
{
var obj = serializer.Deserialize(parameters[i].ParameterType, msg.Pop().ToByteArray());
paramList.Add(obj);
}
var response = method.Invoke(service, paramList.ToArray());
var respMessage = serializer.Serialize(response);
server.SendFrame(respMessage);
}
}
}
示例2: BeforeInvoke
public override void BeforeInvoke(Service.ServiceBase svObj)
{
StringBuilder result = new StringBuilder(1024);
result.Append(string.Format("服务开始执行,服务类型:{0},参数信息:{1}", svObj.GetType().FullName, GetParamInfo(svObj)));
logger.Debug(result.ToString());
}
示例3: grantServiceTicket
/**
* @throws IllegalArgumentException if TicketGrantingTicket ID, Credentials
* or Service are null.
*/
//@Audit(
// action="SERVICE_TICKET",
// actionResolverName="GRANT_SERVICE_TICKET_RESOLVER",
// resourceResolverName="GRANT_SERVICE_TICKET_RESOURCE_RESOLVER")
//@Profiled(tag="GRANT_SERVICE_TICKET", logFailuresSeparately = false)
//@Transactional(readOnly = false)
public string grantServiceTicket(string ticketGrantingTicketId, Service service, Credentials credentials)
{
//Assert.notNull(ticketGrantingTicketId, "ticketGrantingticketId cannot be null");
//Assert.notNull(service, "service cannot be null");
TicketGrantingTicket ticketGrantingTicket;
ticketGrantingTicket = (TicketGrantingTicket)this.ticketRegistry.getTicket(ticketGrantingTicketId, typeof(TicketGrantingTicket));
if (ticketGrantingTicket == null)
{
throw new InvalidTicketException();
}
lock (ticketGrantingTicket)
{
if (ticketGrantingTicket.isExpired())
{
this.ticketRegistry.deleteTicket(ticketGrantingTicketId);
throw new InvalidTicketException();
}
}
RegisteredService registeredService = this.servicesManager
.findServiceBy(service);
if (registeredService == null || !registeredService.isEnabled())
{
//log.warn("ServiceManagement: Unauthorized Service Access. Service [" + service.getId() + "] not found in Service Registry.");
throw new UnauthorizedServiceException();
}
if (!registeredService.isSsoEnabled() && credentials == null
&& ticketGrantingTicket.getCountOfUses() > 0)
{
//log.warn("ServiceManagement: Service Not Allowed to use SSO. Service [" + service.getId() + "]");
throw new UnauthorizedSsoServiceException();
}
//CAS-1019
List<Authentication> authns = ticketGrantingTicket.getChainedAuthentications();
if (authns.Count > 1)
{
if (!registeredService.isAllowedToProxy())
{
string message = string.Format("ServiceManagement: Service Attempted to Proxy, but is not allowed. Service: [%s] | Registered Service: [%s]", service.getId(), registeredService.ToString());
//log.warn(message);
throw new UnauthorizedProxyingException(message);
}
}
if (credentials != null)
{
try
{
Authentication authentication = this.authenticationManager
.authenticate(credentials);
Authentication originalAuthentication = ticketGrantingTicket.getAuthentication();
if (!(authentication.getPrincipal().Equals(originalAuthentication.getPrincipal()) && authentication.getAttributes().Equals(originalAuthentication.getAttributes())))
{
throw new TicketCreationException();
}
}
catch (AuthenticationException e)
{
throw new TicketCreationException(e);
}
}
// this code is a bit brittle by depending on the class name. Future versions (i.e. CAS4 will know inherently how to identify themselves)
UniqueTicketIdGenerator serviceTicketUniqueTicketIdGenerator = this.uniqueTicketIdGeneratorsForService
.FirstOrDefault(x => x.Key == service.GetType().FullName).Value;
ServiceTicket serviceTicket = ticketGrantingTicket
.grantServiceTicket(serviceTicketUniqueTicketIdGenerator
.getNewTicketId(TicketPrefix.ServiceTicket_PREFIX), service,
this.serviceTicketExpirationPolicy, credentials != null);
this.serviceTicketRegistry.addTicket(serviceTicket);
//if (log.isInfoEnabled()) {
// List<Authentication> authentications = serviceTicket.getGrantingTicket().getChainedAuthentications();
// string formatString = "Granted %s ticket [%s] for service [%s] for user [%s]";
// string type;
// string principalId = authentications.get(authentications.size()-1).getPrincipal().getId();
// if (authentications.size() == 1) {
// type = "service";
//.........这里部分代码省略.........