Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.83 KB | None | 0 0
  1. string getAvailableForms()
  2. {
  3.     import extensions.enumeration : staticMembers;
  4.     import asdf; // JSON serializer
  5.     import std.traits : getUDAs, hasUDA;
  6.     import externalPaths : ExternalAppPath, DisplayName;
  7.     import std.algorithm : startsWith;
  8.     import std.conv : to;
  9.  
  10.     FormDisplayNameObj[] output;
  11.     static foreach(string fieldName; staticMembers!ExternalAppPath)
  12.     {{
  13.         static if(hasUDA!(__traits(getMember, ExternalAppPath, fieldName), DisplayName))
  14.         {
  15.             if(fieldName.startsWith(startKey))
  16.             {
  17.                 DisplayName dn = getUDAs!(__traits(getMember, ExternalAppPath, fieldName), DisplayName)[0];
  18.                 string id = extractDigits(fieldName[startKey.length - 1 .. $]);
  19.                 int i  = to!int(id);
  20.                 auto o = new FormDisplayNameObj();
  21.                 o.value = dn.value;
  22.                 o.index = i;
  23.                 output ~= o;
  24.             }
  25.         }
  26.     }}
  27.     return output.serializeToJson;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement