daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Dec 12th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top