GetCatelPropertyNames() public method

Gets the catel property names.
The is null.
public GetCatelPropertyNames ( Type type, bool includeModelBaseProperties = false ) : HashSet
type System.Type Type of the model.
includeModelBaseProperties bool if set to true, also include model base properties.
return HashSet
コード例 #1
0
        /// <summary>
        /// Gets the member group.
        /// </summary>
        /// <param name="modelType">Type of the model.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <returns>The <see cref="SerializationMemberGroup"/>.</returns>
        protected SerializationMemberGroup GetMemberGroup(Type modelType, string memberName)
        {
            var catelProperties = SerializationManager.GetCatelPropertyNames(modelType);

            if (catelProperties.Contains(memberName))
            {
                return(SerializationMemberGroup.CatelProperty);
            }

            var regularProperties = SerializationManager.GetRegularPropertyNames(modelType);

            if (regularProperties.Contains(memberName))
            {
                return(SerializationMemberGroup.RegularProperty);
            }

            return(SerializationMemberGroup.Field);
        }
コード例 #2
0
            public void ThrowsArgumentNullExceptionForNullType()
            {
                var serializationManager = new SerializationManager();

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => serializationManager.GetCatelPropertyNames(null));
            }
コード例 #3
0
            public void ReturnsCorrectValue()
            {
                var serializationManager = new SerializationManager();

                var properties = serializationManager.GetCatelPropertyNames(typeof(TestModel)).ToArray();

                Assert.AreEqual(3, properties.Length);
                Assert.AreEqual("IncludedCatelProperty", properties[0]);
                Assert.AreEqual("ExcludedCatelProperty", properties[1]);
                Assert.AreEqual("ExcludedProtectedCatelProperty", properties[2]);
            }