public IBusinessObjectPropertyPathResult GetResult(
     IBusinessObject root,
     BusinessObjectPropertyPath.UnreachableValueBehavior unreachableValueBehavior,
     BusinessObjectPropertyPath.ListValueBehavior listValueBehavior)
 {
     return(new NullBusinessObjectPropertyPathResult());
 }
 private void HandlePropertyValueNull(BusinessObjectPropertyPath.UnreachableValueBehavior unreachableValueBehavior, int propertyIndex)
 {
     if (unreachableValueBehavior == BusinessObjectPropertyPath.UnreachableValueBehavior.FailForUnreachableValue)
     {
         throw new InvalidOperationException(
                   string.Format(
                       "A null value was returned for property #{0} of property path '{1}'. Cannot evaluate rest of path.", propertyIndex, Identifier));
     }
 }
        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.");
        }