コード例 #1
0
        /// <summary>
        /// Instantiates a <see cref="CsvQueryColumnConfiguration"/>
        /// </summary>
        /// <param name="xmlElement"></param>
        public CsvQueryColumnConfiguration(XmlElement xmlElement)
        {
            // validate element
            xmlElement.ShouldBeNamed(ColumnElementName);

            // get attribute values
            _tag = xmlElement.GetAttributeValue(TagAttributeName);
            _description = xmlElement.GetAttributeValue(DescriptionAttributeName);
            _mappedProperty = xmlElement.GetAttributeValue(MappedPropertyAttributeName, false);
            _enabled = bool.Parse(xmlElement.GetAttributeValue(EnabledAttributeName));
        }
コード例 #2
0
        /// <summary>
        /// Loads section from xml
        /// </summary>
        /// <param name="xmlElement"></param>
        public void Load(XmlElement xmlElement)
        {
            // validate name
            xmlElement.ShouldBeNamed(SectionName);

            // validate name of columns collection
            xmlElement.FirstChild.ShouldBeNamed(ColumnsElementName);

            // create column configurations
            _columnConfigurations =
                xmlElement.FirstChild.ChildNodes.OfType<XmlElement>().Select(e => new CsvQueryColumnConfiguration(e)).ToList();
        }
コード例 #3
0
        /// <summary>
        /// Instantiates a <see cref="YqlPropertyMappingElement"/>
        /// </summary>
        /// <param name="xmlElement"></param>
        public YqlPropertyMappingElement(XmlElement xmlElement)
        {
            // validate element
            xmlElement.ShouldBeNamed(PropertyMappingElementName);

            // get attribute values
            _xmlElementName = xmlElement.GetAttributeValue(XmlElementNameAttributeName);
            _propertyName = xmlElement.GetAttributeValue(PropertyNameAttributeName);

            // set enabled, with a default value of false
            bool enabled;
            if (bool.TryParse(xmlElement.GetAttributeValue(EnabledAttributeName, false), out enabled))
                _enabled = enabled;
        }
コード例 #4
0
        /// <summary>
        /// Gets a parameter for a constructor from a parameter XmlElement
        /// </summary>
        /// <param name="parameterElement"></param>
        /// <returns></returns>
        private static object GetConstructorParameter(XmlElement parameterElement)
        {
            // ensure element is parameter element
            parameterElement.ShouldBeNamed(ParameterElementName);

            // get flag indicating whether or not to resolve the value of the parameter
            var resolve = parameterElement.GetAttributeValue(ResolveAttributeName).ConvertTo<bool>();

            // get the type of the parameter
            var type = parameterElement.GetTypeFromAttribute(TypeAttributeName);

            // get value to be passed in - if resolving, this is not required
            var value = parameterElement.GetAttributeValue(ValueAttributeName, !resolve);

            // get value for parameter
            return resolve
                ? new ResolvedParameter(type, string.IsNullOrWhiteSpace(value) ? value : null)
                : value.ConvertTo(type);
        }
コード例 #5
0
        /// <summary>
        /// Gets a registration from an xml element
        /// </summary>
        /// <param name="registrationElement"></param>
        /// <returns></returns>
        private static Registration CreateRegistration(XmlElement registrationElement)
        {
            registrationElement.ShouldBeNamed(RegistrationElementName);

            // initialize injection constructor to null
            InjectionConstructor injectionConstructor = null;

            // check for an injection constructor element
            var injectionConstructorElement =
                registrationElement.ChildNodes.OfType<XmlElement>()
                                   .FirstOrDefault(x => x.Name == InjectionConstructorElementName);
            if (injectionConstructorElement != null)
                injectionConstructor = GetInjectionConstructor(injectionConstructorElement);

            return new Registration(registrationElement.GetTypeFromAttribute(RegistrationTypeAttributeName),
                registrationElement.GetTypeFromAttribute(RegistrationMapToAttributeName),
                GetLifetimeManager(registrationElement, RegistrationLifetimeAttributeName),
                registrationElement.GetAttributeValue(RegistrationNameAttributeName, false),
                injectionConstructor);
        }