private IBusinessObject GetPropertyValue( IBusinessObject currentObject, IBusinessObjectReferenceProperty currentProperty, BusinessObjectPropertyPath.ListValueBehavior listValueBehavior, int propertyIndex) { if (currentProperty.IsList) { if (listValueBehavior == BusinessObjectPropertyPath.ListValueBehavior.FailForListProperties) { throw new InvalidOperationException( string.Format("Property #{0} of property path '{1}' is not a single-value property.", propertyIndex, Identifier)); } var list = (IList)currentObject.GetProperty(currentProperty); if (list.Count > 0) { return((IBusinessObject)list[0]); } else { return(null); } } else { return((IBusinessObject)currentObject.GetProperty(currentProperty)); } }
public IBusinessObjectPropertyPathResult GetResult( IBusinessObject root, BusinessObjectPropertyPath.UnreachableValueBehavior unreachableValueBehavior, BusinessObjectPropertyPath.ListValueBehavior listValueBehavior) { return(new NullBusinessObjectPropertyPathResult()); }
public IBusinessObjectPropertyPathResult GetResult( IBusinessObject root, BusinessObjectPropertyPath.UnreachableValueBehavior unreachableValueBehavior, BusinessObjectPropertyPath.ListValueBehavior listValueBehavior) { ArgumentUtility.CheckNotNull("root", root); var propertyEnumerator = GetResultPropertyEnumerator(); var currentObject = root; int propertyIndex = 0; while (propertyEnumerator.MoveNext(currentObject.BusinessObjectClass)) { var currentProperty = propertyEnumerator.Current; if (currentProperty == null) { return(new NullBusinessObjectPropertyPathResult()); } if (!propertyEnumerator.HasNext) { return(new EvaluatedBusinessObjectPropertyPathResult(currentObject, currentProperty)); } if (!currentProperty.IsAccessible(currentObject)) { HandlePropertyAccessDenied(unreachableValueBehavior, propertyIndex); return(new NotAccessibleBusinessObjectPropertyPathResult(currentObject.BusinessObjectClass.BusinessObjectProvider)); } try { currentObject = GetPropertyValue(currentObject, (IBusinessObjectReferenceProperty)currentProperty, listValueBehavior, propertyIndex); } catch (BusinessObjectPropertyAccessException) { HandlePropertyAccessDenied(unreachableValueBehavior, propertyIndex); return(new NotAccessibleBusinessObjectPropertyPathResult(currentObject.BusinessObjectClass.BusinessObjectProvider)); } if (currentObject == null) { HandlePropertyValueNull(unreachableValueBehavior, propertyIndex); return(new NullBusinessObjectPropertyPathResult()); } propertyIndex++; } throw new InvalidOperationException("Property path enumeration can never fall through."); }