Example #1
0
        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);
        }