Ejemplo n.º 1
0
        public void ClearProperty(string property)
        {
            PropertyProvider.CheckProperty(property);
            PropertyInfo pd = _GetProperty(property);

            if (pd != null)
            {
                _ResetProperty(pd);
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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));
        }
        public Type GetPropertyType(string property)
        {
            PropertyProvider.CheckProperty(property);

            PropertyInfo descriptor = _GetProperty(property);

            if (descriptor == null)
            {
                return(null);
            }

            else
            {
                return(descriptor.PropertyType);
            }
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 11
0
 public bool TrySetProperty(string property, object value)
 {
     PropertyProvider.CheckProperty(property);
     return(false);
 }
Ejemplo n.º 12
0
 Type IPropertyProvider.GetPropertyType(string property)
 {
     PropertyProvider.CheckProperty(property);
     return(null);
 }
Ejemplo n.º 13
0
 void IProperties.SetProperty(string property, object value)
 {
     PropertyProvider.CheckProperty(property);
 }
Ejemplo n.º 14
0
 void IProperties.ClearProperty(string property)
 {
     PropertyProvider.CheckProperty(property);
 }
Ejemplo n.º 15
0
 public Type GetPropertyType(string property)
 {
     PropertyProvider.CheckProperty(property);
     return(_indexer.PropertyType);
 }