private bool IsAvailableFor(object input) { if (input == null) { return(true); } if (!_cmsContext.CanRender(input, _cmsContext.GetCurrentTheme())) { return(false); } var ensureExists = _container.GetAllInstances(typeof(IEnsureExists <>).MakeGenericType(input.GetType())).OfType <object>().ToList(); var exists = ensureExists.All(x => (bool)x.GetType().GetMethod("Exists", new[] { input.GetType() }).Invoke(x, new[] { input })); if (!exists) { return(false); } var secureInterfaces = input.GetType() .GetInterfaces() .Where(x => x.GenericTypeArguments.Length == 1 && x.GenericTypeArguments[0].CanBeCastTo <ISubApplication>() && x.CanBeCastTo(typeof(IAmSecuredBy <>).MakeGenericType(x.GenericTypeArguments[0]))) .ToList(); return((from secureInterface in secureInterfaces let authenticationContext = _serviceLocator.GetInstance(typeof(IAuthenticationService <>).MakeGenericType(secureInterface.GenericTypeArguments[0])) let user = (AuthenticationInformation)authenticationContext.GetType().GetMethod("GetUser").Invoke(authenticationContext, new object[0]) select _validateSecurity.IsAllowed(user, (SecuredBy)input .GetType() .GetMethod("GetSecuredBy", new[] { secureInterface.GenericTypeArguments[0] }) .Invoke(input, new[] { _serviceLocator.GetInstance(secureInterface.GenericTypeArguments[0]) }))) .All(x => x)); }
public IEnumerable <BreadCrumb> Get(object input) { var amBreadCrumb = input as IAmBreadCrumb; var breadCrumbs = new List <BreadCrumb>(); if (amBreadCrumb == null) { return(breadCrumbs); } var menuContext = new DefaultMenuContext(_fubuRequest, _serviceLocator); while (amBreadCrumb != null) { breadCrumbs.Add(amBreadCrumb.Build(menuContext)); amBreadCrumb = amBreadCrumb.FindParent() as IAmBreadCrumb; } breadCrumbs.Reverse(); breadCrumbs = _cmsContext.Filter(breadCrumbs, _cmsContext.GetCurrentTheme()).ToList(); return(new ReadOnlyCollection <BreadCrumb>(breadCrumbs)); }
public void Write(string mimeType, T resource) { var renderResult = _cmsRenderer.RenderEndpoint(resource, _cmsContext, _cmsContext.GetCurrentTheme()); _writer.Write(renderResult.ContentType, x => { var writer = new StreamWriter(x); renderResult.RenderTo(writer); writer.Flush(); }); }