<PackageReference Include="Relativity.Server.Import.SDK" Version="2.9.2" />

DocumentFieldCollection

using Relativity.DataExchange.Service; using System; using System.Collections; using System.Collections.Generic; namespace kCura.WinEDDS { public class DocumentFieldCollection : IEnumerable<DocumentField> { public class FieldNameComparer : IComparer { public int Compare(object x, object y) { DocumentField obj = (DocumentField)x; DocumentField documentField = (DocumentField)y; return string.Compare(obj.FieldName, documentField.FieldName); } int IComparer.Compare(object x, object y) { return this.Compare(x, y); } } private Dictionary<int, DocumentField> _idIndex; private Dictionary<string, DocumentField> _nameIndex; public DocumentField GroupIdentifier => Item("Group Identifier"); public DocumentField FullText => GetFieldByCategory(FieldCategory.FullText); public ICollection AllFields { get { DocumentField[] array = new DocumentField[checked(_idIndex.Count - 1 + 1)]; _idIndex.Values.CopyTo(array, 0); Array.Sort(array, new FieldNameComparer()); return array; } } public DocumentField Item(int fieldID) { return _idIndex[fieldID]; } public DocumentField Item(string fieldName) { return _nameIndex[fieldName]; } public int Count() { return _nameIndex.Count; } public void Add(DocumentField field) { _idIndex.Add(field.FieldID, field); _nameIndex.Add(field.FieldName, field); } public void AddRange(DocumentField[] fields) { foreach (DocumentField documentField in fields) { _idIndex.Add(documentField.FieldID, documentField); _nameIndex.Add(documentField.FieldName, documentField); } } public string[] Names() { string[] array = new string[checked(_nameIndex.Keys.Count - 1 + 1)]; _nameIndex.Keys.CopyTo(array, 0); Array.Sort(array); return array; } public bool Exists(int fieldID) { if (_idIndex.ContainsKey(fieldID)) return _idIndex[fieldID] != null; return false; } public bool Exists(string fieldName) { if (_nameIndex.ContainsKey(fieldName)) return _nameIndex[fieldName] != null; return false; } private DocumentField GetFieldByCategory(FieldCategory type) { foreach (int key in _idIndex.Keys) { DocumentField documentField = _idIndex[key]; if (documentField.FieldCategory == type) return documentField; } return null; } public DocumentField[] GetFieldsByCategory(FieldCategory type) { ArrayList arrayList = new ArrayList(); foreach (int key in _idIndex.Keys) { DocumentField documentField = _idIndex[key]; if (documentField.FieldCategory == type) arrayList.Add(documentField); } return (DocumentField[])arrayList.ToArray(typeof(DocumentField)); } public DocumentField[] IdentifierFields() { ArrayList arrayList = new ArrayList(); foreach (DocumentField value in _idIndex.Values) { if (value.FieldCategoryID == 2) arrayList.Add(value); } return (DocumentField[])arrayList.ToArray(typeof(DocumentField)); } public string[] IdentifierFieldNames() { DocumentField[] array = IdentifierFields(); checked { string[] array2 = new string[array.Length - 1 + 1]; int num = array2.Length - 1; for (int i = 0; i <= num; i++) { array2[i] = array[i].FieldName; } Array.Sort(array2); return array2; } } public string[] NamesForIdentifierDropdown() { ArrayList arrayList = new ArrayList(); foreach (DocumentField value in _idIndex.Values) { if (value.FieldCategoryID != 8 && value.FieldCategoryID != 5 && value.FieldTypeID == 0) arrayList.Add(value.FieldName); } string[] obj = (string[])arrayList.ToArray(typeof(string)); Array.Sort(obj); return obj; } public DocumentFieldCollection() { _idIndex = new Dictionary<int, DocumentField>(); _nameIndex = new Dictionary<string, DocumentField>(); } public DocumentFieldCollection(DocumentField[] fields) : this() { if (fields != null) AddRange(fields); } public IEnumerator GetEnumerator() { return IEnumerable_GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } private IEnumerator<DocumentField> IEnumerable_GetEnumerator() { return (IEnumerator<DocumentField>)_idIndex.Values.GetEnumerator(); } IEnumerator<DocumentField> IEnumerable<DocumentField>.GetEnumerator() { return this.IEnumerable_GetEnumerator(); } } }