/// <summary>
        /// Gets the generic field definition.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <returns>System.String.</returns>
        private string GetGenericFieldDefinition(SyncProcessDestinationField field)
        {
            var result = new StringBuilder();
            result.AppendFormat(
                @"new SynchronizationField({0}, {1}, {2}, {3})",
                field.Name.ToLiteral(),
                field.SystemName.ToLiteral(),
                field.IsKey.ToLiteral(),
                field.MappedTo.ToLiteral());

            return result.ToString();
        }
        /// <summary>
        /// Gets the version master field definition.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <returns>System.String.</returns>
        private string GetVersionMasterFieldDefinition(SyncProcessDestinationField field)
        {
            var keyFieldDefinitions = new List<string>();

            foreach (var subfield in field.Subfields)
            {
                if (!subfield.IsKey || string.IsNullOrEmpty(subfield.MappedTo))
                    continue;

                keyFieldDefinitions.Add(GetGenericFieldDefinition(subfield));
            }

            var result = new StringBuilder();

            result.AppendFormat(
                @"new SynchronizationField({0}, {1}, {2}, {3},
                    new SynchronizationField[]
                    {{
                        {4}
                    }})",
                field.Name.ToLiteral(),
                field.SystemName.ToLiteral(),
                field.IsKey.ToLiteral(),
                field.MappedTo.ToLiteral(),
                string.Join("," + Environment.NewLine, keyFieldDefinitions));

            return result.ToString();
        }
        /// <summary>
        /// Gets the add version fields.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="field">The field.</param>
        /// <returns>System.String.</returns>
        private string GetAddVersionFields(IProcessDefinition process, SyncProcessDestinationField field)
        {
            var result = new StringBuilder();

            if (!process.IsVersioningEnabled)
                return string.Empty;

            var versionDateField = field.Subfields.FirstOrDefault(x => x.SystemName == Constants.VersionDate);
            var versionNumberField = field.Subfields.FirstOrDefault(x => x.SystemName == Constants.VersionNumber);
            var versionMasterField = field.Subfields.FirstOrDefault(x => x.SystemName == Constants.VersionMaster);

            if (versionDateField != null && !string.IsNullOrEmpty(versionDateField.MappedTo))
                result.AppendFormat(
                    @"
            _synchronizationMap.SynchronizedFields.Add({0});
", GetGenericFieldDefinition(versionDateField));

            if (versionNumberField != null && !string.IsNullOrEmpty(versionNumberField.MappedTo))
                result.AppendFormat(
                    @"
            _synchronizationMap.SynchronizedFields.Add({0});
", GetGenericFieldDefinition(versionNumberField));

            if (versionMasterField != null && versionMasterField.Subfields.Any(f => f.IsKey && !string.IsNullOrEmpty(f.MappedTo)))
                result.AppendFormat(
                    @"
            _synchronizationMap.SynchronizedFields.Add({0});
", GetVersionMasterFieldDefinition(versionMasterField));

            return result.ToString();
        }
        /// <summary>
        /// Gets the add current state field.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="field">The field.</param>
        /// <returns>System.String.</returns>
        private string GetAddCurrentStateField(IProcessDefinition process, SyncProcessDestinationField field)
        {
            var result = new StringBuilder();

            if (!process.IsStateEnabled || string.IsNullOrEmpty(field.MappedTo))
                return string.Empty;

            result.AppendFormat(
                @"
            _synchronizationMap.SynchronizedFields.Add({0});", GetGenericFieldDefinition(field));

            return result.ToString();
        }
        /// <summary>
        /// Gets the add cross reference field.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="tableField">The table field.</param>
        /// <param name="field">The field.</param>
        /// <returns>System.String.</returns>
        private string GetAddCrossReferenceField(IProcessDefinition process, TableFieldDefinition tableField, SyncProcessDestinationField field)
        {
            if (!field.Subfields.Any(sf => sf.IsKey && !string.IsNullOrEmpty(sf.MappedTo)))
                return string.Empty;

            var result = new StringBuilder();

            result.AppendFormat(
                @"
            _synchronizationMap.SynchronizedFields.Add({0});
", GetCrossReferenceFieldDefinition(field));

            return result.ToString();
        }