Esempio n. 1
0
        private bool TryLoadProperty_RowEntityType(object entity, string propertyName, out object propertyValue)
        {
            propertyValue = null;

            RowEntityType row = entity as RowEntityType;

            if (row == null)
            {
                return(false);
            }

            return(row.Properties.TryGetValue(propertyName, out propertyValue));
        }
Esempio n. 2
0
 private bool UpdateLink(KeyedResourceInstance updateTree, RowEntityType entityType, string linkProperty)
 {
     RowEntityType linkedEntity = FindRowInstance(updateTree);
     if (linkedEntity == null)
         throw new TestFailedException("Could not find row instance for updating link");
     entityType.Properties[linkProperty] = linkedEntity;
     return true;
 }
Esempio n. 3
0
        private RowEntityType AddNewEntity(KeyedResourceInstance updateTree, ResourceType entityType)
        {
            List<RowEntityType> resourceList = _resources[updateTree.ResourceSetName];
            RowEntityType newResource = new RowEntityType(updateTree.ResourceSetName, updateTree.TypeName);

            foreach (ResourceInstanceProperty keyProperty in updateTree.KeyProperties)
            {
                ResourceInstanceSimpleProperty tempProperty = (ResourceInstanceSimpleProperty)keyProperty;
                newResource.Properties.Add(tempProperty.Name, tempProperty.PropertyValue);
            }

            AddProperties(updateTree, newResource);

            if (entityType != null)
                AddNavigationProperties(entityType, newResource);

            resourceList.Add(newResource);

            return newResource;
        }
Esempio n. 4
0
        private bool AddEntityToCollection(KeyedResourceInstance updateTree, RowEntityType entityType, string linkProperty)
        {
            RowEntityType linkedEntity = FindRowInstance(updateTree);
            if (linkedEntity == null)
                throw new TestFailedException("Could not find row instance for adding entity to collection");

            //need to make sure its not already in the list
            List<RowEntityType> list = entityType.Properties[linkProperty] as List<RowEntityType>;
            if (list == null)
                entityType.Properties[linkProperty] = list = new List<RowEntityType>();

            foreach (RowEntityType e in list)
            {
                // if its actually the same reference, then the keys must match
                if (e == linkedEntity)
                    return false;

                // check the keys if its not the same reference
                bool match = true;
                foreach (ResourceInstanceSimpleProperty property in updateTree.KeyProperties)
                {
                    object value;
                    if (e.Properties.TryGetValue(property.Name, out value))
                    {
                        if (value != property.PropertyValue)
                        {
                            match = false;
                            break;
                        }
                    }
                }

                if (match)
                    return false;
            }

            list.Add(linkedEntity);
            return true;
        }