Browse Source

Added more extension methods for ObjectExtensionManager

pull/3834/head
Halil İbrahim Kalkan 7 years ago
parent
commit
8f906ad49f
  1. 33
      framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManagerExtensions.cs

33
framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManagerExtensions.cs

@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using JetBrains.Annotations;
using Volo.Abp.Data;
@ -80,6 +82,16 @@ namespace Volo.Abp.ObjectExtending
});
}
public static ObjectExtensionPropertyInfo GetPropertyOrNull<TObject>(
[NotNull] this ObjectExtensionManager objectExtensionManager,
[NotNull] string propertyName)
{
return objectExtensionManager.GetPropertyOrNull(
typeof(TObject),
propertyName
);
}
public static ObjectExtensionPropertyInfo GetPropertyOrNull(
[NotNull] this ObjectExtensionManager objectExtensionManager,
[NotNull] Type objectType,
@ -93,5 +105,26 @@ namespace Volo.Abp.ObjectExtending
.GetOrNull(objectType)?
.GetPropertyOrNull(propertyName);
}
private static readonly ImmutableList<ObjectExtensionPropertyInfo> EmptyPropertyList
= new List<ObjectExtensionPropertyInfo>().ToImmutableList();
public static ImmutableList<ObjectExtensionPropertyInfo> GetProperties(
[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));
var extensionInfo = objectExtensionManager.GetOrNull(objectType);
if (extensionInfo == null)
{
return EmptyPropertyList;
}
return extensionInfo.GetProperties();
}
}
}
Loading…
Cancel
Save