コード例 #1
0
        public void AppendLinksTo(IWebLinkable webLinkable, ApiResourceEndPoint endPoint, ITestApiContext context)
        {
            var weblinkType = webLinkable.GetType();

            if (!_linkCreators.ContainsKey(webLinkable.GetType()))
            {
                return;
            }

            _linkCreators[weblinkType].AppendFunctionsTo(webLinkable, endPoint, context);
        }
コード例 #2
0
        /// <summary>
        /// Appends the links to.
        /// </summary>
        /// <param name="webLinkable">The <see cref="IWebLinkable" /> object.</param>
        /// <param name="endPoint"></param>
        /// <param name="context">Context containing information about the request.</param>
        //public void AppendFunctionsTo(IWebLinkable webLinkable, ApiResourceEndPoint endPoint, ITestApiContext context)
        //{
        //    var webLinkableType = webLinkable.GetType();
        //    if (webLinkableType != CreatesLinksFor)
        //    {
        //        context.AddWarning(
        //            string.Format(
        //                @"Trying to add functions to invalid type {0} in LightboxDetailFunctionAppender.  Operation Cancelled",
        //                webLinkableType));
        //        return;
        //    }

        //    var securableObjectPermission =
        //        context.AuthenticatedUser.Permissions.FirstOrDefault(
        //            p => p.SecurableObjectType.Equals(SecurableObjectType.OrgUnit));

        //    webLinkable.Links.Self = "lightbox";

        //    if (securableObjectPermission == null)
        //    {
        //        AddFunctionsToWebLinkable(
        //            f => f.Value.ResourceEndPoints.Contains(endPoint) && f.Value.Permissions == ulong.MaxValue,
        //            webLinkable.Links);

        //        return;
        //    }

        //    AddFunctionsToWebLinkable(
        //        f => f.Value.ResourceEndPoints.Contains(endPoint) && (f.Value.Permissions & securableObjectPermission.Permissions) > 0 || f.Value.Permissions == ulong.MaxValue,
        //        webLinkable.Links);
        //}


        public void AppendFunctionsTo(IWebLinkable webLinkable, ApiResourceEndPoint endPoint, ITestApiContext context)
        {
            var webLinkableType = webLinkable.GetType();

            if (webLinkableType != CreatesLinksFor)
            {
                context.AddWarning(
                    string.Format(
                        @"Trying to add functions to invalid type {0} in LightboxDetailFunctionAppender.  Operation Cancelled",
                        webLinkableType));
                return;
            }

            webLinkable.Links.Self = "tickets";

            AddFunctionsToWebLinkable(
                f => f.Value.ResourceEndPoints.Contains(endPoint) && f.Value.Permissions == ulong.MaxValue,
                webLinkable.Links);
        }