/// <summary> /// Initialises a new service endpoint for the given service type. /// </summary> protected ServiceBase(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } if (!serviceType.IsInterface) { throw new ArgumentException(serviceType.FullName + " is not an interface", "serviceType"); } this.serviceType = serviceType; foreach (MethodInfo method in serviceType.GetMethods(BindingFlags.Instance | BindingFlags.Public)) { if (method.IsGenericMethod || method.IsGenericMethodDefinition || method.DeclaringType != serviceType) { continue; } string key = RpcUtils.GetActionName(method); if (actions.ContainsKey(key)) { throw new ArgumentException("Duplicate action \"" + key + "\" found on service-contract " + serviceType.FullName, "serviceContractType"); } actions.Add(key, method); } }
/// <summary> /// Identify the action to use for a given method. /// </summary> /// <param name="method">The method requested.</param> /// <returns>The action to use.</returns> protected virtual string ResolveAction(MethodInfo method) { return(RpcUtils.GetActionName(method)); }