Example #1
0
 /// <summary>
 /// The get entity.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 /// <param name="parent">
 /// The parent.
 /// </param>
 /// <param name="childElement">
 /// The child Element.
 /// </param>
 /// <returns>
 /// The <see cref="XElement"/>.
 /// </returns>
 private static XElement GetEntityElement(EntityBase entity, XContainer parent, string childElement)
 {
     IEnumerable<XElement> entities = from c in parent.Descendants(childElement)
                                      let nameAttribute = c.Attribute(Constants.NameAttribute)
                                      where nameAttribute != null && nameAttribute.Value.Equals(entity.Name)
                                      select c;
     return entities.FirstOrDefault();
 }
Example #2
0
        /// <summary>
        /// Update test entity.
        /// </summary>
        /// <param name="testEntity">
        /// The test entity.
        /// </param>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <exception cref="NullReferenceException">
        /// </exception>
        private static void UpdateEntityElement(EntityBase testEntity, XElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element", "Element is not initialized.");
            }

            if (testEntity == null)
            {
                throw new ArgumentNullException("testEntity", "Test entity can not be null.");
            }

            element.SetAttributeValue(Constants.StatusAttribute, testEntity.Status.ToString());
            element.SetAttributeValue(Constants.StartTimeAttribute, testEntity.StartTime ?? string.Empty);
            element.SetAttributeValue(Constants.EndTimeAttribute, testEntity.EndTime ?? DateTimeAdapter.Now);
        }
Example #3
0
 /// <summary>
 /// To construct an entity xml element.
 /// </summary>
 /// <param name="entity">
 /// The entity object.
 /// </param>
 /// <param name="elementName">
 /// The element name.
 /// </param>
 /// <returns>
 /// The entity element.
 /// </returns>
 private static XElement ConstructEntityXElement(EntityBase entity, string elementName)
 {
     return new XElement(
         elementName,
         new XAttribute(Constants.NameAttribute, entity.Name),
         new XAttribute(Constants.StatusAttribute, entity.Status.ToString()),
         new XAttribute(Constants.StartTimeAttribute, entity.StartTime ?? DateTimeAdapter.Now),
         new XAttribute(Constants.EndTimeAttribute, entity.EndTime ?? string.Empty));
 }