public NamespacePropertyProvider(IEnumerable <KeyValuePair <string, IPropertyProvider> > elements) { _items = elements.GroupBy(l => l.Key, l => l.Value).ToDictionary( grouping => grouping.Key, grouping => PropertyProvider.Compose(grouping) ); }
public void ClearProperty(string property) { PropertyProvider.CheckProperty(property); PropertyInfo pd = _GetProperty(property); if (pd != null) { _ResetProperty(pd); } }
public static string Format(string format, IEnumerable <KeyValuePair <string, object> > propertyProviders) { if (string.IsNullOrEmpty(format)) { return(string.Empty); } return(Format(format, PropertyProvider.Compose(propertyProviders))); }
public bool TrySetProperty(string property, object value) { PropertyProvider.CheckProperty(property); PropertyInfo pd = _GetProperty(property); if (pd != null && pd.GetValue(ObjectContext) != value) { pd.SetValue(ObjectContext, value); return(true); } return(false); }
public Type GetPropertyType(string property) { PropertyProvider.CheckProperty(property); object result; if (TryGetProperty(property, typeof(object), out result)) { return((result == null) ? _items.GetType().GetElementType() : result.GetType()); } return(null); }
public bool TryGetProperty(string property, Type propertyType, out object value) { PropertyProvider.CheckProperty(property); value = null; foreach (var pp in _items) { if (pp.TryGetProperty(property, propertyType, out value)) { return(true); } } return(false); }
public void SetProperty(string property, object value) { PropertyProvider.CheckProperty(property); PropertyInfo pd = _GetProperty(property); if (pd == null) { throw RuntimeFailure.PropertyNotFound(nameof(property), property); } if (pd.GetValue(ObjectContext) != value) { pd.SetValue(ObjectContext, value); } }
public IPropertyProvider AddNew(string name, object value = null, TypeReference type = null) { if (value == null && type == null) { throw RuntimeFailure.DataProviderTypeOrValueNotBoth(); } if (value != null) { return(AddOne(name, PropertyProvider.FromValue(value))); } return(AddOne(name, PropertyProvider.LateBound(type))); }
public bool TryGetProperty(string property, Type propertyType, out object value) { PropertyProvider.CheckProperty(property); value = null; int index; if (!int.TryParse(property, out index) || index < 0 || index >= _items.Length) { return(false); } value = _items[index]; return(value == null || propertyType.GetTypeInfo().IsInstanceOfType(value)); }
protected override int MatchCriteriaCore(object criteria) { if (criteria == null) { return(0); } int result = 0; var pp = PropertyProvider.FromValue(criteria); result += EnumerateExtensions().Contains(pp.GetString("Extension")) ? 1 : 0; result += EnumerateContentTypes().Contains(pp.GetString("ContentType")) ? 1 : 0; result += MatchType(pp.GetProperty("OutputType")); return(result); }
public Type GetPropertyType(string property) { PropertyProvider.CheckProperty(property); PropertyInfo descriptor = _GetProperty(property); if (descriptor == null) { return(null); } else { return(descriptor.PropertyType); } }
public bool TryGetProperty(string property, Type propertyType, out object value) { PropertyProvider.CheckProperty(property); value = null; if (!property.Contains(':')) { return(false); } string[] items = property.Split(new [] { ':' }, 2); string prefix = items[0]; string myProp = items[1]; var pp = _items.GetValueOrDefault(prefix) ?? PropertyProvider.Null; return(pp.TryGetProperty(myProp, propertyType, out value)); }
public bool TryGetProperty(string property, Type propertyType, out object value) { PropertyProvider.CheckProperty(property); value = null; try { value = _indexer.GetValue(_objectContext, new object[] { property }); } catch (TargetInvocationException ex) { if (ex.InnerException is KeyNotFoundException || ex.InnerException is ArgumentException) { return(false); } throw; } return(true); }
public bool TryGetProperty(string property, Type requiredType, out object value) { PropertyProvider.CheckProperty(property); PropertyInfo pd = _GetProperty(property); requiredType = requiredType ?? typeof(object); value = null; if (pd != null && TryGetValue(pd, out object tempValue)) { if (tempValue == null) { return(true); } return(TryCoerceValue(pd, tempValue, requiredType, out value) && requiredType.IsInstanceOfType(value)); } return(false); }
internal static int MemberwiseEquals(object criteria, object other) { var pp = (other == null ? PropertyProvider.Null : PropertyProvider.FromValue(other)); int score = 0; foreach (var m in Properties.FromValue(criteria)) { var comparand = pp.GetProperty(m.Key); if (comparand is Type && m.Value is Type) { if (((Type)m.Value).GetTypeInfo().IsAssignableFrom((Type)comparand)) { score++; } } if (object.Equals(comparand, m.Value)) { score++; } } return(score); }
public Type GetPropertyType(string property) { PropertyProvider.CheckProperty(property); return(_indexer.PropertyType); }
public Type GetPropertyType(string property) { return(PropertyProvider.InferPropertyType(this, property)); }
public string Format(IEnumerable <KeyValuePair <string, object> > propertyProvider) { return(Format(PropertyProvider.Compose(propertyProvider))); }
public LateBoundPropertyProvider(TypeReference type) { _item = new Lazy <IPropertyProvider>( () => PropertyProvider.FromValue(Activation.CreateInstance(type.Resolve())) ); }
public static IPropertyProvider Compose( IEnumerable <KeyValuePair <string, object> > propertyProviders) { if (propertyProviders == null) { throw new ArgumentNullException(nameof(propertyProviders)); } return(Compose(propertyProviders.Select( s => new KeyValuePair <string, IPropertyProvider>(s.Key, PropertyProvider.FromValue(s.Value))))); }
void IProperties.ClearProperty(string property) { PropertyProvider.CheckProperty(property); }
void IProperties.SetProperty(string property, object value) { PropertyProvider.CheckProperty(property); }
public bool TrySetProperty(string property, object value) { PropertyProvider.CheckProperty(property); return(false); }
Type IPropertyProvider.GetPropertyType(string property) { PropertyProvider.CheckProperty(property); return(null); }