Catel.Runtime.Serialization.SerializationManager.GetCatelProperties C# (CSharp) Метод

GetCatelProperties() публичный Метод

Gets the catel properties.
The is null.
public GetCatelProperties ( Type type, bool includeModelBaseProperties = false ) : MemberMetadata>.Dictionary
type System.Type Type of the model.
includeModelBaseProperties bool if set to true, also include model base properties.
Результат MemberMetadata>.Dictionary
        public Dictionary<string, MemberMetadata> GetCatelProperties(Type type, bool includeModelBaseProperties = false)
        {
            Argument.IsNotNull("type", type);

            var key = GetCacheKey(type, includeModelBaseProperties);

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

                var propertyDataManager = PropertyDataManager.Default;
                var catelTypeInfo = propertyDataManager.GetCatelTypeInfo(type);
                var properties = (from property in catelTypeInfo.GetCatelProperties()
                                  select property.Value);

                if (!includeModelBaseProperties)
                {
                    properties = properties.Where(x => !x.IsModelBaseProperty);
                }

                foreach (var property in properties)
                {
                    var memberMetadata = new MemberMetadata(type, property.Type, SerializationMemberGroup.CatelProperty, property.Name)
                    {
                        Tag = property
                    };

                    var propertyInfo = property.GetPropertyInfo(type);
                    if (propertyInfo != null && propertyInfo.PropertyInfo != null)
                    {
                        var nameOverride = GetNameOverrideForSerialization(propertyInfo.PropertyInfo);
                        if (!string.IsNullOrWhiteSpace(nameOverride))
                        {
                            memberMetadata.MemberNameForSerialization = nameOverride;
                        }
                    }

                    dictionary[property.Name] = memberMetadata;
                }

                return dictionary;
            });
        }

Usage Example

Пример #1
0
        /// <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::GetCatelProperties