Example #1
0
 public BaseJsonTests()
 {
     this._settings = new ConnectionSettings(Test.Default.Uri)
         .SetDefaultIndex(Test.Default.DefaultIndex);
     this._connection = new InMemoryConnection(this._settings);
     this._client = new ElasticClient(this._settings, this._connection);
 }
Example #2
0
        public ElasticClient(IConnectionSettings settings,bool  useThrift)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            this.Settings = settings;
            if (useThrift)
                this.Connection = new ThriftConnection(settings);
            else
                this.Connection = new Connection(settings);

            this.SerializationSettings = new JsonSerializerSettings()
            {
                ContractResolver = new ElasticResolver(),
                NullValueHandling = NullValueHandling.Ignore,
                Converters = new List<JsonConverter>
                {
                    new DateHistogramConverter(),
                    new IsoDateTimeConverter(),
                    new QueryJsonConverter(),
                    new FacetsMetaDataConverter()

                }
            };
            this.PropertyNameResolver = new PropertyNameResolver(this.SerializationSettings);
        }
Example #3
0
 /// <summary>
 /// 
 /// </summary>
 public ThriftConnection(IConnectionSettings connectionSettings)
 {
     Created = DateTime.Now;
     var tsocket = new TSocket(connectionSettings.Host, connectionSettings.Port);
     _transport = new TBufferedTransport(tsocket, 1024);
     _protocol = new TBinaryProtocol(_transport);
     _client = new Rest.Client(_protocol);
 }
Example #4
0
        public Connection(IConnectionSettings settings)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            this._ConnectionSettings = settings;
            this._ResourceLock = new Semaphore(settings.MaximumAsyncConnections, settings.MaximumAsyncConnections);
        }
 public static string ConnectionStringCreate(IConnectionSettings settings,  string databaseName)
 {
     if (settings.AuthMode == SqlAuthMode.SqlServer)
     {
         return string.Format(CONN_SQL, settings.ServerName, databaseName, settings.UserName, settings.Password);
     }
     return string.Format(CONN_WIN, settings.ServerName, databaseName);
 }
Example #6
0
        internal TypeMappingWriter(Type t, string typeName, IConnectionSettings connectionSettings, int maxRecursion, ConcurrentDictionary<Type, int> seenTypes)
        {
            this._type = GetUnderlyingType(t);
            this._connectionSettings = connectionSettings;

            this.TypeName = typeName;
            this.MaxRecursion = maxRecursion;
            this.SeenTypes = seenTypes;
        }
Example #7
0
        public RawElasticClient(IConnectionSettings settings, IConnection connection)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            this.Settings = settings;
            this.Connection = connection;
            this.Serializer = new ElasticSerializer(this.Settings);
        }
        public static string Resolve(this IndexNameMarker marker, IConnectionSettings connectionSettings)
        {
            if (marker == null)
                return null;
            connectionSettings.ThrowIfNull("connectionSettings");

            if (marker.Type == null)
                return marker.Name;
            return new IndexNameResolver(connectionSettings).GetIndexForType(marker.Type);
        }
Example #9
0
 /// <summary>
 /// Copies information between objects inheriting the IConnectionSettings interface
 /// </summary>
 /// <param name="source"></param>
 /// <param name="destination"></param>
 public static void CopyConnectionSettings(IConnectionSettings source, IConnectionSettings destination)
 {
     destination.BufferedInput = source.BufferedInput;
     destination.ConnectionAddress = source.ConnectionAddress;
     destination.ConnectionName = source.ConnectionName;
     destination.LocalEcho = source.LocalEcho;
     destination.NewLineSequence = source.NewLineSequence;
     destination.Port = source.Port;
     destination.TerminalType = source.TerminalType;
 }
Example #10
0
        public Connection(IConnectionSettings settings)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            this._ConnectionSettings = settings;
            var semaphore = Math.Max(1, settings.MaximumAsyncConnections);
            this._ResourceLock = new Semaphore(semaphore, semaphore);
            this._enableTrace = settings.TraceEnabled;
        }
