Esempio n. 1
0
        /// <summary>
        /// Attempts opening a MongoDBWorkspace from its connection file path
        /// </summary>
        /// <param name="wksString">the path to a connection file</param>
        /// <returns>a mongodbworkspace</returns>
        public MongoDBWorkspace OpenMongoDBWorkspace(string wksString)
        {
            MongoDatabase mDB;

            try
            {
                string          connString = ConnectionUtilities.DecodeConnFile(wksString);
                MongoDBConnInfo connInfo   = ConnectionUtilities.ParseConnectionString(connString);
                mDB = ConnectionUtilities.OpenConnection(connInfo);
            }
            catch (Exception e)
            {
                throw new COMException(e.Message);
            }

            return(new MongoDBWorkspace(mDB));
        }
Esempio n. 2
0
        /// <summary>
        /// Determins whether a string represents a workspace
        /// Note that workspace strings are file paths to conn files in this plugin
        /// </summary>
        /// <param name="wksString">the string (i.e. path to conn file)</param>
        /// <returns>whether it is or not</returns>
        public bool IsWorkspace(string wksString)
        {
            bool retVal = false;

            try
            {
                if (Directory.Exists(wksString))
                {
                    return(Directory.GetFiles(wksString, "*.mongoconn").Length > 0);
                }

                string          connString = ConnectionUtilities.DecodeConnFile(wksString);
                MongoDBConnInfo connInfo   = ConnectionUtilities.ParseConnectionString(connString);
                ConnectionUtilities.OpenConnection(connInfo);
                retVal = true;
            }
            catch (Exception)
            {
                // this just means this isn't a proper string
            }

            return(retVal);
        }