internal static IAggregateFieldConfig LoadAggregateFieldConfig(PropertyInfo pi) { IAggregateFieldConfig config = null; if (config == null) { LightDataConfig lightDataConfig = GetConfig(); if (lightDataConfig != null && lightDataConfig.ContainAggregateTableConfig(pi.ReflectedType)) { AggregateTableConfig atconfig = lightDataConfig.GetAggregateTableConfig(pi.ReflectedType); IConfiguratorFieldConfig fieldConfig = atconfig[pi.Name]; if (fieldConfig != null) { if (fieldConfig is IgnoraFieldConfig) { return(null); } config = atconfig[pi.Name] as AggregateFieldConfig; } } } if (config == null) { AggregateFieldAttribute[] attributes = AttributeCore.GetPropertyAttributes <AggregateFieldAttribute>(pi, true); if (attributes.Length > 0) { config = attributes[0]; } } return(config); }
public void LoadConfig(XmlNode configNode) { if (configNode == null) { throw new ArgumentNullException("ConfigNode"); } _dataTableConfigs = new Dictionary <Type, DataTableConfig>(); _aggregateTableConfigs = new Dictionary <Type, AggregateTableConfig>(); foreach (XmlNode typeNode in configNode.ChildNodes) { if (typeNode.Name == "DataType") { DataTableConfig config = LoadDataTableConfig(typeNode); _dataTableConfigs.Add(config.DataType, config); } else if (typeNode.Name == "AggregateType") { AggregateTableConfig config = LoadAggregateTableConfig(typeNode); _aggregateTableConfigs.Add(config.DataType, config); } } }
AggregateTableConfig LoadAggregateTableConfig(XmlNode typeNode) { if (typeNode == null) { throw new ArgumentException("TypeNode"); } if (typeNode.Name != "AggregateType") { throw new LightDataException(string.Format(RE.ConfigDataLoadError, "AggregateType")); } AggregateTableConfig config = null; Type dataType = null; Type relateType = null; string dataTypeName = null; string relateTypeName = null; if (typeNode.Attributes["Type"] != null) { dataTypeName = typeNode.Attributes["Type"].Value; } if (string.IsNullOrEmpty(dataTypeName)) { throw new LightDataException(string.Format(RE.ConfigDataTypeValueIsEmpty, "Type")); } if (typeNode.Attributes["RelateType"] != null) { relateTypeName = typeNode.Attributes["RelateType"].Value; } //if (string.IsNullOrEmpty(relateTypeName)) //{ // throw new LightDataException(string.Format(RE.ConfigDataTypeValueIsEmpty, "RelateType")); //} dataType = System.Type.GetType(dataTypeName, true); if (!string.IsNullOrEmpty(relateTypeName)) { relateType = System.Type.GetType(relateTypeName, true); } config = new AggregateTableConfig(dataType, relateType); if (typeNode.Attributes["ExtendParams"] != null) { config.ExtendParams = typeNode.Attributes["ExtendParams"].Value; } foreach (XmlNode fieldNode in typeNode.ChildNodes) { IConfiguratorFieldConfig fieldConfig = null; if (fieldNode.Name == "AggregateField") { fieldConfig = LoadAggregateFieldConfig(fieldNode, dataType); } if (fieldNode.Name == "IgnoraField") { fieldConfig = LoadIgnoraFieldConfig(fieldNode, dataType); } if (fieldConfig != null) { config.SetField(fieldConfig); } } return(config); }