本文整理汇总了C#中Castle.Components.DictionaryAdapter.PropertyDescriptor类的典型用法代码示例。如果您正苦于以下问题:C# PropertyDescriptor类的具体用法?C# PropertyDescriptor怎么用?C# PropertyDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyDescriptor类属于Castle.Components.DictionaryAdapter命名空间,在下文中一共展示了PropertyDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DictionaryAdapterInstance
public DictionaryAdapterInstance(IDictionary dictionary, PropertyDescriptor descriptor,
IDictionaryAdapterFactory factory)
{
Dictionary = dictionary;
Descriptor = descriptor;
Factory = factory;
}
示例2: MergeBehaviorOverrides
private void MergeBehaviorOverrides(DictionaryAdapterMeta meta)
{
if (Descriptor == null) return;
var typeDescriptor = Descriptor as DictionaryDescriptor;
if (typeDescriptor != null)
{
Initializers = Initializers.Prioritize(typeDescriptor.Initializers).ToArray();
}
Properties = new Dictionary<string, PropertyDescriptor>();
foreach (var property in meta.Properties)
{
var propertyDescriptor = property.Value;
var propertyOverride = new PropertyDescriptor(propertyDescriptor, false)
.AddKeyBuilders(propertyDescriptor.KeyBuilders.Prioritize(Descriptor.KeyBuilders))
.AddGetters(propertyDescriptor.Getters.Prioritize(Descriptor.Getters))
.AddSetters(propertyDescriptor.Setters.Prioritize(Descriptor.Setters));
Properties.Add(property.Key, propertyOverride);
}
}
示例3: GetPropertyAsString
bool IDictionaryPropertySetter.SetPropertyValue(IDictionaryAdapter dictionaryAdapter,
string key, ref object value, PropertyDescriptor property)
{
if (value != null)
{
value = GetPropertyAsString(property, value);
}
return true;
}
示例4: GetPropertyValue
public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key, object storedValue, PropertyDescriptor property, bool ifExists)
{
if (storedValue != null)
{
return storedValue;
}
throw new InvalidOperationException(string.Format("App setting '{0}' not found!", key));
}
示例5: GetPropertyValue
public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter,
string key, object storedValue, PropertyDescriptor property, bool ifExists)
{
if (storedValue == null || storedValue.Equals(UnassignedGuid))
{
storedValue = Guid.NewGuid();
property.SetPropertyValue(dictionaryAdapter, key, ref storedValue, dictionaryAdapter.This.Descriptor);
}
return storedValue;
}
示例6: DictionaryAdapterInstance
public DictionaryAdapterInstance(IDictionary dictionary, DictionaryAdapterMeta meta,
PropertyDescriptor descriptor, IDictionaryAdapterFactory factory)
{
Dictionary = dictionary;
Descriptor = descriptor;
Factory = factory;
Properties = meta.Properties;
Initializers = meta.Initializers;
MergeBehaviorOverrides(meta);
}
示例7: GetPropertyValue
public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key, object storedValue, PropertyDescriptor property, bool ifExists)
{
if (property.PropertyType.IsAssignableFrom(storedValue.GetType()))
{
return storedValue;
}
if (property.PropertyType.IsInterface && IsDictionary(storedValue.GetType()))
{
return dictionaryAdapter.This.Factory.GetAdapter(property.PropertyType, storedValue as IDictionary);
}
return storedValue;
}
示例8: GetPropertyValue
public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key, object storedValue,
PropertyDescriptor property, bool ifExists)
{
var defaultValue = property.Annotations
.OfType<DefaultValueAttribute>()
.SingleOrDefault();
if (storedValue == null && IsRequired(ifExists) && defaultValue == null)
throw new KeyNotFoundException("key '" + key + "' not found");
if (storedValue == null && defaultValue != null)
return defaultValue.Value;
return storedValue;
}
示例9: PropertyDescriptor
object IDictionaryPropertyGetter.GetPropertyValue(
IDictionaryAdapterFactory factory, IDictionary dictionary,
string key, object storedValue, PropertyDescriptor property)
{
if (storedValue == null)
{
PropertyDescriptor descriptor =
new PropertyDescriptor(property.Property);
descriptor.AddKeyBuilder(new DictionaryKeyPrefixAttribute(key));
return factory.GetAdapter(
property.Property.PropertyType, dictionary, descriptor);
}
return storedValue;
}
示例10: DictionaryAdapterInstance
public DictionaryAdapterInstance(IDictionary dictionary, DictionaryAdapterMeta meta,
PropertyDescriptor descriptor, IDictionaryAdapterFactory factory)
{
Dictionary = dictionary;
Descriptor = descriptor;
Factory = factory;
List<IDictionaryBehavior> behaviors;
if (null == descriptor || null == (behaviors = descriptor.BehaviorsInternal))
{
Initializers = meta.Initializers;
Properties = MergeProperties(meta.Properties);
}
else
{
Initializers = MergeInitializers(meta.Initializers, behaviors);
Properties = MergeProperties(meta.Properties, behaviors);
}
}
示例11: PropertyDescriptor
object IDictionaryPropertyGetter.GetPropertyValue(IDictionaryAdapter dictionaryAdapter,
string key, object storedValue, PropertyDescriptor property, bool ifExists)
{
if (storedValue == null)
{
var component = dictionaryAdapter.This.ExtendedProperties[property.PropertyName];
if (component == null)
{
var descriptor = new PropertyDescriptor(property.Property, null);
descriptor.AddKeyBuilder(new KeyPrefixAttribute(key));
component = dictionaryAdapter.This.Factory.GetAdapter(
property.Property.PropertyType, dictionaryAdapter.This.Dictionary, descriptor);
dictionaryAdapter.This.ExtendedProperties[property.PropertyName] = component;
}
return component;
}
return storedValue;
}
示例12: IsCollection
private static bool IsCollection(PropertyDescriptor property, out Type collectionItemType)
{
collectionItemType = null;
var propertyType = property.PropertyType;
if (propertyType != typeof(string) && typeof(IEnumerable).IsAssignableFrom(propertyType))
{
if (propertyType.IsArray)
{
collectionItemType = propertyType.GetElementType();
}
else if (propertyType.IsGenericType)
{
var arguments = propertyType.GetGenericArguments();
collectionItemType = arguments[0];
}
else
{
collectionItemType = typeof(object);
}
return true;
}
return false;
}
示例13: SetPropertyValue
public bool SetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key, ref object value, PropertyDescriptor property)
{
value = (value != null) ? value.ToString() : null;
return true;
}
示例14:
String IDictionaryKeyBuilder.GetKey(IDictionaryAdapter dictionaryAdapter, String key, PropertyDescriptor property)
{
return String.Format("{0}#{1}", property.Property.DeclaringType.FullName, key);
}
示例15: IsVolatileProperty
private static bool IsVolatileProperty(IDictionaryAdapter dictionaryAdapter, PropertyDescriptor property)
{
return dictionaryAdapter.Meta.Behaviors.Union(property.Behaviors).Any(behavior => behavior is VolatileAttribute);
}