diff --git a/Extensions/ModelExtensions.cs b/Extensions/ModelExtensions.cs
index aa3a981..4c816ff 100644
--- a/Extensions/ModelExtensions.cs
+++ b/Extensions/ModelExtensions.cs
@@ -116,17 +116,19 @@ namespace xCommons.Extensions
///
///
///
+ ///
///
public static bool HasProperty(
this T source,
- string property
+ string property,
+ BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
)
where T : class
{
//
var result = source
.GetType()
- .GetProperties()
+ .GetProperties(bindingAttr)
.Any(prop => prop.Name == property); ;
//
@@ -134,23 +136,25 @@ namespace xCommons.Extensions
}
///
- /// Check a Class is Contains a Filed or not ...
+ /// Check a Class is Contains a field or not ...
///
///
///
- ///
+ ///
+ ///
///
public static bool HasField(
this T source,
- string filed
+ string field,
+ BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
)
where T : class
{
//
var result = source
.GetType()
- .GetFields()
- .Any(fld => fld.Name == filed);
+ .GetFields(bindingAttr)
+ .Any(fld => fld.Name == field);
//
return result;
@@ -162,17 +166,19 @@ namespace xCommons.Extensions
///
///
///
+ ///
///
public static bool HasMethod(
this T source,
- string method
+ string method,
+ BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
)
where T : class
{
//
var result = source
.GetType()
- .GetMethods()
+ .GetMethods(bindingAttr)
.Any(mthd => mthd.Name == method);
//
@@ -209,7 +215,7 @@ namespace xCommons.Extensions
///
///
///
- public static string[] GetFiledsNames(
+ public static string[] GetFieldsNames(
this T source,
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
)
@@ -278,15 +284,17 @@ namespace xCommons.Extensions
///
///
///
+ ///
///
public static TProp GetProperty(
this T source,
- string property
+ string property,
+ BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
)
where T : class
{
//
- TProp result = default(TProp);
+ TProp result = default;
//
// Check if T Has Property ...
@@ -296,7 +304,10 @@ namespace xCommons.Extensions
// Access Property ...
var prop = source
.GetType()
- .GetProperty(property);
+ .GetProperty(
+ property,
+ bindingAttr
+ );
//
// Retrieve Property Value as Object ...
@@ -316,11 +327,13 @@ namespace xCommons.Extensions
///
///
///
- ///
+ ///
+ ///
///
public static TField GetField(
this T source,
- string filed
+ string field,
+ BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
)
where T : class
{
@@ -328,12 +341,15 @@ namespace xCommons.Extensions
TField result = default;
//
- if (source.HasField(filed))
+ if (source.HasField(field))
{
//
var fld = source
.GetType()
- .GetField(filed);
+ .GetField(
+ field,
+ bindingAttr
+ );
//
var fieldVal = fld.GetValue(source);
@@ -352,11 +368,13 @@ namespace xCommons.Extensions
///
///
///
+ ///
///
public static bool SetProperty(
this T source,
string property,
- TProp value
+ TProp value,
+ BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
)
where T : class
{
@@ -372,7 +390,10 @@ namespace xCommons.Extensions
// Access Property ...
var prop = source
.GetType()
- .GetProperty(property);
+ .GetProperty(
+ property,
+ bindingAttr
+ );
//
// Set Property ...
@@ -397,19 +418,21 @@ namespace xCommons.Extensions
///
///
///
- ///
+ ///
///
+ ///
///
public static bool SetField(
this T source,
- string filed,
- TField value
+ string field,
+ TField value,
+ BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
)
where T : class
{
//
// Check T Has Field ...
- var result = source.HasField(filed);
+ var result = source.HasField(field);
if (!result)
{
return result;
@@ -419,7 +442,10 @@ namespace xCommons.Extensions
// Access Field ...
var fld = source
.GetType()
- .GetField(filed);
+ .GetField(
+ field,
+ bindingAttr
+ );
//
// Set Value ...