Esempio n. 1
0
        /// <summary>
        /// Gets the .NET type of the collection for the specified data 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 collection.</returns>
        public static Type GetObjectGroupType(string objectType, string version)
        {
            if (WbGeometry.EqualsIgnoreCase(objectType))
            {
                objectType = WellboreGeometry;
            }

            return(GetObjectType(objectType + "List", version));
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the .NET type of the collection for the specified data 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 collection.</returns>
        public static Type GetObjectGroupType(string objectType, string family, string version)
        {
            if (WbGeometry.EqualsIgnoreCase(objectType))
            {
                objectType = WellboreGeometry;
            }

            var suffix = OptionsIn.DataVersion.Version200.Equals(version)
                ? string.Empty
                : "List";

            return(GetObjectType(objectType + suffix, family, version));
        }
Esempio n. 3
0
        /// <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."
                : "Energistics.DataAccess.WITSML141.";

            if (WbGeometry.EqualsIgnoreCase(objectType) && !OptionsIn.DataVersion.Version200.Equals(version))
            {
                objectType = $"StandAlone{WellboreGeometry.ToPascalCase()}";
            }

            return(typeof(IDataObject).Assembly.GetType(ns + objectType.ToPascalCase()));
        }
Esempio n. 4
0
        /// <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()));
        }