wasSharpNET

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 11  →  ?path2? @ 27
/Reflection.cs
@@ -31,12 +31,8 @@
{
if (fi.FieldType.FullName.Split('.', '+')
.Contains(@namespace, StringComparer.OrdinalIgnoreCase))
{
foreach (var sf in wasGetFields(fi.GetValue(@object), @namespace))
{
yield return sf;
}
}
yield return new KeyValuePair<FieldInfo, object>(fi, @object);
}
}
@@ -64,19 +60,15 @@
var getMethod = pi.GetGetMethod();
if (getMethod.ReturnType.IsArray)
{
var array = (Array)getMethod.Invoke(@object, null);
var array = (Array) getMethod.Invoke(@object, null);
foreach (var sp in
array.Cast<object>().SelectMany(element => wasGetProperties(element, @namespace)))
{
yield return sp;
}
}
foreach (
var sp in
wasGetProperties(pi.GetValue(@object, null), @namespace))
{
wasGetProperties(pi.GetValue(@object, null), @namespace))
yield return sp;
}
}
yield return new KeyValuePair<PropertyInfo, object>(pi, @object);
}
@@ -94,18 +86,18 @@
public static void wasSetInfoValue<TK, TV>(TK info, ref TV @object, object value)
{
object o = @object;
var fi = (object)info as FieldInfo;
var fi = (object) info as FieldInfo;
if (fi != null)
{
fi.SetValue(o, value);
@object = (TV)o;
@object = (TV) o;
return;
}
var pi = (object)info as PropertyInfo;
var pi = (object) info as PropertyInfo;
if (pi != null)
{
pi.SetValue(o, value, null);
@object = (TV)o;
@object = (TV) o;
}
}
 
@@ -120,21 +112,17 @@
/// <returns>the value of the field or property</returns>
public static object wasGetInfoValue<T>(T info, object value)
{
var fi = (object)info as FieldInfo;
var fi = (object) info as FieldInfo;
if (fi != null)
{
return fi.GetValue(value);
}
var pi = (object)info as PropertyInfo;
var pi = (object) info as PropertyInfo;
if (pi != null)
{
if (pi.GetIndexParameters().Any())
{
return value;
}
return pi.GetValue(value, null);
}
return null;
}
}
}
}