Catel.Runtime.Serialization.SerializationManager.GetRegularProperties C# (CSharp) Method

GetRegularProperties() public method

Gets the regular properties.
The is null.
public GetRegularProperties ( Type type ) : MemberMetadata>.Dictionary
type System.Type Type of the model.
return MemberMetadata>.Dictionary
        public Dictionary<string, MemberMetadata> GetRegularProperties(Type type)
        {
            Argument.IsNotNull("type", type);

            return _regularPropertiesCache.GetFromCacheOrFetch(type, () =>
            {
                var dictionary = new Dictionary<string, MemberMetadata>();

                var catelPropertyNames = GetCatelPropertyNames(type, true);

                var regularProperties = type.GetPropertiesEx();
                foreach (var propertyInfo in regularProperties)
                {
                    if (catelPropertyNames.Contains(propertyInfo.Name) ||
                        propertyInfo.DeclaringType == typeof(ModelBase))
                    {
                        continue;
                    }

                    var memberMetadata = new MemberMetadata(type, propertyInfo.PropertyType, SerializationMemberGroup.RegularProperty, propertyInfo.Name)
                    {
                        Tag = propertyInfo
                    };

                    var nameOverride = GetNameOverrideForSerialization(propertyInfo);
                    if (!string.IsNullOrWhiteSpace(nameOverride))
                    {
                        memberMetadata.MemberNameForSerialization = nameOverride;
                    }

                    dictionary[propertyInfo.Name] = memberMetadata;
                }

                return dictionary;
            });
        }

Usage Example

        /// <summary>
        /// Gets the type of the member.
        /// </summary>
        /// <param name="modelType">Type of the model.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <returns>The <see cref="Type"/> of the member.</returns>
        protected Type GetMemberType(Type modelType, string memberName)
        {
            var catelProperties = SerializationManager.GetCatelProperties(modelType);

            if (catelProperties.ContainsKey(memberName))
            {
                return(catelProperties[memberName].MemberType);
            }

            var regularProperties = SerializationManager.GetRegularProperties(modelType);

            if (regularProperties.ContainsKey(memberName))
            {
                return(regularProperties[memberName].MemberType);
            }

            var fields = SerializationManager.GetFields(modelType);

            if (fields.ContainsKey(memberName))
            {
                return(fields[memberName].MemberType);
            }

            return(null);
        }
All Usage Examples Of Catel.Runtime.Serialization.SerializationManager::GetRegularProperties