#region copyright
//<copyright>
// Copyright(C) 2012 TrackerRealm Corporation
// This file is part of the open source project - Jazz. http://jazz.codeplex.com
//
// Jazz is open software: you can redistribute it and/or modify it
// under the terms of the GNU Affero General Public License (AGPL) as published by
// the Free Software Foundation, version 3 of the License.
//
// Jazz is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Affero General Public License (AGPL) for more details.
//
// You should have received a copy of the GNU General Public
// License along with Jazz. If not, see <http://www.gnu.org/licenses/>.
//
// REMOVAL OF THIS NOTICE IS VIOLATION OF THE COPYRIGHT.
//</copyright>
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Reflection;
using System.Text.RegularExpressions;
namespace TrackerRealm.Jazz.Common
{
/// <summary>
///
/// </summary>
public static class ReflectionExtensionMethods
{
#region GetPrivateField
/// <summary>
///
/// </summary>
/// <param name="t"></param>
/// <param name="name"></param>
/// <returns></returns>
public static FieldInfo GetPrivateField(this Type t, string name)
{
FieldInfo field;
while (t != typeof(object))
{
field = t.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return field;
}
t = t.BaseType;
}
throw new ArgumentException(string.Format("Field '{0}' not found", name));
}
#endregion
}
}