/// <summary> /// Initializes a new instance of the <see cref="ServerConfiguration" /> class. /// </summary> /// <param name="host"> /// The IP address. /// </param> /// <param name="port"> /// The port. /// </param> private ServerConfiguration(string host, int port) { Should.NotBeNull(host, nameof(host)); Should.BeTrue(IPAddress.TryParse(host, out _), nameof(host)); Should.BePositive(port, nameof(port)); this.Logger = new ConsoleLogger(); this.Host = host; this.Port = port; }
public static ObjectMapper CreateBasic(Type fromType, Type toType) { Should.BeTrue(Type.GetTypeCode(fromType) == TypeCode.Object, () => new ArgumentException("From type should be an object type.")); Should.BeTrue(Type.GetTypeCode(toType) == TypeCode.Object, () => new ArgumentException("To type should be an object type.")); string key = $"{fromType.AssemblyQualifiedName}_{toType.AssemblyQualifiedName}"; ObjectMapper objectMapper = new ObjectMapper(fromType, toType); var fromTypeMaps = fromType.GetProperties().Where(p => p.CanRead).ToDictionary(p => p.Name, p => p); var toTypeMaps = toType.GetProperties().Where(p => p.CanWrite).ToDictionary(p => p.Name, p => p); foreach (var fromProp in fromType.GetProperties()) { if (toTypeMaps.TryGetValue(fromProp.Name, out var toProp)) { if (toProp.PropertyType != fromProp.PropertyType) { continue; } // add basicPropertyMapper } } return(objectMapper); }
/// <summary> /// Validates an IP address and its port. /// </summary> /// <param name="host"> /// The IP address to validate. /// </param> /// <param name="port"> /// The port to validate. /// </param> internal static void Validate(string host, int port) { Should.NotBeNull(host, nameof(host)); Should.BeTrue(IPAddress.TryParse(host, out _), nameof(host)); Should.BePositive(port, nameof(port)); }
/// <summary> /// Validates <see cref="GridionServerConfiguration" /> instance. /// </summary> /// <param name="configuration"> /// The configuration to validate. /// </param> internal static void Validate(GridionServerConfiguration configuration) { Should.NotBeNull(configuration, nameof(configuration)); Should.BeTrue(IPAddress.TryParse(configuration.Host, out _), nameof(configuration.Host)); Should.BePositive(configuration.Port, nameof(configuration.Port)); }
/// <summary> /// Validates the server configuration. /// </summary> internal void Validate() { Should.BeTrue(IPAddress.TryParse(this.Host, out _), nameof(this.Host)); Should.BePositive(this.Port, nameof(this.Port)); }