public void InheritMultipleDerivedInterfaces() { Assert.Throws <ThriftyException>(() => { ThriftServiceMetadata.GetThriftServiceAttribute(typeof(MultipleDerivedServiceImplementation)); }); }
public void GetProperties_Success() { var swiftMetadata = new ThriftyServiceMetadata(typeof(IServiceStup), "1.1"); //这个测试有点.... Assert.Equal(swiftMetadata.ServiceName, ThriftServiceMetadata.ParseServiceName(typeof(IServiceStup))); Assert.Equal(swiftMetadata.Version, "1.1"); }
/// <summary> /// 构造函数 /// </summary> /// <param name="serviceType">服务源类型</param> /// <param name="version">服务版本。</param> public ThriftyServiceMetadata(Type serviceType, string version = "1.0.0") { Guard.ArgumentNotNull(serviceType, nameof(serviceType)); if (!serviceType.GetTypeInfo().IsInterface) { throw new ThriftyException($"{serviceType.FullName} as a swifty service type must be a interface type."); } ThriftServiceAttribute thriftServiceAttr = serviceType.GetTypeInfo().GetCustomAttribute <ThriftServiceAttribute>(false); if (thriftServiceAttr == null) { throw new ThriftyException($"{serviceType.FullName} as a swifty service type must attrited by {nameof(ThriftServiceAttribute)}."); } this.Version = String.IsNullOrWhiteSpace(version) ? "1.0.0" : version; this.ServiceName = ThriftServiceMetadata.ParseServiceName(serviceType); }
internal ThriftClientMetadata( Type clientType, String clientName, ThriftCodecManager codecManager) { Guard.ArgumentNotNull(clientType, nameof(clientType)); Guard.ArgumentNotNull(codecManager, nameof(codecManager)); Guard.ArgumentNullOrWhiteSpaceString(clientName, nameof(clientName)); this.ClientName = clientName; thriftServiceMetadata = new ThriftServiceMetadata(clientType, codecManager.Catalog); this.ClientType = thriftServiceMetadata.Name; this.MethodHandlers = new Dictionary <MethodInfo, ThriftMethodHandler>(); foreach (ThriftMethodMetadata methodMetadata in thriftServiceMetadata.Methods.Values) { ThriftMethodHandler methodHandler = new ThriftMethodHandler(methodMetadata, codecManager); MethodHandlers.Add(methodMetadata.Method, methodHandler); } }
private void BuildMethods(IDictionary <Type, Func <IRequestContext, Object> > services, ThriftCodecManager codecManager, ILoggerFactory loggerFactory) { var processorMap = ImmutableDictionary.CreateBuilder <String, ThriftMethodProcessor>(); foreach (Type serviceType in services.Keys) { ThriftServiceMetadata serviceMetadata = new ThriftServiceMetadata(serviceType, codecManager.Catalog); foreach (ThriftMethodMetadata methodMetadata in serviceMetadata.Methods.Values) { String methodName = methodMetadata.QualifiedName; ThriftMethodProcessor methodProcessor = new ThriftMethodProcessor(services[serviceType], serviceMetadata.Name, methodMetadata, codecManager, loggerFactory); if (processorMap.ContainsKey(methodName)) { throw new ThriftyException($"Multiple ThriftMethod-attributed methods named '{methodMetadata.Name}' found in the given service type '{serviceType.Name}'"); } processorMap.Add(methodName, methodProcessor); } } this.Methods = processorMap.ToImmutableDictionary(); }
public void InheritCombinedInterface() { ThriftServiceMetadata.GetThriftServiceAttribute(typeof(CombinedServiceImplementation)); }
public void InheritMultipleDerviedInterfacesWithExplicitAttribute() { ThriftServiceMetadata.GetThriftServiceAttribute(typeof(MultipleDerivedServiceImplementationWithExplicitAttribute)); }
public void InheritSingleDerivedInterface() { ThriftServiceMetadata.GetThriftServiceAttribute(typeof(SingleDerivedServiceImplementation)); }
public void InheritBaseInterface() { ThriftServiceMetadata.GetThriftServiceAttribute(typeof(BaseServiceImplementation)); }