public void RegisterServiceContract <T>() where T : class { var type = typeof(T); foreach (var method in type.GetMethods()) { if (_factory.TryCreateOperationContract(method, out OperationContract operation)) { if (!OperationContracts.TryAdd(method.Name, operation)) { if (Log.IsEnabled(Serilog.Events.LogEventLevel.Warning)) { Log.Warning("The operation {0} occurs multiple times.", method.Name); } } RegisterDataContract(operation.ParameterType); RegisterDataContract(operation.ReturnType); } } foreach (var evnt in type.GetEvents()) { if (_factory.TryCreateEventContract(evnt, out EventContract contract)) { if (!EventContracts.TryAdd(evnt.Name, contract)) { if (Log.IsEnabled(Serilog.Events.LogEventLevel.Warning)) { Log.Warning("The event {0} occurs multiple times.", evnt.Name); } } RegisterDataContract(contract.ParameterType); } } }
public bool TryGetOperationContract(string title, out OperationContract contract) { return(OperationContracts.TryGetValue(title, out contract)); }