private void ValidateHost(RethinkDbAttribute attribute, Type paramType)
 {
     if (String.IsNullOrEmpty(_options.Hostname) && String.IsNullOrEmpty(attribute.HostnameSetting))
     {
         string attributeProperty = $"{nameof(RethinkDbAttribute)}.{nameof(RethinkDbAttribute.HostnameSetting)}";
         string optionsProperty   = $"{nameof(RethinkDbOptions)}.{nameof(RethinkDbOptions.Hostname)}";
         throw new InvalidOperationException($"The RethinkDB hostname must be set either via the {attributeProperty} property or via {optionsProperty}.");
     }
 }
Beispiel #2
0
 public static ConnectionOptions Build(RethinkDbAttribute attribute, RethinkDbOptions options)
 {
     return(new ConnectionOptions(
                attribute.HostnameSetting ?? options.Hostname,
                (String.IsNullOrEmpty(attribute.PortSetting) || !Int32.TryParse(attribute.PortSetting, out int port)) ? options.Port : port,
                attribute.AuthorizationKeySetting ?? options.AuthorizationKey,
                attribute.UserSetting ?? options.User,
                attribute.PasswordSetting ?? options.Password,
                (String.IsNullOrEmpty(attribute.EnableSslSetting) || !Boolean.TryParse(attribute.EnableSslSetting, out bool enableSsl)) ? options.EnableSsl : enableSsl,
                attribute.LicenseToSetting ?? options.LicenseTo,
                attribute.LicenseKeySetting ?? options.LicenseKey
                ));
 }
        private Task <IValueBinder> CreateValueBinderAsync(RethinkDbAttribute attribute, Type type)
        {
            if (String.IsNullOrEmpty(attribute.Id))
            {
                throw new InvalidOperationException($"The '{nameof(RethinkDbAttribute.Id)}' property of a RethinkDB single-item input binding cannot be null or empty.");
            }

            ConnectionOptions connectionOptions = ConnectionOptionsBuilder.Build(attribute, _options);
            Type         valyeBinderType        = typeof(RethinkDbValueBinder <>).MakeGenericType(type);
            IValueBinder valueBinder            = (IValueBinder)Activator.CreateInstance(valyeBinderType, attribute, _rethinkDBConnectionFactory.GetConnectionAsync(connectionOptions));

            return(Task.FromResult(valueBinder));
        }
        public IAsyncCollector <T> Convert(RethinkDbAttribute attribute)
        {
            ConnectionOptions connectionOptions = ConnectionOptionsBuilder.Build(attribute, _options);

            return(new RethinkDbAsyncCollector <T>(attribute, _rethinkDBConnectionFactory.GetConnectionAsync(connectionOptions)));
        }
 public RethinkDbValueBinder(RethinkDbAttribute attribute, Task <IConnection> rethinkDbConnectionTask)
 {
     _attribute = attribute;
     _rethinkDbConnectionTask = rethinkDbConnectionTask;
     _rethinkDbTable          = Driver.RethinkDB.R.Db(attribute.DatabaseName).Table(attribute.TableName);
 }