Update
This commit is contained in:
parent
a276adeedb
commit
a980b6c71b
@ -149,7 +149,7 @@ namespace SkinHide.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyRef(PropertyInfo propertyinfo, object instance = null)
|
public PropertyRef(PropertyInfo propertyinfo, object instance)
|
||||||
{
|
{
|
||||||
if (propertyinfo == null)
|
if (propertyinfo == null)
|
||||||
{
|
{
|
||||||
@ -159,9 +159,11 @@ namespace SkinHide.Utils
|
|||||||
Init(propertyinfo, instance);
|
Init(propertyinfo, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyRef(Type type, string propertyname, object instance = null)
|
public PropertyRef(Type type, string propertyname, bool declaredonly, object instance)
|
||||||
{
|
{
|
||||||
PropertyInfo propertyInfo = type.GetProperty(propertyname, AccessTools.all);
|
BindingFlags flags = declaredonly ? AccessTools.allDeclared : AccessTools.all;
|
||||||
|
|
||||||
|
PropertyInfo propertyInfo = type.GetProperty(propertyname, flags);
|
||||||
|
|
||||||
if (propertyInfo == null)
|
if (propertyInfo == null)
|
||||||
{
|
{
|
||||||
@ -171,9 +173,11 @@ namespace SkinHide.Utils
|
|||||||
Init(propertyInfo, instance);
|
Init(propertyInfo, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyRef(Type type, string[] propertynames, object instance = null)
|
public PropertyRef(Type type, string[] propertynames, bool declaredonly, object instance)
|
||||||
{
|
{
|
||||||
PropertyInfo propertyInfo = propertynames.Select(x => type.GetProperty(x, AccessTools.all)).FirstOrDefault(x => x != null);
|
BindingFlags flags = declaredonly ? AccessTools.allDeclared : AccessTools.all;
|
||||||
|
|
||||||
|
PropertyInfo propertyInfo = propertyInfo = propertynames.Select(x => type.GetProperty(x, flags)).FirstOrDefault(x => x != null);
|
||||||
|
|
||||||
if (propertyInfo == null)
|
if (propertyInfo == null)
|
||||||
{
|
{
|
||||||
@ -206,29 +210,29 @@ namespace SkinHide.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PropertyRef<T, F> Create(PropertyInfo propertyinfo, object instance = null)
|
public static PropertyRef<T, F> Create(PropertyInfo propertyinfo, object instance)
|
||||||
{
|
{
|
||||||
return new PropertyRef<T, F>(propertyinfo, instance);
|
return new PropertyRef<T, F>(propertyinfo, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PropertyRef<T, F> Create(string propertyname, object instance = null)
|
public static PropertyRef<T, F> Create(string propertyname, bool declaredonly = false, object instance = null)
|
||||||
{
|
{
|
||||||
return new PropertyRef<T, F>(typeof(T), propertyname, instance);
|
return new PropertyRef<T, F>(typeof(T), propertyname, declaredonly, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PropertyRef<T, F> Create(string[] propertynames, object instance = null)
|
public static PropertyRef<T, F> Create(string[] propertynames, bool declaredonly = false, object instance = null)
|
||||||
{
|
{
|
||||||
return new PropertyRef<T, F>(typeof(T), propertynames, instance);
|
return new PropertyRef<T, F>(typeof(T), propertynames, declaredonly, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PropertyRef<T, F> Create(Type type, string propertyname, object instance = null)
|
public static PropertyRef<T, F> Create(Type type, string propertyname, bool declaredonly = false, object instance = null)
|
||||||
{
|
{
|
||||||
return new PropertyRef<T, F>(type, propertyname, instance);
|
return new PropertyRef<T, F>(type, propertyname, declaredonly, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PropertyRef<T, F> Create(Type type, string[] propertynames, object instance = null)
|
public static PropertyRef<T, F> Create(Type type, string[] propertynames, bool declaredonly = false, object instance = null)
|
||||||
{
|
{
|
||||||
return new PropertyRef<T, F>(type, propertynames, instance);
|
return new PropertyRef<T, F>(type, propertynames, declaredonly, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public F GetValue(T instance)
|
public F GetValue(T instance)
|
||||||
@ -296,7 +300,7 @@ namespace SkinHide.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldRef(FieldInfo fieldinfo, object instance = null)
|
public FieldRef(FieldInfo fieldinfo, object instance)
|
||||||
{
|
{
|
||||||
if (fieldinfo == null)
|
if (fieldinfo == null)
|
||||||
{
|
{
|
||||||
@ -306,21 +310,25 @@ namespace SkinHide.Utils
|
|||||||
Init(fieldinfo, instance);
|
Init(fieldinfo, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldRef(Type type, string fieldname, object instance = null)
|
public FieldRef(Type type, string fieldname, bool declaredonly, object instance)
|
||||||
{
|
{
|
||||||
FieldInfo fieldInfo = type.GetField(fieldname, AccessTools.all);
|
BindingFlags flags = declaredonly ? AccessTools.allDeclared : AccessTools.all;
|
||||||
|
|
||||||
|
FieldInfo fieldInfo = type.GetField(fieldname, flags);
|
||||||
|
|
||||||
if (fieldInfo == null)
|
if (fieldInfo == null)
|
||||||
{
|
{
|
||||||
throw new Exception(fieldInfo + " is null");
|
throw new Exception(fieldname + " is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
Init(fieldInfo, instance);
|
Init(fieldInfo, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldRef(Type type, string[] fieldnames, object instance = null)
|
public FieldRef(Type type, string[] fieldnames, bool declaredonly, object instance)
|
||||||
{
|
{
|
||||||
FieldInfo fieldInfo = fieldnames.Select(x => type.GetField(x, AccessTools.all)).FirstOrDefault(x => x != null);
|
BindingFlags flags = declaredonly ? AccessTools.allDeclared : AccessTools.all;
|
||||||
|
|
||||||
|
FieldInfo fieldInfo = fieldnames.Select(x => type.GetField(x, flags)).FirstOrDefault(x => x != null);
|
||||||
|
|
||||||
if (fieldInfo == null)
|
if (fieldInfo == null)
|
||||||
{
|
{
|
||||||
@ -335,24 +343,24 @@ namespace SkinHide.Utils
|
|||||||
return new FieldRef<T, F>(fieldinfo, instance);
|
return new FieldRef<T, F>(fieldinfo, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FieldRef<T, F> Create(string fieldname, object instance = null)
|
public static FieldRef<T, F> Create(string fieldname, bool declaredonly = false, object instance = null)
|
||||||
{
|
{
|
||||||
return new FieldRef<T, F>(typeof(T), fieldname, instance);
|
return new FieldRef<T, F>(typeof(T), fieldname, declaredonly, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FieldRef<T, F> Create(string[] fieldnames, object instance = null)
|
public static FieldRef<T, F> Create(string[] fieldnames, bool declaredonly = false, object instance = null)
|
||||||
{
|
{
|
||||||
return new FieldRef<T, F>(typeof(T), fieldnames, instance);
|
return new FieldRef<T, F>(typeof(T), fieldnames, declaredonly, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FieldRef<T, F> Create(Type type, string fieldname, object instance = null)
|
public static FieldRef<T, F> Create(Type type, string fieldname, bool declaredonly = false, object instance = null)
|
||||||
{
|
{
|
||||||
return new FieldRef<T, F>(type, fieldname, instance);
|
return new FieldRef<T, F>(type, fieldname, declaredonly, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FieldRef<T, F> Create(Type type, string[] fieldnames, object instance = null)
|
public static FieldRef<T, F> Create(Type type, string[] fieldnames, bool declaredonly = false, object instance = null)
|
||||||
{
|
{
|
||||||
return new FieldRef<T, F>(type, fieldnames, instance);
|
return new FieldRef<T, F>(type, fieldnames, declaredonly, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Init(FieldInfo fieldinfo, object instance = null)
|
private void Init(FieldInfo fieldinfo, object instance = null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user