Exemplo n.º 1
0
 private object GetPropertyValue(object targetObject, string propertyName)
 {
     if (targetObject != null)
     {
         ADEntity aDEntity = targetObject as ADEntity;
         if (aDEntity == null)
         {
             PropertyInfo property = targetObject.GetType().GetProperty(propertyName);
             if (property != null)
             {
                 return(property.GetValue(targetObject, null));
             }
             else
             {
                 object[] str = new object[2];
                 str[0] = propertyName;
                 str[1] = targetObject.GetType().ToString();
                 throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ADFilterPropertyNotFoundInObject, str));
             }
         }
         else
         {
             return(ADEntityAdapter.GetPropertyValue(aDEntity, propertyName));
         }
     }
     else
     {
         throw new ArgumentNullException("targetObject");
     }
 }
Exemplo n.º 2
0
 public override object GetPropertyValue(PSAdaptedProperty property)
 {
     if (property != null)
     {
         if (property.BaseObject != null)
         {
             if (property.Name != null)
             {
                 ADEntity baseObject = property.BaseObject as ADEntity;
                 if (baseObject != null)
                 {
                     return(ADEntityAdapter.GetPropertyValue(baseObject, property.Name));
                 }
                 else
                 {
                     object[] typeAdapterTypeName = new object[2];
                     typeAdapterTypeName[0] = ADEntityAdapter.TypeAdapterTypeName;
                     typeAdapterTypeName[1] = ADEntityAdapter.ADEntityTypeName;
                     throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.TypeAdapterForADEntityOnly, typeAdapterTypeName));
                 }
             }
             else
             {
                 throw new ArgumentNullException("property.Name");
             }
         }
         else
         {
             throw new ArgumentNullException("property.BaseObject");
         }
     }
     else
     {
         throw new ArgumentNullException("property");
     }
 }