public static IDictionary<string, FieldMetadata> GetFieldMetadata(Type type, Func<FieldMetadata, bool> isHiddenCallback) { var data = new Dictionary<string, FieldMetadata>(); foreach (var propertyInfo in type.GetProperties(BindingFlags.FlattenHierarchy|BindingFlags.Instance|BindingFlags.Public)) { if (!propertyInfo.CanRead) continue; var fieldType = FieldManager.GetSuggestedFieldType(propertyInfo.PropertyType); //if (fieldType == null) // throw new NotSupportedException(String.Concat("Cannot match any FieldType to the '", // propertyInfo.Name, "' property. Property type is: ", propertyInfo.PropertyType)); var fieldMeta = new FieldMetadata { PropertyInfo = propertyInfo, FieldName = propertyInfo.Name, PropertyType = propertyInfo.PropertyType, FieldType = fieldType, CanRead = propertyInfo.CanRead, CanWrite = propertyInfo.CanWrite }; if (fieldType != null && (isHiddenCallback == null || isHiddenCallback(fieldMeta))) data.Add(propertyInfo.Name, fieldMeta); } return data; }
public override IDictionary<string, FieldMetadata> GetFieldMetadata() { var fmd = base.GetFieldMetadata(); if (fmd.ContainsKey(DefaultValueName)) { fmd[DefaultValueName] = new FieldMetadata { FieldName = DefaultValueName, CanRead = true, CanWrite = true, FieldSetting = new HyperLinkFieldSetting { Name = DefaultValueName, DisplayName = GetTitleString(DefaultValueName), Description = GetDescString(DefaultValueName), FieldClassName = typeof (HyperLinkField).FullName, ControlHint = "sn:HyperLink" } }; } fmd.Add(UrlFormatName, new FieldMetadata { FieldName = UrlFormatName, PropertyType = typeof(UrlFormat), FieldType = DynamicContentTools.GetSuggestedFieldType(typeof(UrlFormat)), DisplayName = GetTitleString(UrlFormatName), Description = GetDescString(UrlFormatName), CanRead = true, CanWrite = true }); return fmd; }
private bool IsHiddenProperty(FieldMetadata fieldMeta) { if (fieldMeta.PropertyInfo.Name == "StartupProperty") return IsStartupMode; if (fieldMeta.PropertyInfo.Name == "RuntimeProperty") return IsRuntimeMode; return true; }