Example #11
0
        public Connection(IConnectionSettings settings)
            : base(Connection.addressFamily)
        {
            base.Encoding = settings.Encoding;
            base.Address = settings.Host;

            base.Connected += connection_Connected;
            base.Disconnected += connection_Disconnected;
            base.Sent += connection_Sent;
            base.Recieved += connection_Recieved;
        }
Example #12
0
        public TypeMappingWriter(Type t, TypeNameMarker typeName, IConnectionSettings connectionSettings, int maxRecursion)
        {
            this._type = t;
            this._connectionSettings = connectionSettings;

            this.TypeName = typeName;
            this.MaxRecursion = maxRecursion;

            this.SeenTypes = new ConcurrentDictionary<Type, int>();
            this.SeenTypes.TryAdd(t, 0);
        }
Example #13
0
 public ElasticClient(IConnectionSettings settings,bool  useThrift)
 {
     this.Settings = settings;
     this.Connection = new ThriftConnection(settings);
     this.SerializationSettings = new JsonSerializerSettings()
     {
         ContractResolver = new CamelCasePropertyNamesContractResolver(),
         NullValueHandling = NullValueHandling.Ignore,
         Converters = new List<JsonConverter> { new IsoDateTimeConverter(), new QueryJsonConverter(), new FacetsMetaDataConverter() }
     };
     this.PropertyNameResolver = new PropertyNameResolver(this.SerializationSettings);
 }
Example #14
0
        public ConnectionListener(
            IConnectionSettings connectionSettings,
            IConnectionFactory connectionFactory,
            IPlayerRepository playerRepository,
            IAdminCredentials adminCredentials)
        {
            _connectionSettings = connectionSettings;
            _connectionFactory = connectionFactory;
            _playerRepository = playerRepository;
            _adminCredentials = adminCredentials;

            _connections = new List<IConnection>();

            var taskScheduler = new ThreadPerTaskScheduler();
            _taskFactory = new TaskFactory(taskScheduler);
        }
Example #15
0
        public ThriftConnection(IConnectionSettings connectionSettings)
        {
            this._timeout = connectionSettings.Timeout;
            this._poolSize = connectionSettings.MaximumAsyncConnections;

            this._resourceLock = new Semaphore(_poolSize, _poolSize);

            for (var i = 0; i <= connectionSettings.MaximumAsyncConnections; i++)
            {
                var tsocket = new TSocket(connectionSettings.Host, connectionSettings.Port);
                var transport = new TBufferedTransport(tsocket, 1024);
                var protocol = new TBinaryProtocol(transport);
                var client = new Rest.Client(protocol);
                _clients.Enqueue(client);
            }
        }
Example #16
0
        public ElasticClient(IConnectionSettings settings, IConnection connection)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            this._connectionSettings = settings;
            this.Connection = connection;

            this.PathResolver = new PathResolver(settings);

            this.PropertyNameResolver = new PropertyNameResolver();

            this.Serializer = new ElasticSerializer(this._connectionSettings);
            this.Raw = new RawElasticClient(this._connectionSettings, connection);
              this.Infer = new ElasticInferrer(this._connectionSettings);
        }
        public Directory(IConnectionSettings connectionSettings, IDirectorySearcherOptions directorySearcherOptions)
        {
            if(connectionSettings == null)
                throw new ArgumentNullException("connectionSettings");

            this._connectionSettings = connectionSettings;
            this._directorySearcherOptions = directorySearcherOptions;

            string hostUrl = connectionSettings.Scheme.ToString() + "://" + connectionSettings.Host;
            if(connectionSettings.Port != null)
                hostUrl += ":" + connectionSettings.Port.Value.ToString(CultureInfo.InvariantCulture);
            if(!hostUrl.EndsWith("/", StringComparison.Ordinal))
                hostUrl += "/";

            this._hostUrl = hostUrl;
            this._rootPath = hostUrl + connectionSettings.DistinguishedName;
        }
        AzureServiceBusEndpointAddress(AddressType addressType, string ns, string queueOrTopicName,
            IConnectionSettings settings, int prefetchCount)
        {
            _addressType = addressType;
            _namespace = ns;
            _queueOrTopicName = queueOrTopicName;
            _settings = settings;
            _prefetchCount = prefetchCount;

            string suffix = "";
            if (addressType == AddressType.Topic)
                suffix = "?topic=true";

            _friendlyUri = new Uri(string.Format("azure-sb://{0}/{1}{2}",
                ns,
                queueOrTopicName,
                suffix));
        }
