/// <summary> /// Return sub entity path. /// </summary> /// <param name="subEntity">Sub entity.</param> /// <returns></returns> public override string GetSubEntityFullPath(EntityPath subEntity) { // if it works with User graph object then just forward // actual entity path. subEntity.ThrowIfNull(nameof(subEntity)); if (subEntity.Path.StartsWith("users", StringComparison.OrdinalIgnoreCase)) { if (subEntity.Id.Equals("") || this.Id.Equals(subEntity.Id, StringComparison.OrdinalIgnoreCase)) { return($"{this.EntityPath.Path}"); } if (Guid.TryParse(subEntity.Id, out Guid id)) { // navigation property case, return subEntity path as // correct path will be there. return($"{subEntity.Path}"); } return($"{this.EntityPath.Path}/{subEntity.Id}"); } return(base.GetSubEntityFullPath(subEntity)); }
/// <summary> /// Create new instance of <see cref="GraphUri"/> /// </summary> /// <param name="identity">Identity.</param> /// <param name="subEntity">Sub entity.</param> /// <param name="beta">Connect to beta endpoint.</param> internal GraphUri(IGraphIdentity identity, EntityPath subEntity, bool beta) { identity.ThrowIfNull(nameof(identity)); subEntity.ThrowIfNull(nameof(subEntity)); this.IsBeta = beta; this.Identity = identity; this.restUri = new HttpRestUri( $"{GraphUri.baseGraphUri}/{this.GetServiceInstance()}/{this.Identity.GetSubEntityFullPath(subEntity)}"); }
/// <summary> /// Create sub entity path. /// </summary> /// <param name="subEntity">Sub entity.</param> /// <returns></returns> public virtual string GetSubEntityFullPath(EntityPath subEntity) { subEntity.ThrowIfNull(nameof(subEntity)); return($"{this.EntityPath.Path}/{subEntity.Path}"); }