コード例 #1
0
ファイル: WitsmlParser.cs プロジェクト: nilsbenson/witsml
        /// <summary>
        /// Transforms the supplied data object to the specified version.
        /// </summary>
        /// <param name="collection">The data object collection.</param>
        /// <param name="dataVersion">The data schema version.</param>
        /// <returns>The transformed data object, if successful; otherwise, the original data object.</returns>
        public static IEnergisticsCollection Transform(IEnergisticsCollection collection, string dataVersion)
        {
            var objectType = ObjectTypes.GetObjectType(collection);
            var listType   = ObjectTypes.GetObjectGroupType(objectType, dataVersion);
            var converter  = _upgradeMethod.MakeGenericMethod(collection.GetType(), listType);

            try
            {
                collection = (IEnergisticsCollection)converter.Invoke(null, new object[] { collection });
                collection.SetVersion(dataVersion);
            }
            catch (Exception ex)
            {
                _log.Warn($"Unable to convert to data schema version: {dataVersion}", ex);
            }

            return(collection);
        }
コード例 #2
0
ファイル: ObjectTypes.cs プロジェクト: nilsbenson/witsml
 /// <summary>
 /// Gets the type of the object.
 /// </summary>
 /// <param name="pluralObject">The plural object.</param>
 /// <returns>The WITSML data object type, as a string.</returns>
 public static string GetObjectType(IEnergisticsCollection pluralObject)
 {
     return(GetObjectType(pluralObject.GetType()));
 }