/// <summary>
        /// This method will attempt to connect to the third-party.
        /// </summary>
        /// <param name="properties">
        /// The collection of information required by this Connector to connect to the third-party.
        /// </param>
        public void Connect(IDictionary<string, string> properties)
        {
            // Use LogMethodExecution to add entry and exit tracing to a method. 
            // When wrapped in a using statement, the exit point is written during garbage collection.
            using (new LogMethodExecution(ConnectorTypeName, "Connect"))
            {
                try
                {
                    //parse the incomming properties to ensure the proper parameters are set
                    BuildConnectionString(properties);

                    //attempt a connection to the selected datasource
                    _dataAccess.OleDbConnect(_connectionString);
                }
                catch (OleDbException oleDbException)
                {
                    string msg = ExceptionFormatter.BuildActionableException("Unable to Connect to datasource", string.Format("The following error occured in the {0}:", ConnectorTypeName),
                                                                             oleDbException);
                    //be sure to log any errors that occure while attempting to connect
                    Logger.Write(Logger.Severity.Error, ConnectorTypeName, msg);
                    //throw the InvalidConnectionException found in the ConnectorApi
                    throw new InvalidConnectionException(msg);
                }
                catch (InvalidOperationException invalidOperationException)
                {
                    string msg = ExceptionFormatter.BuildActionableException("Unable to connect to datasource the provider information is invalid.", string.Format("The following error occured in the {0}:", ConnectorTypeName),
                                                         invalidOperationException);
                    //be sure to log an error that is due to an invalid provider
                    Logger.Write(Logger.Severity.Error, ConnectorTypeName, msg);
                    //throw the InvalidConnectionException found in the ConnectorApi
                    throw new InvalidConnectionException(msg);
                }
            }
        }
        /// <summary>
        /// Connects the Connector and authorizes the credentials of the user.
        /// </summary>
        /// <param name="properties">Collection of information required by this Connector to connect to the REST service.</param>
        public void Connect(IDictionary <string, string> properties)
        {
            /* LogMethodExecution will write time stamps at the start and
             * end of the using statement. Use this to keep track of when
             * methods are executing
             */

            using (new LogMethodExecution("Rest CDK Example", "RestConnector.Connect()"))
            {
                /* For the initial authorization, we need to connect and get the access token
                 * Pull the oAuth information out of the properties dictionary and verify its format:
                 */
                try
                {
                    if (Uri.IsWellFormedUriString(properties[OAuthResponse], UriKind.RelativeOrAbsolute))
                    {
                        var queryString = HttpUtility.ParseQueryString(properties[OAuthResponse]);
                        var goToWebinar = new GoToWebinarClient();

                        string oAuthCode = queryString["code"];

                        //get the properties from the REST service:
                        _connectionInfo = goToWebinar.Authenticate(oAuthCode, OAuthApiKey);

                        //loop through and add them to our dictionary:
                        foreach (var item in _connectionInfo)
                        {
                            properties.Add(item.Key, item.Value);
                        }

                        //Use Scribe's CDK to encrypt the access token in the dictionary:
                        //Scribe OnLine uses the properties parameter further up, byref, to store these values.
                        properties["AccessToken"] = Encryptor.Encrypt_AesManaged(properties["AccessToken"], CryptoKey);
                    }
                    else
                    {
                        /* We've connected before and already have the token in our dictionary:
                         *  We're using the connection data that's serialized in memory
                         */


                        using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(properties[OAuthResponse])))
                        {
                            //Use the CDK to deserialize the properties dictionary
                            _connectionInfo = XmlTextSerializer.DeserializeFromStream <Dictionary <string, string> >(memoryStream);

                            /*Check the properties for the access token, if it doesn't exist, dig into it for the
                             * oauth_response and look there for the access token
                             */
                            if (_connectionInfo.ContainsKey("AccessToken"))
                            {
                                _connectionInfo["AccessToken"] = Decryptor.Decrypt_AesManaged(_connectionInfo["AccessToken"], CryptoKey);
                            }
                            else
                            {
                                if (_connectionInfo.ContainsKey(OAuthResponse))
                                {
                                    using (var innerStream = new MemoryStream(Encoding.UTF8.GetBytes(_connectionInfo[OAuthResponse])))
                                    {
                                        _connectionInfo = XmlTextSerializer.DeserializeFromStream <Dictionary <string, string> >(innerStream);
                                        _connectionInfo["AccessToken"] = Decryptor.Decrypt_AesManaged(_connectionInfo["AccessToken"], CryptoKey);
                                    }
                                }
                            }
                        }
                    }

                    //Check to see how the connection went and set some additional members on this class:
                    if (_connectionInfo.Count > 0)
                    {
                        IsConnected             = true;
                        this.QueryProcessor     = new QueryProcessor(_connectionInfo, _webinarClient);
                        this.OperationProcessor = new OperationProcessor(this._webinarClient, this._connectionInfo);
                    }
                }
                catch (System.Net.WebException exception)
                {
                    //Use the CDK to create a message from the exception
                    string message = ExceptionFormatter.BuildActionableException(
                        "Unable to connect to the service due to a Web exception",
                        "The following error occured in the REST Connector",
                        exception);

                    //log the exception
                    Logger.Write(Logger.Severity.Error, "REST Connector", message);

                    //Throw an exception that the CDK will recognize:
                    throw new InvalidConnectionException(message);
                }
                catch (Exception exception)
                {
                    string message = ExceptionFormatter.BuildActionableException(
                        "Unable to connect to the service.",
                        "The following error occured while trying to connect to the REST service.",
                        exception);

                    Logger.Write(Logger.Severity.Error, "REST Connector", message);

                    throw new InvalidConnectionException(message);
                }
            }
        }