Example #19
0
        public MySqlStorage(IConnectionSettings connectionSettings)
        {

            string connection =  string.Format("server={0};port={1};username={2};password={3};database={4}",
                connectionSettings.getHost(), connectionSettings.getPort(), connectionSettings.getLogin(), connectionSettings.getPassword(), connectionSettings.getDatabaseName());

            //This is my insert query in which i am taking input from the user through windows forms 

            //This is  MySqlConnection here i have created the object and pass my connection string. 
            _mySqlConnection = new MySqlConnection(connection);
            try
            {

                _mySqlConnection.Open();
            }
            catch (MySql.Data.MySqlClient.MySqlException)
            {
                if (connectionFailed != null)
                {
                    connectionFailed("Не удалось подключиться к базе данных, проверьте файл настроек");
                }
            }
        }
Example #20
0
        public void Connect(IConnectionSettings connectionSettings)
        {
            Log.Debug(string.Format("Connecting to device {0}", this.DeviceName));
            try
            {
                this.Protocol.ConnectionSettings = connectionSettings;
                this.Protocol.Connect();

                this.IsConnected = true;

                this.Protocol.DataReceived += Protocol_DataReceived;

                if (this.ConnectionSuccess != null)
                    this.ConnectionSuccess();
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Cannot establish connection with the device {0}", this.DeviceName);
                Log.Error(e);

                if (this.ConnectionFailed != null)
                    this.ConnectionFailed();
            }
        }
 public ILogSource GetSource(IConnectionSettings connectionSettings)
 {
     AzureConnectionSettings azureConnectionSettings = connectionSettings as AzureConnectionSettings;
     azureConnectionSettings = new AzureConnectionSettings(azureConnectionSettings.StorageName, azureConnectionSettings.StorageKey, true, azureConnectionSettings.QueryFilter, azureConnectionSettings.StartTimeFilter, azureConnectionSettings.EndTimeFilter, azureConnectionSettings.RoleFilter, azureConnectionSettings.RoleInstanceFilter);
     return new AzureLogSource(azureConnectionSettings);
 }
 public IEnumerable<ILogSource> GetSources(IConnectionSettings settings)
 {
     return new List<ILogSource> { GetSource(settings) };
 }
 public Directory(IConnectionSettings connectionSettings)
     : this(connectionSettings, null)
 {
 }
Example #24
0
 public InMemoryConnection(IConnectionSettings settings)
     : base(settings)
 {
 }
Example #25
0
 public InMemoryConnection(IConnectionSettings settings, ConnectionStatus fixedResult)
     : base(settings)
 {
     this._fixedResult = fixedResult;
 }
Example #26
0
 public Connection(IConnectionSettings settings)
 {
     this._ConnectionSettings = settings;
     this._ResourceLock = new Semaphore(settings.MaximumAsyncConnections, settings.MaximumAsyncConnections);
 }
Example #27
0
 public TestConnection(IConnectionSettings settings)
     : base(settings)
 {
 }
Example #28
0
 public ElasticCamelCaseResolver(IConnectionSettings connectionSettings)
     : base(connectionSettings)
 {
 }
Example #29
0
 public ElasticResolver(IConnectionSettings connectionSettings)
     : base(true)
 {
     this.ConnectionSettings = connectionSettings;
 }
Example #30
0
 public RawElasticClient(IConnectionSettings settings)
     : this(settings, new Connection(settings))
 {
 }