public virtual PagedResults <GraphObject> GetLinkedObjects( GraphObject graphObject, LinkProperty linkProperty, string nextPageToken, int top) { Utils.ValidateGraphObject(graphObject, "graphObject"); Uri objectUri = Utils.GetRequestUri( this, graphObject.GetType(), graphObject.ObjectId, nextPageToken, top, Utils.GetLinkName(linkProperty)); if (this.returnBatchItem.Value) { this.batchRequestItems.Value.Add( new BatchRequestItem(HttpVerb.GET, true, objectUri, null, null)); return(null); } byte[] rawResponse = this.ClientConnection.DownloadData(objectUri, null); PagedResults <GraphObject> pagedResults = SerializationHelper.DeserializeJsonResponse <GraphObject>( Encoding.UTF8.GetString(rawResponse), objectUri); return(pagedResults); }
public void GetHashCode_hashes_href_string() { var link = new LinkProperty("http://foo"); int expectedHash = HashCode.Start.Hash("http://foo"); link.GetHashCode().ShouldBe(expectedHash); }
public void Comparison_is_case_insensitive() { var link1 = new LinkProperty("http://foo"); var link2 = new LinkProperty("http://bar"); link1.ShouldBe(new LinkProperty("HTTP://FOO")); link2.ShouldBe(new LinkProperty("HTTP://baR")); }
public void Comparing_compares_href() { var link1 = new LinkProperty("http://foo"); var link2 = new LinkProperty("http://bar"); (link1 == link2).ShouldBeFalse(); (link1 != link2).ShouldBeTrue(); }
/// <summary> /// Gets the link attribute for the link property. /// </summary> /// <param name="entityType">Entity type.</param> /// <param name="linkProperty">Link property.</param> /// <returns>Link attribute.</returns> public static LinkAttribute GetLinkAttribute(Type entityType, LinkProperty linkProperty) { LinkAttribute linkAttribute = Utils.GetLinkAttribute(entityType, linkProperty.ToString()); Utils.ThrowIfNull(linkAttribute, "Unable to lookup link information in the proxy."); return(linkAttribute); }
/// <summary> /// Lower case the first letter of the link property name. /// </summary> /// <param name="linkProperty">Link property.</param> /// <returns>First letter will be lower case.</returns> public static string GetLinkName(LinkProperty linkProperty) { if (linkProperty == LinkProperty.None || LinkNameMap.NameMap.Count <= (int)linkProperty) { throw new ArgumentException("Invalid link property"); } return(LinkNameMap.NameMap[(int)linkProperty]); }
public static float GetLinkValue(int index, LinkProperty code) { CheckEpanetIndex(index); float res = 0; ENgetlinkvalue(index, (int)code, ref res); return(res); }
public virtual GraphObject Get(Type objectType, string objectId, LinkProperty expandProperty) { FilterGenerator filterGenerator = new FilterGenerator(); filterGenerator.ExpandProperty = expandProperty; Uri requestUri; PagedResults <GraphObject> pagedResults = SerializationHelper.DeserializeJsonResponse <GraphObject>( this.GetCore(objectType, objectId, filterGenerator, out requestUri), requestUri); return(pagedResults.Results.FirstOrDefault()); }
public void Comparing_to_null() { LinkProperty link1 = null; LinkProperty link2 = new LinkProperty("http://foo"); (link1 == null).ShouldBeTrue(); (null == link1).ShouldBeTrue(); link1.ShouldBeNull(); (link2 == null).ShouldBeFalse(); (null == link2).ShouldBeFalse(); link2.ShouldNotBe(link1); link2.ShouldNotBe(null); }
public virtual void DeleteLink( GraphObject sourceObject, GraphObject targetObject, LinkProperty linkProperty) { Utils.ValidateGraphObject(sourceObject, "sourceObject"); Uri deleteUri; bool isSingleValued = Utils.GetLinkAttribute(sourceObject.GetType(), linkProperty).IsSingleValued; if (isSingleValued) { // If the link is single valued, the target object id should not be part of the Uri. deleteUri = Utils.GetRequestUri( this, sourceObject.GetType(), sourceObject.ObjectId, Constants.LinksFragment, Utils.GetLinkName(linkProperty)); } else { Utils.ValidateGraphObject(targetObject, "targetObject"); deleteUri = Utils.GetRequestUri( this, sourceObject.GetType(), sourceObject.ObjectId, Constants.LinksFragment, Utils.GetLinkName(linkProperty), targetObject.ObjectId); } if (this.returnBatchItem.Value) { this.batchRequestItems.Value.Add(new BatchRequestItem(HttpVerb.DELETE, true, deleteUri, null, null)); return; } this.ClientConnection.DeleteRequest(deleteUri); }
public virtual void AddLink( GraphObject sourceObject, GraphObject targetObject, LinkProperty linkProperty) { Utils.ValidateGraphObject(sourceObject, "sourceObject"); Utils.ValidateGraphObject(targetObject, "targetObject"); Uri linkUri = Utils.GetRequestUri( this, sourceObject.GetType(), sourceObject.ObjectId, Constants.LinksFragment, Utils.GetLinkName(linkProperty)); Uri targetObjectUri = Utils.GetRequestUri( this, targetObject.GetType(), targetObject.ObjectId); Dictionary <string, string> postParameters = new Dictionary <string, string>() { { "url", targetObjectUri.ToString() } }; string requestJson = JsonConvert.SerializeObject(postParameters); bool isSingleValued = Utils.GetLinkAttribute(sourceObject.GetType(), linkProperty).IsSingleValued; string methodName = isSingleValued ? HttpVerb.PUT : HttpVerb.POST; if (this.returnBatchItem.Value) { this.batchRequestItems.Value.Add(new BatchRequestItem(methodName, true, linkUri, null, requestJson)); return; } this.ClientConnection.UploadString( linkUri, methodName, requestJson, null, null); }
/// <summary> /// Get all target values for this link (single and multi-valued) /// </summary> /// <param name="graphObject">Directory object.</param> /// <param name="linkProperty">Link property.</param> /// <returns>Paged collection of results.</returns> /// <remarks> /// This is NOT a transitive lookup, just a single level lookup. /// </remarks> public virtual IList <GraphObject> GetAllDirectLinks(GraphObject graphObject, LinkProperty linkProperty) { Utils.ValidateGraphObject(graphObject, "graphObject"); List <GraphObject> linkResults = new List <GraphObject>(); PagedResults <GraphObject> pagedResults = null; while (true) { pagedResults = this.GetLinkedObjects( graphObject, linkProperty, pagedResults == null ? null : pagedResults.PageToken, -1); linkResults.AddRange(pagedResults.Results); if (pagedResults.IsLastPage) { break; } } return(linkResults); }
public static void SetLinkValue(int index, LinkProperty code, float value) { CheckEpanetIndex(index); ENsetlinkvalue(index, (int)code, value); }
public virtual PagedResults <GraphObject> GetLinkedObjects( GraphObject graphObject, LinkProperty linkProperty, string nextPageToken) { return(this.GetLinkedObjects(graphObject, linkProperty, nextPageToken, -1)); }
set => SetValue(LinkProperty, value);
public LinkElement(string name, string extension, string path, LinkProperty property) : base(name, extension, path) { Property = property; }
public float this[LinkProperty index] { get => _values[index];