/// <summary>
 /// Initializes a new instance of the <see cref="ChecklistQuestionFieldInfo"/> struct.
 /// </summary>
 /// <param name="guid">
 /// The field GUID.
 /// </param>
 /// <param name="systemName">
 /// The field system name.
 /// </param>
 /// <param name="source">
 /// The field source.
 /// </param>
 public ChecklistQuestionFieldInfo(Guid? guid, string systemName, ChecklistQuestionFieldSource source)
     : this()
 {
     Guid = guid;
     SystemName = systemName;
     Source = source;
 }
        /// <summary>
        /// Gets the source item.
        /// </summary>
        /// <param name="source">
        /// The source type.
        /// </param>
        /// <returns>
        /// The source item.
        /// </returns>
        public IEditableRoot this[ChecklistQuestionFieldSource source]
        {
            get
            {
                switch (source)
                {
                    case ChecklistQuestionFieldSource.QuestionProcess:
                        return QuestionItem;

                    case ChecklistQuestionFieldSource.RootProcess:
                        return RootItem;

                    default:
                        return null;
                }
            }
        }
 /// <summary>
 /// Method called by MobileFormatter when an object should be deserialized. The data should be deserialized from the SerializationInfo parameter.
 /// </summary>
 /// <param name="info">
 /// Object containing the serialized data.
 /// </param>
 public void SetState(SerializationInfo info)
 {
     SystemName = info.GetValue<string>("SystemName");
     Source = info.GetValue<ChecklistQuestionFieldSource>("Source");
     Guid = info.GetValue<Guid?>("Guid");
 }
 /// <summary>
 /// Returns a copy of this <see cref="ChecklistQuestionFieldInfo"/> whose source is changed to <paramref name="source"/>.
 /// </summary>
 /// <param name="source">
 /// The source.
 /// </param>
 /// <returns>
 /// The <see cref="ChecklistQuestionFieldInfo"/>.
 /// </returns>
 public ChecklistQuestionFieldInfo SetSource(ChecklistQuestionFieldSource source)
 {
     return new ChecklistQuestionFieldInfo(Guid, SystemName, source);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ChecklistQuestionField"/> class.
        /// </summary>
        /// <param name="field">
        /// The field.
        /// </param>
        /// <param name="process">
        /// The process.
        /// </param>
        /// <param name="questionSource">
        /// The question source.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="field"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="process"/> parameter is null.
        /// </exception>
        public ChecklistQuestionField(FieldInfo field, PublishedProcessInfo process, ChecklistQuestionFieldSource questionSource)
        {
            if (field == null)
                throw new ArgumentNullException("field");

            if (process == null)
                throw new ArgumentNullException("process");

            _name = field.Name;
            _systemName = field.SystemName;
            _guid = field.Guid;
            _questionSource = questionSource;
            _sourceName = process.Name;
            _columnType = field.ColumnType;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ChecklistQuestionField"/> class.
        /// </summary>
        /// <param name="field">
        /// The field.
        /// </param>
        /// <param name="process">
        /// The process.
        /// </param>
        /// <param name="questionSource">
        /// The question source.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="field"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="process"/> parameter is null.
        /// </exception>
        public ChecklistQuestionField(FieldEdit field, ProcessEdit process, ChecklistQuestionFieldSource questionSource)
        {
            if (field == null)
                throw new ArgumentNullException("field");

            if (process == null)
                throw new ArgumentNullException("process");

            _name = field.Name;
            _systemName = field.SystemName;
            _guid = field.Guid;
            _questionSource = questionSource;
            _sourceName = process.Name;

            ColumnTypes columnType;
            if (field.TryGetColumnType(out columnType))
                _columnType = columnType;

            _fieldPropertyChangedListener = new PropertyChangedListener(this, field)
                                            {
                                                OnEventAction = OnFieldPropertyChanged,
                                                OnDetachAction = Static
            };
            field.PropertyChanged += _fieldPropertyChangedListener.OnEvent;

            _processPropertyChangedListener = new PropertyChangedListener(this, process)
                                              {
                                                  OnEventAction = OnProcessPropertyChanged,
                                                  OnDetachAction = Static
            };
            process.PropertyChanged += _processPropertyChangedListener.OnEvent;
        }