public CouchbaseSettings(LogicJSONObject jsonObject) { LogicJSONArray serverArray = jsonObject.GetJSONArray("servers"); LogicJSONArray bucketArray = jsonObject.GetJSONArray("buckets"); this.Servers = new LogicArrayList <CouchbaseServerEntry>(serverArray.Size()); this.Buckets = new LogicArrayList <CouchbaseBucketEntry>(bucketArray.Size()); for (int i = 0; i < serverArray.Size(); i++) { this.Servers.Add(new CouchbaseServerEntry(serverArray.GetJSONObject(i))); } for (int i = 0; i < bucketArray.Size(); i++) { CouchbaseBucketEntry entry = new CouchbaseBucketEntry(bucketArray.GetJSONString(i)); if (this.GetBucketIdx(entry.Name) != -1) { Logging.Warning("EnvironmentSettings::CouchbaseSettings.ctr: bucket with the same name already exists."); continue; } if ((uint)entry.ServerIndex >= this.Servers.Size()) { Logging.Warning(string.Format("EnvironmentSettings::CouchbaseSettings.ctr: server index is out of bounds (bucket name: {0})", entry.ServerIndex)); continue; } this.Buckets.Add(entry); } }
public bool TryGetBucketData(string name, out CouchbaseServerEntry serverEntry, out CouchbaseBucketEntry bucketEntry) { int index = this.GetBucketIdx(name); if (index != -1) { bucketEntry = this.Buckets[index]; serverEntry = this.Servers[bucketEntry.ServerIndex]; return(true); } serverEntry = default(CouchbaseServerEntry); bucketEntry = null; return(false); }