Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether the domain object contains a property with the specified short name and declaring type.
        /// </summary>
        /// <param name="domainObjectType">The type declaring the property with the given <paramref name="shortPropertyName"/>.</param>
        /// <param name="shortPropertyName">The short property name to check for.</param>
        /// <returns>
        /// True if the domain object contains a property named as specified by <paramref name="shortPropertyName"/> declared on
        /// <paramref name="domainObjectType"/>; otherwise, false.
        /// </returns>
        public bool Contains([NotNull] Type domainObjectType, [NotNull] string shortPropertyName)
        {
            ArgumentUtility.CheckNotNull("domainObjectType", domainObjectType);
            ArgumentUtility.CheckNotNullOrEmpty("shortPropertyName", shortPropertyName);

            return(PropertyAccessorDataCache.GetPropertyAccessorData(domainObjectType, shortPropertyName) != null);
        }
 public override void SetUp()
 {
     base.SetUp();
     _orderCache              = CreatePropertyAccessorDataCache(typeof(Order));
     _distributorCache        = CreatePropertyAccessorDataCache(typeof(Distributor));
     _closedGenericClassCache = CreatePropertyAccessorDataCache(typeof(ClosedGenericClassWithManySideRelationProperties));
     _derivedClassWithMixedPropertiesCache = CreatePropertyAccessorDataCache(typeof(DerivedClassWithDifferentProperties));
 }
        public void ResolveMandatoryPropertyAccessorData_Expression_Mixin_ViaMixin()
        {
            var cacheWithMixins = new PropertyAccessorDataCache(GetTypeDefinition(typeof(TargetClassForPersistentMixin)));
            var data            = cacheWithMixins.ResolveMandatoryPropertyAccessorData((TargetClassForPersistentMixin t) => (Mixin.Get <MixinAddingPersistentProperties> (t).PersistentProperty));

            Assert.That(data, Is.Not.Null);
            Assert.That(data, Is.EqualTo(cacheWithMixins.GetPropertyAccessorData(typeof(MixinAddingPersistentProperties).FullName + ".PersistentProperty")));
        }
        public void ResolvePropertyAccessorData_PropertyInformation_Mixin_ViaMixin()
        {
            var cacheWithMixins     = new PropertyAccessorDataCache(GetTypeDefinition(typeof(TargetClassForPersistentMixin)));
            var propertyinformation = PropertyInfoAdapter.Create(typeof(MixinAddingPersistentProperties).GetProperty("PersistentProperty"));
            var data = cacheWithMixins.ResolvePropertyAccessorData(propertyinformation);

            Assert.That(data, Is.Not.Null);
            Assert.That(data, Is.EqualTo(cacheWithMixins.GetPropertyAccessorData(typeof(MixinAddingPersistentProperties).FullName + ".PersistentProperty")));
        }
        public void ResolveMandatoryPropertyAccessorData_Expression_Mixin_ViaInterface()
        {
            var cacheWithMixins = new PropertyAccessorDataCache(GetTypeDefinition(typeof(TargetClassForPersistentMixin)));
            // ReSharper disable SuspiciousTypeConversion.Global
            var data = cacheWithMixins.ResolveMandatoryPropertyAccessorData((TargetClassForPersistentMixin t) => ((IMixinAddingPersistentProperties)t).PersistentProperty);

            // ReSharper restore SuspiciousTypeConversion.Global

            Assert.That(data, Is.Not.Null);
            Assert.That(data, Is.EqualTo(cacheWithMixins.GetPropertyAccessorData(typeof(MixinAddingPersistentProperties).FullName + ".PersistentProperty")));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Selects the property of the domain object with the given name.
        /// </summary>
        /// <param name="propertyName">The name of the property to be accessed.</param>
        /// <param name="transaction">The transaction to use for accessing the property.</param>
        /// <returns>A <see cref="PropertyAccessor"/> instance encapsulating the requested property.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="propertyName"/> parameter is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">
        /// The <paramref name="propertyName"/> parameter does not denote a valid mapping property of the domain object.
        /// </exception>
        public                         PropertyAccessor this[[NotNull] string propertyName, [NotNull] ClientTransaction transaction]
        {
            get
            {
                // PropertyAccessorDataCache checks the argument
                ArgumentUtility.DebugCheckNotNullOrEmpty("propertyName", propertyName);
                // GetPropertyAccessor checks the argument
                ArgumentUtility.DebugCheckNotNull("transaction", transaction);

                var data = PropertyAccessorDataCache.GetMandatoryPropertyAccessorData(propertyName);
                return(GetPropertyAccessor(transaction, data));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Finds a property with the specified short name, starting its search at a given declaring type upwards the inheritance hierarchy.
        /// </summary>
        /// <param name="typeToStartSearch">The type to start searching from.</param>
        /// <param name="shortPropertyName">The short name of the property to find.</param>
        /// <returns>A <see cref="PropertyAccessor"/> encapsulating the first property with the given <paramref name="shortPropertyName"/>
        /// found when traversing upwards through the inheritance hierarchy, starting from <paramref name="typeToStartSearch"/>.</returns>
        /// <exception cref="ArgumentNullException">One or more of the arguments passed to this method are <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">No matching property could be found.</exception>
        public PropertyAccessor Find([NotNull] Type typeToStartSearch, [NotNull] string shortPropertyName)
        {
            ArgumentUtility.CheckNotNull("typeToStartSearch", typeToStartSearch);
            ArgumentUtility.CheckNotNullOrEmpty("shortPropertyName", shortPropertyName);

            var propertyAccessorData = PropertyAccessorDataCache.FindPropertyAccessorData(typeToStartSearch, shortPropertyName);

            if (propertyAccessorData == null)
            {
                var message = string.Format(
                    "The domain object type '{0}' does not have or inherit a mapping property with the short name '{1}'.",
                    typeToStartSearch.FullName,
                    shortPropertyName);
                throw new ArgumentException(message, "shortPropertyName");
            }

            return(GetPropertyAccessor(ClientTransaction, propertyAccessorData));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Determines whether the domain object contains a property with the specified identifier.
        /// </summary>
        /// <param name="propertyIdentifier">The long property identifier to check for.</param>
        /// <returns>
        /// True if the domain object contains a property named as specified by <paramref name="propertyIdentifier"/>; otherwise, false.
        /// </returns>
        public bool Contains([NotNull] string propertyIdentifier)
        {
            ArgumentUtility.CheckNotNullOrEmpty("propertyIdentifier", propertyIdentifier);

            return(PropertyAccessorDataCache.GetPropertyAccessorData(propertyIdentifier) != null);
        }