- presentationmodeldemo.zip
- App.Configuration.Wpf
- App.Configuration
- App.Core
- App.Data
- libs
- AttachedCommandBehavior.dll
- Castle.Core.dll
- Castle.DynamicProxy2.dll
- Castle.MicroKernel.dll
- Castle.Windsor.dll
- PresentationModelBase
- PresentationModelDemo.sln
- WPFUI
|
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace App.Core
{
class EntityViewTypeDescriptorProvider : TypeDescriptionProvider
{
public EntityViewTypeDescriptorProvider(TypeDescriptionProvider parent, Type entityType)
: base(parent)
{
_entityType = entityType;
}
Type _entityType;
private static Dictionary<Type, EntityViewTypeDescriptor> _handledTypes = new Dictionary<Type, EntityViewTypeDescriptor>();
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
{
if (_handledTypes.ContainsKey(objectType))
return _handledTypes[objectType];
object[] attributes = objectType.GetCustomAttributes(typeof(EncapsulatesPropertyAttribute), true);
List<string> propertiesThatShouldBeEncapsulated = new List<string>();
foreach (EncapsulatesPropertyAttribute item in attributes)
{
propertiesThatShouldBeEncapsulated.Add(item.PropertyName);
}
EntityViewTypeDescriptor descriptor = new EntityViewTypeDescriptor(base.GetTypeDescriptor(objectType, instance), propertiesThatShouldBeEncapsulated, _entityType, objectType);
_handledTypes.Add(objectType, descriptor);
return descriptor;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.