/// <summary>
        /// Get the existing sync state for this CRM item, if it exists, else null.
        /// </summary>
        /// <param name="outlookId">The Outlook id of the syncstate to seek.</param>
        /// <param name="crmId">The CRM id of the syncstate to seek.</param>
        /// <returns>The appropriate sync state, or null if none.</returns>
        public SyncState GetExistingSyncState(string outlookId, CrmId crmId)
        {
            SyncState result;

            if (this.byCrmId.ContainsKey(crmId))
            {
                result = this.byCrmId[crmId];
            }
            else if (!string.IsNullOrEmpty(outlookId))
            {
                if (this.byOutlookId.ContainsKey(outlookId))
                {
                    result = this.byOutlookId[outlookId];
                }
                else
                {
                    result = this.byGlobalId.ContainsKey(outlookId) ?
                             this.byGlobalId[outlookId] :
                             null;
                }
            }
            else
            {
                string simulatedGlobalId = SyncStateManager.SimulateGlobalId(crmId);

                result = this.byGlobalId.ContainsKey(simulatedGlobalId) ? this.byGlobalId[simulatedGlobalId] : null;
            }

            return(result);
        }
        /// <summary>
        /// Get the existing sync state for this CRM item, if it exists, else null.
        /// </summary>
        /// <param name="crmItem">The item.</param>
        /// <returns>The appropriate sync state, or null if none.</returns>
        public SyncState GetExistingSyncState(EntryValue crmItem)
        {
            SyncState result;
            string    outlookId = crmItem.GetValueAsString("outlook_id");
            CrmId     crmId     = CrmId.Get(crmItem.id);

            if (this.byCrmId.ContainsKey(crmId))
            {
                result = this.byCrmId[crmId];
            }
            else if (this.byOutlookId.ContainsKey(outlookId))
            {
                result = this.byOutlookId[outlookId];
            }
            else if (this.byGlobalId.ContainsKey(outlookId))
            {
                result = this.byGlobalId[outlookId];
            }
            else
            {
                string simulatedGlobalId = SyncStateManager.SimulateGlobalId(crmId);

                if (this.byGlobalId.ContainsKey(simulatedGlobalId))
                {
                    result = this.byGlobalId[simulatedGlobalId];
                }
                else
                {
                    string distinctFields = GetDistinctFields(crmItem);

                    if (string.IsNullOrEmpty(distinctFields))
                    {
                        result = null;
                    }
                    else if (this.byDistinctFields.ContainsKey(distinctFields))
                    {
                        result = this.byDistinctFields[distinctFields];
                    }
                    else
                    {
                        result = null;
                    }
                }
            }

            return(result);
        }