Exemple #1
0
        public ArangoContext(string cs)
        {
            User        = new ArangoUserModule(this);
            Collection  = new ArangoCollectionModule(this);
            View        = new ArangoViewModule(this);
            Database    = new ArangoDatabaseModule(this);
            Graph       = new ArangoGraphModule(this);
            Transaction = new ArangoTransactionModule(this);
            Document    = new ArangoDocumentModule(this);
            Query       = new ArangoQueryModule(this);
            Index       = new ArangoIndexModule(this);
            Analyzer    = new ArangoAnalyzerModule(this);
            Function    = new ArangoFunctionModule(this);

            var builder = new DbConnectionStringBuilder {
                ConnectionString = cs
            };

            builder.TryGetValue("Server", out var s);
            builder.TryGetValue("Realm", out var r);
            builder.TryGetValue("User ID", out var uid);
            builder.TryGetValue("User", out var u);
            builder.TryGetValue("Password", out var p);

            var server   = s as string;
            var user     = u as string ?? uid as string;
            var password = p as string;
            var realm    = r as string;

            if (string.IsNullOrWhiteSpace(server))
            {
                throw new ArgumentException("Server invalid");
            }

            if (string.IsNullOrWhiteSpace(user))
            {
                throw new ArgumentException("User invalid");
            }

            if (string.IsNullOrWhiteSpace(realm))
            {
                Realm = string.Empty;
            }
            else
            {
                Realm = realm + "-";
            }

            Server    = server;
            _user     = user;
            _password = password;
        }
        public ArangoContext(IArangoConfiguration config)
        {
            Configuration = config ?? throw new ArgumentNullException(nameof(config));

            User        = new ArangoUserModule(this);
            Collection  = new ArangoCollectionModule(this);
            View        = new ArangoViewModule(this);
            Database    = new ArangoDatabaseModule(this);
            Graph       = new ArangoGraphModule(this);
            Transaction = new ArangoTransactionModule(this);
            Document    = new ArangoDocumentModule(this);
            Query       = new ArangoQueryModule(this);
            Index       = new ArangoIndexModule(this);
            Analyzer    = new ArangoAnalyzerModule(this);
            Function    = new ArangoFunctionModule(this);
        }
        public ArangoContext(string cs, IArangoConfiguration settings = null)
        {
            Configuration = settings ?? new ArangoConfiguration();
            Configuration.ConnectionString = cs;

            User        = new ArangoUserModule(this);
            Collection  = new ArangoCollectionModule(this);
            View        = new ArangoViewModule(this);
            Database    = new ArangoDatabaseModule(this);
            Graph       = new ArangoGraphModule(this);
            Transaction = new ArangoTransactionModule(this);
            Document    = new ArangoDocumentModule(this);
            Query       = new ArangoQueryModule(this);
            Index       = new ArangoIndexModule(this);
            Analyzer    = new ArangoAnalyzerModule(this);
            Function    = new ArangoFunctionModule(this);
        }