Exemple #1
0
        /// <summary>
        /// Gets the <see cref="IBusinessObjectWithIdentity.DisplayName"/> property of <paramref name="businessObject"/>
        /// after checking that the property's value can be read.
        /// </summary>
        /// <remarks>
        /// Getting the <see cref="IBusinessObjectWithIdentity.DisplayName"/> can still fail with an exception if the exception is not part of the
        /// property access contract, i.e. the exception is not of type <see cref="BusinessObjectPropertyAccessException"/>.
        /// </remarks>
        public static string GetAccessibleDisplayName(this IBusinessObjectWithIdentity businessObject)
        {
            ArgumentUtility.CheckNotNull("businessObject", businessObject);

            var businessObjectClass = businessObject.BusinessObjectClass;

            Assertion.IsNotNull(businessObjectClass, "The business object's BusinessObjectClass-property evaluated and returned null.");

            var displayNameProperty = businessObjectClass.GetPropertyDefinition("DisplayName");

            if (displayNameProperty == null)
            {
                // No property-is-accessible checks can be performed.
                // This code path would only be exercised if the DisplayName property is not included in the bound properties.
                return(businessObject.DisplayName);
            }

            if (displayNameProperty.IsAccessible(businessObject))
            {
                try
                {
                    return((string)businessObject.GetProperty(displayNameProperty));
                }
                catch (BusinessObjectPropertyAccessException)
                {
                    // Fallback to not-accessible-property behavior
                }
            }

            var businessObjectProvider = displayNameProperty.BusinessObjectProvider;

            Assertion.IsNotNull(businessObjectProvider, "IBusinessObjectProperty.BusinessObjectProvider cannot be null.");

            return(businessObjectProvider.GetNotAccessiblePropertyStringPlaceHolder());
        }
Exemple #2
0
        public void GetProperty_UniqueIdentifier()
        {
            Tenant tenant = TestHelper.CreateTenant("TestTenant", string.Empty);
            IBusinessObjectWithIdentity businessObject = tenant;

            tenant.UniqueIdentifier = "My Unique Identifier";

            Assert.That(businessObject.GetProperty("UniqueIdentifier"), Is.EqualTo("My Unique Identifier"));
            Assert.That(businessObject.UniqueIdentifier, Is.EqualTo(tenant.ID.ToString()));
        }
Exemple #3
0
        public void GetProperty_UniqueIdentifier()
        {
            Group group = CreateGroup();
            IBusinessObjectWithIdentity businessObject = group;

            group.UniqueIdentifier = "My Unique Identifier";

            Assert.That(businessObject.GetProperty("UniqueIdentifier"), Is.EqualTo("My Unique Identifier"));
            Assert.That(businessObject.UniqueIdentifier, Is.EqualTo(@group.ID.ToString()));
        }
Exemple #4
0
        public void GetPropertyDefinition_UniqueIdentifier()
        {
            Tenant tenant = TestHelper.CreateTenant("TestTenant", string.Empty);
            IBusinessObjectWithIdentity businessObject = tenant;

            tenant.UniqueIdentifier = "My Unique Identifier";

            IBusinessObjectProperty property = businessObject.BusinessObjectClass.GetPropertyDefinition("UniqueIdentifier");

            Assert.IsInstanceOf(typeof(IBusinessObjectStringProperty), property);
            Assert.That(businessObject.GetProperty(property), Is.EqualTo("My Unique Identifier"));
        }
Exemple #5
0
        public void GetPropertyDefinition_UniqueIdentifier()
        {
            Group group = CreateGroup();
            IBusinessObjectWithIdentity businessObject = group;

            group.UniqueIdentifier = "My Unique Identifier";

            IBusinessObjectProperty property = businessObject.BusinessObjectClass.GetPropertyDefinition("UniqueIdentifier");

            Assert.IsInstanceOf(typeof(IBusinessObjectStringProperty), property);
            Assert.That(businessObject.GetProperty(property), Is.EqualTo("My Unique Identifier"));
        }
Exemple #6
0
 protected override IBusinessObjectWithIdentity[] GetBusinessObjects(
     BocTreeNode parentNode, IBusinessObjectWithIdentity parent, IBusinessObjectReferenceProperty property)
 {
     if (parent.UniqueIdentifier == new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).ToString())
     {
         IList     children     = (IList)parent.GetProperty(property);
         ArrayList childrenList = new ArrayList();
         for (int i = 0; i < children.Count; i++)
         {
             if (i != 1)
             {
                 childrenList.Add(children[i]);
             }
         }
         return((IBusinessObjectWithIdentity[])childrenList.ToArray(typeof(IBusinessObjectWithIdentity)));
     }
     return(base.GetBusinessObjects(parentNode, parent, property));
 }
Exemple #7
0
        protected virtual IBusinessObjectWithIdentity[] GetBusinessObjects(
            BocTreeNode parentNode,
            IBusinessObjectWithIdentity parentBusinessObject,
            IBusinessObjectReferenceProperty parentProperty)
        {
            ArgumentUtility.CheckNotNull("parentNode", parentNode);
            ArgumentUtility.CheckNotNull("parentBusinessObject", parentBusinessObject);
            ArgumentUtility.CheckNotNull("parentProperty", parentProperty);

            IList children = (IList)parentBusinessObject.GetProperty(parentProperty);

            if (children == null)
            {
                return(new IBusinessObjectWithIdentity[0]);
            }

            return(children.Cast <IBusinessObjectWithIdentity>().ToArray());
        }