/// <summary>
        /// Gets the property value from the specified target.
        /// </summary>
        /// <param name="key">Target object.</param>
        /// <returns>Property value.</returns>
        public object Get(object key)
        {
            if (mCanRead)
            {
                if (mEmittedPropertyAccessor == null)
                {
                    Init();
                }

                try
                {
                    return(mEmittedPropertyAccessor.Get(key));
                }
                catch (Exception e)
                {
                    throw new PropertyAccessorException("Could not evaluate property - Is your class public and is it correctly accessed?", e);
                }
            }
            else
            {
                throw new PropertyAccessorException(
                          string.Format("Property \"{0}\" does not have a get method.",
                                        mProperty));
            }
        }
Exemple #2
0
 public object GetProperty(object target, string propertyName)
 {
     try
     {
         IGetterSetter hGet = (IGetterSetter)_properties[propertyName];
         if (hGet == null)
         {
             throw new DynaAccessException("No Get method for property " + propertyName + " on instance of " + _proxyType.Name);
         }
         return(hGet.Get(target));
     }
     catch (DynaAccessException dae)
     {
         throw dae;
     }
     catch (Exception e)
     {
         throw new DynaAccessException(e);
     }
 }