/// <summary> /// /// </summary> /// <returns></returns> /// <remarks> /// TODO: Today 12/6/16 commented previous implementation and now just using _bsonDocument.GetEnumerator() /// - See how that goes or otherwise fall back to below plan /// How does this behave(or not?) using dynamic alloc'd local memory for var dict? /// TODO: Probably needs an Enumerator class implementing IDisposable, containing the array, /// which on Finalise() does the class does delete [] dict /// </remarks> public IEnumerator <KeyValuePair <string, object> > GetEnumerator() { return((IEnumerator <KeyValuePair <string, object> >)_bsonDocument.GetEnumerator()); //KeyValuePair<string, object>[] dict = new KeyValuePair<string, object>[_bsonDocument.ElementCount]; //CopyTo(dict, 0); //return (IEnumerator<KeyValuePair<string, object>>)dict.ToList().GetEnumerator(); }
/** \fn void CreateReplicaCataGroup(string hostName, int port, string dbpath, BsonDocument configure) * \brief Create the Replica Catalog Group with given options * \param hostName The host name * \param port The port * \param dbpath The database path * \param configure The configure options * \exception SequoiaDB.BaseException * \exception System.Exception */ public void CreateReplicaCataGroup(string hostName, int port, string dbpath, BsonDocument configure) { if (hostName == null || port == 0 || dbpath == null) throw new BaseException("SDB_INVALIDARG"); string command = SequoiadbConstants.ADMIN_PROMPT + SequoiadbConstants.CREATE_CMD + " " + SequoiadbConstants.CATALOG + " " + SequoiadbConstants.GROUP; BsonDocument condition = new BsonDocument(); condition.Add(SequoiadbConstants.FIELD_HOSTNAME, hostName); condition.Add(SequoiadbConstants.SVCNAME, port.ToString()); condition.Add(SequoiadbConstants.DBPATH, dbpath); if (configure != null) { IEnumerator<BsonElement> it = configure.GetEnumerator(); while (it.MoveNext()) { BsonElement e = it.Current; if (e.Name == SequoiadbConstants.FIELD_HOSTNAME || e.Name == SequoiadbConstants.SVCNAME || e.Name == SequoiadbConstants.DBPATH) continue; condition.Add(e.Name, e.Value.AsString); } } BsonDocument dummyObj = new BsonDocument(); SDBMessage rtn = AdminCommand(command, condition, dummyObj, dummyObj, dummyObj); int flags = rtn.Flags; if (flags != 0) throw new BaseException(flags); }
public IEnumerator <KeyValuePair <string, object> > GetEnumerator() { return(new DocumentEnumerator2(_document.GetEnumerator())); }