/// <summary> /// Returns the value to use for the entity's content element mime type annotation /// </summary> /// <param name="instance">The entity instance</param> /// <param name="defaultValue">The default value to return if no annotation is found</param> /// <returns>The value of the annotation, or the default if one does not exist</returns> public static string GetContentType(this EntityInstance instance, string defaultValue) { ContentTypeAnnotation annotation = instance.Annotations.OfType <ContentTypeAnnotation>().SingleOrDefault(); if (annotation == null) { return(defaultValue); } return(annotation.Value); }
/// <summary> /// Sets the stream source link of the given entity, then returns it /// </summary> /// <param name="entity">The entity to update</param> /// <param name="link">The stream source link </param> /// <returns>The given entity with the updated stream source link</returns> public static EntityInstance WithStreamSourceLink(this EntityInstance entity, string link) { ExceptionUtilities.CheckArgumentNotNull(entity, "entity"); entity.StreamSourceLink = link; return(entity); }
/// <summary> /// Sets the stream content type of the given entity, then returns it /// </summary> /// <param name="entity">The entity to update</param> /// <param name="contentType">The stream content type</param> /// <returns>The given entity with the updated stream content type</returns> public static EntityInstance WithStreamContentType(this EntityInstance entity, string contentType) { ExceptionUtilities.CheckArgumentNotNull(entity, "entity"); entity.StreamContentType = contentType; return(entity); }
public static EntityInstance WithStreamETag(this EntityInstance entity, string etag) { ExceptionUtilities.CheckArgumentNotNull(entity, "entity"); entity.StreamETag = etag; return(entity); }
/// <summary> /// Adds a content type annotation to the given entity instance /// </summary> /// <param name="instance">The entity instance</param> /// <param name="contentTypeValue">The value for the annotation</param> /// <returns>The same entity instance</returns> public static EntityInstance WithContentType(this EntityInstance instance, string contentTypeValue) { return(instance.AddAnnotation(new ContentTypeAnnotation(contentTypeValue))); }
/// <summary> /// Returns the self link annotation value of the entity, if one exists /// </summary> /// <param name="instance">The entity to get the self link from</param> /// <returns>The self link, or null if no annotation is found</returns> public static string GetSelfLink(this EntityInstance instance) { return(instance.Annotations.OfType <SelfLinkAnnotation>().Select(a => a.Value).SingleOrDefault()); }
/// <summary> /// Returns the edit link annotation value of the entity, if one exists /// </summary> /// <param name="instance">The entity to get the edit link from</param> /// <returns>The edit link, or null if no annotation is found</returns> public static string GetEditLink(this EntityInstance instance) { return(instance.EditLink); }
/// <summary> /// Adds an self link annotation to the given entity instance /// </summary> /// <param name="instance">the entity instance</param> /// <param name="selfLinkValue">The value of the self link</param> /// <returns>The same entity instance that was given</returns> public static EntityInstance WithSelfLink(this EntityInstance instance, string selfLinkValue) { instance.AddAnnotationIfNotExist(new SelfLinkAnnotation(selfLinkValue)); return(instance); }
/// <summary> /// Adds an edit link annotation to the given entity instance /// </summary> /// <param name="instance">the entity instance</param> /// <param name="editLinkValue">The value of the edit link</param> /// <returns>The same entity instance that was given</returns> public static EntityInstance WithEditLink(this EntityInstance instance, string editLinkValue) { instance.EditLink = editLinkValue; return(instance); }
/// <summary> /// Returns whether or not the entity is marked with a media link entry annotation /// </summary> /// <param name="instance">The entity to check</param> /// <returns>Whether or not there is a media link entry annotation on the entity</returns> public static bool IsMediaLinkEntry(this EntityInstance instance) { return(instance.StreamSourceLink != null || instance.Annotations.OfType <IsMediaLinkEntryAnnotation>().Any()); }
/// <summary> /// Adds the media link entry annotation to the given entity instance /// </summary> /// <param name="instance">The entity instance</param> /// <returns>The same entity instance</returns> public static EntityInstance AsMediaLinkEntry(this EntityInstance instance) { return(instance.AddAnnotation(new IsMediaLinkEntryAnnotation())); }