public CoalesceProperty ReadProperty(XElement propertyElement)
        {
            if (propertyElement == null)
            {
                throw new ArgumentNullException("propertyElement");
            }

            var propertyName = (string)propertyElement.Attribute("name");

            if (propertyName.IsNullOrWhiteSpace())
            {
                return(null);
            }

            var property = new CoalesceProperty(propertyName);

            if (propertyElement.HasElements)
            {
                var valueElements = from el in propertyElement.Elements("Value") select el;

                // Loop through the current properties values
                foreach (var valueElement in valueElements)
                {
                    var value = valueElement.Value;
                    var type  = (int?)valueElement.Attribute("type");

                    if (!value.IsNullOrWhiteSpace())
                    {
                        value = SpecialCharactersPattern.Replace(value.Trim(), "");
                    }

                    property.Add(new CoalesceValue(value, type));
                }
            }
            else
            {
                var value = propertyElement.Value;
                var type  = (int?)propertyElement.Attribute("type");

                if (!value.IsNullOrWhiteSpace())
                {
                    value = SpecialCharactersPattern.Replace(value.Trim(), "");
                }

                property.Add(new CoalesceValue(value, type));
            }

            return(property);
        }
        public CoalesceProperty ReadProperty(XElement propertyElement)
        {
            if (propertyElement == null)
            {
                throw new ArgumentNullException(nameof(propertyElement));
            }

            var propertyName = (string)propertyElement.Attribute("name");
            //var optionsString = ((string) propertyElement.Attribute("options")) ?? "";

            // Trim spaces from options
            //optionsString = Regex.Replace(optionsString, @"\s+", "");
            //var options = optionsString.Split(new []{ '|' }, StringSplitOptions.RemoveEmptyEntries);

            // Old, remove eventually
            var ignoreProperty = (bool?)propertyElement.Attribute("ignore") ?? false;

            //var allowDuplicates = (bool?) propertyElement.Attribute("allowDuplicates") ?? false;

            if (ignoreProperty || string.IsNullOrEmpty(propertyName))
            {
                return(null);
            }

            var property = new CoalesceProperty(propertyName);

            if (propertyElement.HasElements)
            {
                var valueElements = from el in propertyElement.Elements("Value") select el;

                // Loop through the current properties values
                foreach (var valueElement in valueElements)
                {
                    var value = valueElement.Value;
                    var type  = (int?)valueElement.Attribute("type");
                    //var ignoreValue = (bool?) valueElement.Attribute("ignore") ?? false;

                    if (!string.IsNullOrEmpty(value))
                    {
                        value = SpecialCharactersPattern.Replace(value.Trim(), "");
                    }

                    property.Add(new CoalesceValue(value, type));

                    /*switch (type)
                     * {
                     *      case -1:
                     *      {
                     *              property.Clear();
                     *              property.Add(new CoalesceValue(value, type));
                     *
                     *              break;
                     *      }
                     *      case 0:
                     *      {
                     *              property.Clear();
                     *              property.Add(new CoalesceValue(value, type));
                     *
                     *              break;
                     *      }
                     *      case 1:
                     *      {
                     *              property.Clear();
                     *              property.Add(new CoalesceValue(value, type));
                     *
                     *              break;
                     *      }
                     *      case 2:
                     *      {
                     *              property.Add(new CoalesceValue(value, type));
                     *
                     *              break;
                     *      }
                     *      case 3:
                     *      {
                     *              if (!property.Any(v => v.Equals(value) && v.ValueType != 4))
                     *              {
                     *                      property.Add(new CoalesceValue(value, type));
                     *              }
                     *
                     *              break;
                     *      }
                     *      case 4:
                     *      {
                     *              property.RemoveAll(v => v.Equals(value));
                     *
                     *              property.Add(new CoalesceValue(value, type));
                     *
                     *              break;
                     *      }
                     * }*/
                }
            }
            else
            {
                var value = propertyElement.Value;
                var type  = (int?)propertyElement.Attribute("type");

                if (!string.IsNullOrEmpty(value))
                {
                    value = SpecialCharactersPattern.Replace(value.Trim(), "");
                }

                property.Add(new CoalesceValue(value, type));
            }

            return(property);
        }
		public CoalesceProperty ReadProperty(XElement propertyElement)
		{
			if (propertyElement == null)
			{
				throw new ArgumentNullException(nameof(propertyElement));
			}

			var propertyName = (string) propertyElement.Attribute("name");
			//var optionsString = ((string) propertyElement.Attribute("options")) ?? "";

			// Trim spaces from options
			//optionsString = Regex.Replace(optionsString, @"\s+", "");
			//var options = optionsString.Split(new []{ '|' }, StringSplitOptions.RemoveEmptyEntries);

			// Old, remove eventually
			var ignoreProperty = (bool?) propertyElement.Attribute("ignore") ?? false;
			//var allowDuplicates = (bool?) propertyElement.Attribute("allowDuplicates") ?? false;

			if (ignoreProperty || propertyName.IsNullOrWhiteSpace())
			{
				return null;
			}

			var property = new CoalesceProperty(propertyName);

			if (propertyElement.HasElements)
			{
				var valueElements = from el in propertyElement.Elements("Value") select el;

				// Loop through the current properties values
				foreach (var valueElement in valueElements)
				{
					var value = valueElement.Value;
					var type = (int?) valueElement.Attribute("type");
					//var ignoreValue = (bool?) valueElement.Attribute("ignore") ?? false;

					if (!value.IsNullOrWhiteSpace())
					{
						value = SpecialCharactersPattern.Replace(value.Trim(), "");
					}

					property.Add(new CoalesceValue(value, type));

					/*switch (type)
					{
						case -1:
						{
							property.Clear();
							property.Add(new CoalesceValue(value, type));

							break;
						}
						case 0:
						{
							property.Clear();
							property.Add(new CoalesceValue(value, type));

							break;
						}
						case 1:
						{
							property.Clear();
							property.Add(new CoalesceValue(value, type));

							break;
						}
						case 2:
						{
							property.Add(new CoalesceValue(value, type));

							break;
						}
						case 3:
						{
							if (!property.Any(v => v.Equals(value) && v.ValueType != 4))
							{
								property.Add(new CoalesceValue(value, type));
							}

							break;
						}
						case 4:
						{
							property.RemoveAll(v => v.Equals(value));

							property.Add(new CoalesceValue(value, type));

							break;
						}
					}*/
				}
			}
			else
			{
				var value = propertyElement.Value;
				var type = (int?) propertyElement.Attribute("type");

				if (!value.IsNullOrWhiteSpace())
				{
					value = SpecialCharactersPattern.Replace(value.Trim(), "");
				}

				property.Add(new CoalesceValue(value, type));
			}

			return property;
		}