private void SetupConfigField(XElement configXML, PropertyInfo p, TransformationFieldAttrib attr, string PropName) { var configElement = configXML.Element("config"); if (configElement != null && configElement.Element(PropName) != null) { string configProp = configElement.Element(PropName).Value; object configObj = TypeDescriptor.GetConverter(p.PropertyType).ConvertFromString(configElement.Element(PropName).Value); if (configObj == null) { throw new ConfigException(string.Format("{0} invalid type conversion", PropName)); } p.SetValue(this, configObj, null); } else if (attr.Required) { throw new ConfigException(string.Format("{0} Requires a Value", PropName)); } }
private void SetupInputOutputFields(XElement mappingConfigXML, PropertyInfo property, TransformationFieldAttrib attr, string PropName) { if ((attr.FieldType == TransformationFieldTypeEnum.Input || attr.FieldType == TransformationFieldTypeEnum.InOut) && !property.CanWrite) { throw new ConfigException(string.Format("{0} Input Transformation Properties Must be Writtable", PropName)); } var mappedName = mappingConfigXML == null || mappingConfigXML.Element(PropName) == null ? "" : mappingConfigXML.Element(PropName).ToString(); var tranFld = new TransformationField() { Name = PropName, Map = !string.IsNullOrEmpty(mappedName) ? mappedName : PropName, Required = attr.Required, FldType = attr.FieldType, }; if (tranFld.Map.StartsWith("@")) { tranFld.IsGlobalVar = true; object globalObject = null; GlobalData.Data.TryGetValue(tranFld.Map, out globalObject); tranFld.GlobalVal = globalObject; } tranFld.PropertyDefault = property.PropertyType.IsValueType ? Activator.CreateInstance(property.PropertyType) : null; tranFld.PropertyGet = LinqAccessors.BuildGetAccessor(property.GetGetMethod()); tranFld.PropertySet = LinqAccessors.BuildSetAccessor(property.GetSetMethod()); if (attr.FieldType == TransformationFieldTypeEnum.Input || attr.FieldType == TransformationFieldTypeEnum.InOut) { _inputfields.Add(tranFld); } if (attr.FieldType == TransformationFieldTypeEnum.Output || attr.FieldType == TransformationFieldTypeEnum.InOut) { _outputfields.Add(tranFld); } }