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

ExportFileSerializer

public class ExportFileSerializer
using Microsoft.VisualBasic.CompilerServices; using Relativity.DataExchange; using Relativity.DataExchange.Service; using System; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Xml.Linq; namespace kCura.WinEDDS { public class ExportFileSerializer { public class ExportSettingsValidator { public virtual bool IsValidExportDirectory(string path) { return Directory.Exists(path); } } [Serializable] [CompilerGenerated] internal sealed class _Closure$__ { public static readonly _Closure$__ $I; public static Func<PropertyInfo, bool> $I9-0; static _Closure$__() { $I = new _Closure$__(); } internal bool _Lambda$__9-0(PropertyInfo prop) { return prop.CanWrite; } } private const string ENTITY_OBJECT_TYPE_NAME = "Entity"; private const string CUSTODIAN_OBJECT_TYPE_NAME = "Custodian"; private ExportSettingsValidator _settingsValidator; public ExportSettingsValidator SettingsValidator { get { if (_settingsValidator == null) _settingsValidator = new ExportSettingsValidator(); return _settingsValidator; } set { _settingsValidator = value; } } public ExportFileSerializer() { _settingsValidator = new ExportSettingsValidator(); } public virtual string TransformExportFileXml(XDocument input) { return input.ToString(); } public virtual ExtendedExportFile DeserializeExportFile(ExportFile currentExportFile, string xml) { ExportFile deserialized = DeserializeExportFile(XDocument.Parse(xml)); return PopulateDeserializedExportFile(currentExportFile, deserialized); } public virtual ExtendedExportFile PopulateDeserializedExportFile(ExportFile currentExportFile, ExportFile deserialized) { ExtendedExportFile extendedExportFile = new ExtendedExportFile(currentExportFile.ArtifactTypeID); foreach (PropertyInfo item in extendedExportFile.GetType().GetProperties().Where((_Closure$__.$I9-0 != null) ? _Closure$__.$I9-0 : (_Closure$__.$I9-0 = ((PropertyInfo prop) => prop.CanWrite)))) { item.SetValue(extendedExportFile, RuntimeHelpers.GetObjectValue(item.GetValue(PropertyIsReadFromExisting(item) ? currentExportFile : deserialized, null)), null); } ExportFile.ExportType typeOfExport = extendedExportFile.TypeOfExport; if (typeOfExport != 0) { if ((uint)(typeOfExport - 2) <= 1) extendedExportFile.ArtifactID = currentExportFile.ArtifactID; } else extendedExportFile.ImagePrecedence = new Pair[0]; if (!ObjectTypesAreCompatible(currentExportFile, extendedExportFile)) extendedExportFile = new ErrorExportFile("Cannot load '" + currentExportFile.ObjectTypeName + "' settings from a saved '" + extendedExportFile.ObjectTypeName + "' export"); if (!SettingsValidator.IsValidExportDirectory(extendedExportFile.FolderPath)) extendedExportFile.FolderPath = string.Empty; return extendedExportFile; } public bool ObjectTypesAreCompatible(ExportFile currentExportFile, ExportFile deserializedExportFile) { if (Operators.CompareString(currentExportFile.ObjectTypeName, "Entity", false) == 0 && Operators.CompareString(deserializedExportFile.ObjectTypeName, "Custodian", false) == 0) return true; if (Operators.CompareString(currentExportFile.ObjectTypeName, "Custodian", false) == 0 && Operators.CompareString(deserializedExportFile.ObjectTypeName, "Entity", false) == 0) return true; return Operators.CompareString(SqlNameHelper.GetSqlFriendlyName(currentExportFile.ObjectTypeName), SqlNameHelper.GetSqlFriendlyName(deserializedExportFile.ObjectTypeName), false) == 0; } private bool PropertyIsReadFromExisting(PropertyInfo p) { object[] customAttributes = p.GetCustomAttributes(typeof(ReadFromExisting), false); int num = 0; if (num < customAttributes.Length) { Attribute attribute = (Attribute)customAttributes[num]; return true; } return false; } public virtual ExportFile DeserializeExportFile(XDocument xml) { return SerializationHelper.DeserializeFromSoap<ExportFile>(TransformExportFileXml(xml)); } } }