internal EntityDescriptor(string identity, Uri selfLink, Uri editLink, object entity, EntityDescriptor parentEntity, string parentProperty, string entitySetName, string etag, EntityStates state)
: base(state)
{
Debug.Assert(entity != null, "entity is null");
Debug.Assert((parentEntity == null && parentProperty == null) || (parentEntity != null && parentProperty != null), "When parentEntity is specified, must also specify parentProperyName");
#if DEBUG
if (state == EntityStates.Added)
{
Debug.Assert(identity == null && selfLink == null && editLink == null && etag == null, "For objects in added state, identity, self-link, edit-link and etag must be null");
Debug.Assert(
(!string.IsNullOrEmpty(entitySetName) && parentEntity == null && string.IsNullOrEmpty(parentProperty)) ||
(string.IsNullOrEmpty(entitySetName) && parentEntity != null && !string.IsNullOrEmpty(parentProperty)),
"For entities in added state, entity set name or the insert path must be specified");
}
else
{
Debug.Assert(identity != null, "For objects in non-added state, identity must never be null");
Debug.Assert(string.IsNullOrEmpty(entitySetName) && string.IsNullOrEmpty(parentProperty) && parentEntity == null, "For non-added entities, the entity set name and the insert path must be null");
}
#endif
this.identity = identity;
this.selfLink = selfLink;
this.editLink = editLink;
this.parentDescriptor = parentEntity;
this.parentProperty = parentProperty;
this.entity = entity;
this.etag = etag;
this.entitySetName = entitySetName;
}