/// <summary> /// Gets the .NET type for the specified object type and WITSML version. /// </summary> /// <param name="objectType">The data object type.</param> /// <param name="family">THe data object family name.</param> /// <param name="version">The WITSML version.</param> /// <returns>The .NET type for the data object.</returns> /// <remarks>Handles versions of the format X.Y[.X.[.W]] and dataVersion=X.Y[.Z[.W]].</remarks> public static Type GetObjectType(string objectType, string family, string version) { if (string.IsNullOrEmpty(version) || version.Length < 3) { return(null); } Assembly assembly; string familyUpper = family.ToUpperInvariant(); if (familyUpper == ObjectFamilies.Witsml) { assembly = typeof(IWitsmlDataObject).Assembly; } else if (familyUpper == ObjectFamilies.Prodml) { assembly = typeof(IProdmlDataObject).Assembly; } else if (familyUpper == ObjectFamilies.Resqml) { assembly = typeof(IResqmlDataObject).Assembly; } else if (familyUpper == ObjectFamilies.Eml) { // TODO: Update this once common is implemented independently. familyUpper = "WITSML"; version = "2.0"; assembly = typeof(IWitsmlDataObject).Assembly; } else { return(null); } var index = version.LastIndexOf('='); index++; // index will be -1 if no '=' is found so no special case needed. char build = version.Length > index + 4 ? version[index + 4] : '0'; var ns = $"Energistics.DataAccess.{familyUpper}{version[index]}{version[index + 2]}{build}."; if (WbGeometry.EqualsIgnoreCase(objectType) && !OptionsIn.DataVersion.Version200.Equals(version)) { objectType = $"StandAlone{WellboreGeometry.ToPascalCase()}"; } return(assembly.GetType(ns + objectType.ToPascalCase())); }
/// <summary> /// Gets the .NET type for the specified object type and WITSML version. /// </summary> /// <param name="objectType">The data object type.</param> /// <param name="version">The WITSML version.</param> /// <returns>The .NET type for the data object.</returns> public static Type GetObjectType(string objectType, string version) { var ns = OptionsIn.DataVersion.Version131.Equals(version) ? "Energistics.DataAccess.WITSML131." : OptionsIn.DataVersion.Version200.Equals(version) ? "Energistics.DataAccess.WITSML200." : OptionsIn.DataVersion.Version210.Equals(version) ? "Energistics.DataAccess.RESQML210." : "Energistics.DataAccess.WITSML141."; if (WbGeometry.EqualsIgnoreCase(objectType) && !OptionsIn.DataVersion.Version200.Equals(version)) { objectType = $"StandAlone{WellboreGeometry.ToPascalCase()}"; } return(typeof(IDataObject).Assembly.GetType(ns + objectType.ToPascalCase())); }