/// <summary> /// Constructor for <see cref="ApiInterfaceAttribute"/>. /// </summary> /// <param name="assembly">Assembly where to find Api Interfaces.</param> public ApiInterfaceAttributeSource(Assembly assembly) { ArgumentsHelpers.ThrowIfNull(assembly, nameof(assembly)); ApiInterfaces = assembly.DefinedTypes .Where(t => t.GetCustomAttribute <ApiInterfaceAttribute>() != null) .ToList(); }
static void Main(string[] args) { if (!ArgumentsHelpers.TryGetArgument(args, IP_ARG_NAME, out string ipAddress)) { ipAddress = "127.0.0.1"; } if (!ArgumentsHelpers.TryGetArgument(args, PORT_ARG_NAME, out string port)) { port = "8000"; } SockertServer client = new SockertServer(IPAddress.Parse(ipAddress), int.Parse(port)); client.Initialize(); client.OnMessageReceived += Client_OnMessageReceived; client.Listen(); Console.WriteLine("Write an message"); string message = Console.ReadLine(); client.Send(message); Console.WriteLine("Press any key to exit"); Console.ReadKey(); Console.ReadLine(); }
/// <summary> /// Call the Api Interface method. /// </summary> public Task <TOut> Call <TOut>(Expression <Func <TInterface, TOut> > methodCall) { ArgumentsHelpers.ThrowIfNull(methodCall, nameof(methodCall)); return(Call <TOut>(methodCall.Body)); }
/// <summary> /// Call the Api Interface method. /// </summary> public Task Call(Expression <Action <TInterface> > methodCall) { ArgumentsHelpers.ThrowIfNull(methodCall, nameof(methodCall)); return(Call((MethodCallExpression)methodCall.Body)); }
public ApiInterfacesTypesSource(IEnumerable <Type> apiInterfaces) { ArgumentsHelpers.ThrowIfNull(apiInterfaces, nameof(apiInterfaces)); ApiInterfaces = apiInterfaces.ToList(); }
public ApiConventionException(Type issuedApiInterfaceType) { ArgumentsHelpers.ThrowIfNull(issuedApiInterfaceType, nameof(issuedApiInterfaceType)); IssuedApiInterfaceType = issuedApiInterfaceType; }