/// <summary>
        /// Get the object uri for the specified type.
        /// </summary>
        /// <param name="graphConnection">Call context.</param>
        /// <param name="typeOfEntityObject">Type of object.</param>
        /// <param name="objectId">Object id (optional)</param>
        /// <param name="fragments">Optional url fragments.</param>
        /// <returns>Request uri.</returns>
        public static Uri GetRequestUri(
            GraphConnection graphConnection,
            Type parentType,
            string parentObjectId,
            Type containmentType,
            string containmentObjectId,
            params string[] fragments)
        {
            EntityAttribute containmentEntityAttribute = Utils.GetCustomAttribute <EntityAttribute>(containmentType, true);
            StringBuilder   containmentUriEntry        = new StringBuilder(containmentEntityAttribute.SetName);

            if (!string.IsNullOrEmpty(containmentObjectId))
            {
                containmentUriEntry.AppendFormat("/{0}", containmentObjectId);
            }

            IList <string> fragmentsList = fragments == null ? new List <string>() : fragments.ToList();

            fragmentsList.Add(containmentUriEntry.ToString());

            return(Utils.GetRequestUri(
                       graphConnection, parentType, parentObjectId, null, -1, fragmentsList.ToArray()));
        }
        /// <summary>
        /// Get the object uri for the specified type.
        /// </summary>
        /// <param name="graphConnection">Call context.</param>
        /// <param name="typeOfEntityObject">Type of object.</param>
        /// <param name="objectId">Object id (optional)</param>
        /// <param name="nextLink">Optional next link.</param>
        /// <param name="top">Optional top (less than zero is ignored)</param>
        /// <param name="fragments">Optional url fragments.</param>
        /// <returns>Request uri.</returns>
        public static Uri GetRequestUri(
            GraphConnection graphConnection,
            Type typeOfEntityObject,
            string objectId,
            string nextLink,
            int top,
            params string[] fragments)
        {
            StringBuilder sb      = new StringBuilder();
            string        baseUri = graphConnection.AadGraphEndpoint;

            if (!String.IsNullOrEmpty(nextLink))
            {
                sb.AppendFormat(
                    CultureInfo.InvariantCulture,
                    "{0}/{1}",
                    baseUri,
                    nextLink);
            }
            else
            {
                if (typeOfEntityObject != null)
                {
                    // TODO: Cache the EntityAttribute
                    EntityAttribute entityAttribute = Utils.GetCustomAttribute <EntityAttribute>(typeOfEntityObject, true);

                    sb.AppendFormat(
                        CultureInfo.InvariantCulture,
                        "{0}/{1}",
                        baseUri,
                        entityAttribute.SetName);
                }
                else
                {
                    sb.Append(baseUri);
                }

                if (!String.IsNullOrEmpty(objectId))
                {
                    sb.AppendFormat(
                        CultureInfo.InvariantCulture, "/{0}", objectId);
                }

                foreach (string fragment in fragments)
                {
                    sb.AppendFormat(
                        CultureInfo.InvariantCulture,
                        "/{0}",
                        fragment);
                }
            }

            UriBuilder uriBuilder = new UriBuilder(sb.ToString());

            Utils.AddQueryParameter(
                uriBuilder,
                Constants.QueryParameterNameApiVersion,
                graphConnection.GraphApiVersion,
                true);

            if (top > 0)
            {
                Utils.AddQueryParameter(
                    uriBuilder,
                    Constants.TopOperator,
                    top.ToString(),
                    true);
            }

            return(uriBuilder.Uri);
        }