public static string GetString(this IBusinessObjectPropertyPath propertyPath, IBusinessObject obj, string format)
        {
            ArgumentUtility.CheckNotNull("format", format);
            var result = propertyPath.GetResult(
                obj,
                UnreachableValueBehavior.ReturnNullForUnreachableValue,
                ListValueBehavior.GetResultForFirstListEntry);

            return(result.GetString(format));
        }
        public static object GetValue(
            this IBusinessObjectPropertyPath propertyPath, IBusinessObject obj, bool throwExceptionIfNotReachable, bool getFirstListEntry)
        {
            ArgumentUtility.CheckNotNull("propertyPath", propertyPath);
            var result = propertyPath.GetResult(
                obj,
                throwExceptionIfNotReachable ? UnreachableValueBehavior.FailForUnreachableValue : UnreachableValueBehavior.ReturnNullForUnreachableValue,
                getFirstListEntry ? ListValueBehavior.GetResultForFirstListEntry : ListValueBehavior.FailForListProperties);

            return(result.GetValue());
        }
        public void GetResult_ValidPropertyPath_EndsWithInt()
        {
            var root = TypeOne.Create();
            IBusinessObjectPropertyPath path = DynamicBusinessObjectPropertyPath.Create("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue");

            var result = path.GetResult(
                (IBusinessObject)root,
                BusinessObjectPropertyPath.UnreachableValueBehavior.FailForUnreachableValue,
                BusinessObjectPropertyPath.ListValueBehavior.FailForListProperties);


            Assert.That(result, Is.InstanceOf <EvaluatedBusinessObjectPropertyPathResult>());
            Assert.That(result.ResultObject, Is.SameAs(root.TypeTwoValue.TypeThreeValue.TypeFourValue));
            Assert.That(
                result.ResultProperty,
                Is.SameAs(((IBusinessObject)root.TypeTwoValue.TypeThreeValue.TypeFourValue).BusinessObjectClass.GetPropertyDefinition("IntValue")));
        }
Exemple #4
0
        private CacheValue GetPropertyPathResult(BocListRow row)
        {
            IBusinessObjectPropertyPathResult result;

            try
            {
                result = _propertyPath.GetResult(
                    row.BusinessObject,
                    BusinessObjectPropertyPath.UnreachableValueBehavior.ReturnNullForUnreachableValue,
                    BusinessObjectPropertyPath.ListValueBehavior.GetResultForFirstListEntry);
            }
            catch (Exception e)
            {
                s_log.ErrorFormat(
                    e, "Exception thrown while evaluating the result for property path '{0}' in row {1} of BocList.", _propertyPath.Identifier, row.Index);
                return(Tuple.Create((object)null, new DoubleCheckedLockingContainer <string> (() => null)));
            }

            return(Tuple.Create(
                       GetResultValue(result, row),
                       new DoubleCheckedLockingContainer <string> (() => GetResultString(result, row))));
        }
            public string ToString(string format, IFormatProvider formatProvider)
            {
                var result = _path.GetResult(_object, UnreachableValueBehavior.ReturnNullForUnreachableValue, ListValueBehavior.GetResultForFirstListEntry);

                return(result.GetString(format));
            }