internal void Update(string uid, string propertyName, string value)
        {
            if (!_elementLookupTable.ContainsKey(uid))
            {
                // Add new element
                Element element = new Element();
                element.UId = uid;
                Property property = new Property();
                property.Name = propertyName;
                property.Value = value;
                element.Properties.Add(property);
                // Update the state
                _state.Elements.Add(element);
                // Update the lookup table
                _elementLookupTable.Add(element.UId, element);
                return;
            }

            Element foundElement = _elementLookupTable[uid];
            if (!Contains(foundElement, propertyName))
            {
                // Add new property
                Property property = new Property();
                property.Name = propertyName;
                property.Value = value;
                foundElement.Properties.Add(property);
                return;
            }

            // Update or remove existing property.
            Property foundProperty = GetProperty(foundElement, propertyName);
            if (value == null)
                foundElement.Properties.Remove(foundProperty);
            else
                foundProperty.Value = value;
        }
 private string GetValue(Element element, string propertyName)
 {
     foreach (Property property in element.Properties)
     {
         if (property.Name == propertyName)
         {
             return property.Value;
         }
     }
     return string.Empty;
 }
 private Property GetProperty(Element element, string propertyName)
 {
     foreach (Property property in element.Properties)
     {
         if (property.Name == propertyName)
         {
             return property;
         }
     }
     return null;
 }
 private bool Contains(Element element, string propertyName)
 {
     foreach (Property property in element.Properties)
     {
         if (property.Name == propertyName)
         {
             return true;
         }
     }
     return false;
 }