Class containing all information about a Catel type (such as properties).
Пример #1
0
        public void CorrectlyRegistersNonCatelProperties()
        {
            var catelTypeInfo = new CatelTypeInfo(typeof(CatelTypeInfoTestModel));

            var properties = catelTypeInfo.GetNonCatelProperties();
            Assert.AreNotEqual(0, properties.Count);
            Assert.IsTrue(properties.Keys.Contains("NormalProperty"));
        }
Пример #2
0
        /// <summary>
        /// Unregisters a property for a specific type.
        /// </summary>
        /// <param name="type">The type for which to register the property.</param>
        /// <param name="name">The name of the property.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="type"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="name"/> is <c>null</c> or whitespace.</exception>
        public void UnregisterProperty(Type type, string name)
        {
            Argument.IsNotNullOrWhitespace("name", name);

            lock (_propertyDataLock)
            {
                if (!_propertyData.ContainsKey(type))
                {
                    _propertyData[type] = new CatelTypeInfo(type);
                }

                _propertyData[type].UnregisterProperty(name);
            }
        }
Пример #3
0
        /// <summary>
        /// Registers all the properties for the specified type.
        /// <para />
        /// This method can only be called once per type. The <see cref="PropertyDataManager"/> caches
        /// whether it has already registered the properties once.
        /// </summary>
        /// <param name="type">The type to register the properties for.</param>
        /// <returns>The property data type info.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="type"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">The properties are not declared correctly.</exception>
        public CatelTypeInfo RegisterProperties(Type type)
        {
            Argument.IsNotNull("type", type);

            lock (_propertyDataLock)
            {
                if (!_propertyData.TryGetValue(type, out var typeInfo))
                {
                    typeInfo            = new CatelTypeInfo(type);
                    _propertyData[type] = typeInfo;
                }

                return(typeInfo);
            }
        }
Пример #4
0
        /// <summary>
        /// Unregisters a property for a specific type.
        /// </summary>
        /// <param name="type">The type for which to register the property.</param>
        /// <param name="name">The name of the property.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="type"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="name"/> is <c>null</c> or whitespace.</exception>
        public void UnregisterProperty(Type type, string name)
        {
            Argument.IsNotNullOrWhitespace("name", name);

            lock (_propertyDataLock)
            {
                if (!_propertyData.TryGetValue(type, out var typeInfo))
                {
                    typeInfo            = new CatelTypeInfo(type);
                    _propertyData[type] = typeInfo;
                }

                typeInfo.UnregisterProperty(name);
            }
        }
Пример #5
0
        /// <summary>
        /// Registers all the properties for the specified type.
        /// <para />
        /// This method can only be called once per type. The <see cref="PropertyDataManager"/> caches
        /// whether it has already registered the properties once.
        /// </summary>
        /// <param name="type">The type to register the properties for.</param>
        /// <returns>The property data type info.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="type"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">The properties are not declared correctly.</exception>
        public CatelTypeInfo RegisterProperties(Type type)
        {
            Argument.IsNotNull("type", type);

            lock (_propertyDataLock)
            {
                if (_propertyData.ContainsKey(type))
                {
                    return(_propertyData[type]);
                }

                var catelTypeInfo = new CatelTypeInfo(type);
                _propertyData[type] = catelTypeInfo;
                return(catelTypeInfo);
            }
        }
Пример #6
0
        /// <summary>
        /// Registers all the properties for the specified type.
        /// <para />
        /// This method can only be called once per type. The <see cref="PropertyDataManager"/> caches
        /// whether it has already registered the properties once.
        /// </summary>
        /// <param name="type">The type to register the properties for.</param>
        /// <returns>The property data type info.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="type"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">The properties are not declared correctly.</exception>
        public CatelTypeInfo RegisterProperties(Type type)
        {
            Argument.IsNotNull("type", type);

            lock (_propertyDataLock)
            {
                if (_propertyData.ContainsKey(type))
                {
                    return _propertyData[type];
                }

                var catelTypeInfo = new CatelTypeInfo(type);
                _propertyData[type] = catelTypeInfo;
                return catelTypeInfo;
            }
        }
Пример #7
0
        /// <summary>
        /// Unregisters a property for a specific type.
        /// </summary>
        /// <param name="type">The type for which to register the property.</param>
        /// <param name="name">The name of the property.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="type"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="name"/> is <c>null</c> or whitespace.</exception>
        public void UnregisterProperty(Type type, string name)
        {
            Argument.IsNotNullOrWhitespace("name", name);

            lock (_propertyDataLock)
            {
                if (!_propertyData.ContainsKey(type))
                {
                    _propertyData[type] = new CatelTypeInfo(type);
                }

                _propertyData[type].UnregisterProperty(name);
            }
        }