コード例 #1
0
        /// <summary>
        /// Creates an <see cref="IEnergisticsCollection"/> container and wraps the current entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns>A <see cref="IEnergisticsCollection"/> instance.</returns>
        public static IEnergisticsCollection CreateCollection(this IDataObject entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var type       = entity.GetType();
            var objectType = ObjectTypes.GetObjectType(type);
            var version    = ObjectTypes.GetVersion(type);

            var groupType = ObjectTypes.GetObjectGroupType(objectType, version);
            var property  = ObjectTypes.GetObjectTypeListPropertyInfo(objectType, version);
            var group     = Activator.CreateInstance(groupType) as IEnergisticsCollection;
            var list      = Activator.CreateInstance(property.PropertyType) as IList;

            if (list == null)
            {
                return(group);
            }

            list.Add(entity);
            property.SetValue(group, list);

            return(group);
        }
コード例 #2
0
        public void ObjectTypes_GetObjectTypeListPropertyInfo_Returns_PropertyInfo_For_WellList()
        {
            var property = ObjectTypes.GetObjectTypeListPropertyInfo(ObjectTypes.Well, OptionsIn.DataVersion.Version141);

            Assert.AreEqual("Well", property.Name);
            Assert.AreEqual(typeof(List <Witsml141.Well>), property.PropertyType);

            Assert.IsNull(ObjectTypes.GetObjectTypeListPropertyInfo(ObjectTypes.Well, OptionsIn.DataVersion.Version200.Value));
        }