Reflection abstractions to reduce code duplication

This commit is contained in:
Haacked
2014-12-30 00:55:59 -08:00
parent 011a14b7f2
commit 47e67e9382
10 changed files with 119 additions and 50 deletions
+8 -1
View File
@@ -1,13 +1,20 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Octokit.Reflection;
namespace Octokit
{
internal static class ReflectionExtensions
{
public static IEnumerable<PropertyOrField> GetPropertiesAndFields(this Type type)
{
return ReflectionUtils.GetProperties(type).Select(property => new PropertyOrField(property))
.Union(ReflectionUtils.GetFields(type).Select(field => new PropertyOrField(field)))
.Where(p => p.IsPublic && !p.IsStatic);
}
public static bool IsDateTimeOffset(this Type type)
{
return type == typeof(DateTimeOffset) || type == typeof(DateTimeOffset?);