Example #1
0
        public static ObjectExtensionPropertyInfo GetPropertyOrNull(
            [NotNull] this ObjectExtensionManager objectExtensionManager,
            [NotNull] Type objectType,
            [NotNull] string propertyName)
        {
            Check.NotNull(objectExtensionManager, nameof(objectExtensionManager));
            Check.NotNull(objectType, nameof(objectType));
            Check.NotNull(propertyName, nameof(propertyName));

            return(objectExtensionManager
                   .GetOrNull(objectType)?
                   .GetPropertyOrNull(propertyName));
        }
 public static ObjectExtensionManager MapEfCoreProperty <TEntity, TProperty>(
     [NotNull] this ObjectExtensionManager objectExtensionManager,
     [NotNull] string propertyName,
     [CanBeNull] Action <PropertyBuilder> propertyBuildAction = null)
     where TEntity : IHasExtraProperties, IEntity
 {
     return(objectExtensionManager.MapEfCoreProperty(
                typeof(TEntity),
                typeof(TProperty),
                propertyName,
                propertyBuildAction
                ));
 }
Example #3
0
 public static ObjectExtensionManager AddOrUpdateProperty <TObject, TProperty>(
     [NotNull] this ObjectExtensionManager objectExtensionManager,
     [NotNull] string propertyName,
     [CanBeNull] Action <ObjectExtensionPropertyInfo> configureAction = null)
     where TObject : IHasExtraProperties
 {
     return(objectExtensionManager.AddOrUpdateProperty(
                typeof(TObject),
                typeof(TProperty),
                propertyName,
                configureAction
                ));
 }
Example #4
0
        public static ImmutableList <ObjectExtensionPropertyInfo> GetProperties(
            [NotNull] this ObjectExtensionManager objectExtensionManager,
            [NotNull] Type objectType)
        {
            Check.NotNull(objectExtensionManager, nameof(objectExtensionManager));
            Check.NotNull(objectType, nameof(objectType));

            var extensionInfo = objectExtensionManager.GetOrNull(objectType);

            if (extensionInfo == null)
            {
                return(EmptyPropertyList);
            }

            return(extensionInfo.GetProperties());
        }
Example #5
0
        public static ObjectExtensionManager AddOrUpdateProperty(
            [NotNull] this ObjectExtensionManager objectExtensionManager,
            [NotNull] Type objectType,
            [NotNull] Type propertyType,
            [NotNull] string propertyName,
            [CanBeNull] Action <ObjectExtensionPropertyInfo> configureAction = null)
        {
            Check.NotNull(objectExtensionManager, nameof(objectExtensionManager));

            return(objectExtensionManager.AddOrUpdate(
                       objectType,
                       options =>
            {
                options.AddOrUpdateProperty(
                    propertyType,
                    propertyName,
                    configureAction
                    );
            }));
        }
        public static ObjectExtensionManager MapEfCoreProperty(
            [NotNull] this ObjectExtensionManager objectExtensionManager,
            [NotNull] Type entityType,
            [NotNull] Type propertyType,
            [NotNull] string propertyName,
            [CanBeNull] Action <PropertyBuilder> propertyBuildAction = null)
        {
            Check.NotNull(objectExtensionManager, nameof(objectExtensionManager));

            return(objectExtensionManager.AddOrUpdateProperty(
                       entityType,
                       propertyType,
                       propertyName,
                       options =>
            {
                options.MapEfCore(
                    propertyBuildAction
                    );
            }
                       ));
        }
Example #7
0
        public static ObjectExtensionManager AddOrUpdateProperty(
            [NotNull] this ObjectExtensionManager objectExtensionManager,
            [NotNull] Type[] objectTypes,
            [NotNull] Type propertyType,
            [NotNull] string propertyName,
            [CanBeNull] Action <ObjectExtensionPropertyInfo> configureAction = null)
        {
            Check.NotNull(objectTypes, nameof(objectTypes));

            foreach (var objectType in objectTypes)
            {
                objectExtensionManager.AddOrUpdateProperty(
                    objectType,
                    propertyType,
                    propertyName,
                    configureAction
                    );
            }

            return(objectExtensionManager);
        }
Example #8
0
 public static ImmutableList <ObjectExtensionPropertyInfo> GetProperties <TObject>(
     [NotNull] this ObjectExtensionManager objectExtensionManager)
 {
     return(objectExtensionManager.GetProperties(typeof(TObject)));
 }