Пример #1
0
     public void WriteAsJson(TextWriter output, string mode, ISerializationAnnotator annotator, bool pretty = false, int level = 0) {
         if (string.IsNullOrWhiteSpace(mode)) {
             mode = "admin";
         }
         var jw = new JsonWriter(output,pretty:pretty,level:level);
         jw.OpenObject();
         jw.WriteProperty("name",Name);
         jw.WriteProperty("isauth",IsAuthenticated);
         jw.WriteProperty("authtype",AuthenticationType);
         jw.WriteProperty("isadmin",IsAdmin,true);
         jw.WriteProperty("isguest",IsGuest,true);
         jw.WriteProperty("iserror",IsError,true);
         jw.WriteProperty("state",State,true);
         jw.WriteProperty("stateinfo",StateInfo,true);
 
             if (null != Token) {
                 jw.OpenProperty("token");
                 jw.WriteNative(Token.stringify(mode));
                 jw.CloseProperty();
             }
         if (null != User) {
             jw.OpenProperty("user");
             jw.WriteNative(User.stringify(mode));
             jw.CloseProperty();
         }
         jw.CloseObject();
     }