///// ------------------------------------------------------------------------------------ ///// <summary> ///// Compares the contents of this SortOptions object with the one specified. ///// TODO: Write some tests for this method. It could be used to fix PA-830. ///// </summary> ///// ------------------------------------------------------------------------------------ //public bool AreEqual(SortOptions otherOptions) //{ // if (otherOptions == null) // return false; // if (m_sortType != otherOptions.m_sortType || // m_advancedEnabled != otherOptions.m_advancedEnabled || // m_saveManuallySetSortOptions != otherOptions.m_saveManuallySetSortOptions) // { // return false; // } // for (int i = 0; i < m_advSortOptions.Length; i++) // { // if (m_advSortOptions[i] != otherOptions.m_advSortOptions[i]) // return false; // } // for (int i = 0; i < m_advRlOptions.Length; i++) // { // if (m_advRlOptions[i] != otherOptions.m_advRlOptions[i]) // return false; // } // if (m_sortInfoList == null && otherOptions.m_sortInfoList != null || // m_sortInfoList != null && otherOptions.m_sortInfoList == null || // m_sortInfoList.Count != otherOptions.m_sortInfoList.Count) // { // return false; // } // for (int i = 0; i < m_sortInfoList.Count; i++) // { // if (m_sortInfoList[i].ascending != otherOptions.m_sortInfoList[i].ascending || // m_sortInfoList[i].FieldInfo.FieldName != // otherOptions.m_sortInfoList[i].FieldInfo.FieldName) // { // return false; // } // } // return true; //} /// ------------------------------------------------------------------------------------ /// <summary> /// Deserializing a project brings in only the field names for the sort options's /// SortFields property. We actually want each SortFields entry to contain a pointer /// to a project's field. This will make sure each one points to a real PaField. /// </summary> /// ------------------------------------------------------------------------------------ public void PostDeserializeInitialization(PaProject project) { _project = project; foreach (var sf in SortFields) { sf.Field = project.Fields.SingleOrDefault(f => f.Name == sf.PaFieldName); sf.PaFieldName = null; } // Toss out any fields that couldn't be mapped, although that should probably never happen. SortFields = SortFields.Where(sf => sf.Field != null).ToList(); // We have to have at least one sort field. if (SortFields.Count == 0) { SetPrimarySortField(project.Fields.SingleOrDefault(f => f.Type == FieldType.Phonetic), false, true); } }