Visual Studio Feeds English |
- Convert Dynamic to Type and convert Type to Dynamic
- W8WIL #2: Declaratively Specifying an ItemTemplate in a Fragment
- WebCast MSDN: Visual Studio Architecture Tools
- SyncFusion’s Metro Studio 1 with 600 Metro style Icons
- Pivot, PivotTable and PowerPivot
- Azure Fluent Management v 0.4 Released
- Download Windows 8 Release Preview
- Windows 8 Release Preview license or Serial key
- Installing Eclipse on Windows 8 and connecting to TFS 2012
| Convert Dynamic to Type and convert Type to Dynamic Posted: 02 Jun 2012 09:11 AM PDT public static class DynamicExtensions { public static T FromDynamic(this IDictionary dictionary) { var bindings = new List(); foreach (var sourceProperty in typeof(T).GetProperties().Where(x => x.CanWrite)) { var key = dictionary.Keys.SingleOrDefault(x => x.Equals(sourceProperty.Name, StringComparison.OrdinalIgnoreCase)); if (string.IsNullOrEmpty(key)) continue; var propertyValue = dictionary[key]; bindings.Add(Expression.Bind(sourceProperty, Expression.Constant(propertyValue))); } Expression memberInit = Expression.MemberInit(Expression.New(typeof(T)), bindings); return Expression.Lambda(memberInit).Compile().Invoke(); } public static dynamic ToDynamic(this T obj) { IDictionary expando = new ExpandoObject(); foreach (var propertyInfo in typeof(T).GetProperties()) { var propertyExpression = Expression.Property(Expression.Constant(obj), propertyInfo); var currentValue = Expression.Lambda(propertyExpression).Compile().Invoke(); expando.Add(propertyInfo.Name.ToLower(), currentValue); } return expando as ExpandoObject; } } ...(Read whole news on source site) (http://geekswithblogs.net/Nettuce/archive/2012/06/02/convert-dynamic-to-type-and-convert-type-to-dynamic.aspx) |
| W8WIL #2: Declaratively Specifying an ItemTemplate in a Fragment Posted: 02 Jun 2012 07:10 AM PDT |
| WebCast MSDN: Visual Studio Architecture Tools Posted: 02 Jun 2012 06:55 AM PDT |
| SyncFusion’s Metro Studio 1 with 600 Metro style Icons Posted: 02 Jun 2012 05:55 AM PDT |
| Pivot, PivotTable and PowerPivot Posted: 02 Jun 2012 12:37 AM PDT |
| Azure Fluent Management v 0.4 Released Posted: 02 Jun 2012 12:22 AM PDT |
| Download Windows 8 Release Preview Posted: 01 Jun 2012 08:51 PM PDT |
| Windows 8 Release Preview license or Serial key Posted: 01 Jun 2012 08:51 PM PDT |
| Installing Eclipse on Windows 8 and connecting to TFS 2012 Posted: 01 Jun 2012 03:34 PM PDT |
| You are subscribed to email updates from VSF RSS English To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
| Google Inc., 20 West Kinzie, Chicago IL USA 60610 | |
Комментариев нет:
Отправить комментарий