Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • glenatron 37 posts 132 karma points
    Apr 03, 2017 @ 11:13
    glenatron
    0

    Find the list of IAction letters/aliases

    Is there an easy way to get the Letter and Alias properties from all the available "IAction" implementations in Umbraco?

    I'm trying to do some fairly deep permissions integration and it would be really useful to have an easy way of finding what all the permissions letters mean.

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Apr 03, 2017 @ 12:39
    Dan Diplo
    0

    A very quick'n'dirty way would be use reflection. If you bung the following in a razor script it will get you some of the way:

     var type = typeof(umbraco.interfaces.IAction);
        var types = AppDomain.CurrentDomain.GetAssemblies()
            .SelectMany(s => s.GetTypes())
            .Where(p => type.IsAssignableFrom(p) && p.IsClass);
    
    
        foreach (var myType in types)
        {
          <h3>@myType</h3>
    
            try
            {
                var instance = Activator.CreateInstance(myType) as umbraco.interfaces.IAction;
    
                <p>Alias: @instance.Alias Letter: @instance.Letter</p>
            }
        catch { }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies