Beispiel #1
0
        /// <summary>
        /// adds the entry output data to the intent to be sent to a plugin
        /// </summary>
        public static void AddEntryToIntent(Intent intent, PwEntryOutput entry)
        {
            /*//add the entry XML
            not yet implemented. What to do with attachments?
            MemoryStream memStream = new MemoryStream();
            KdbxFile.WriteEntries(memStream, new[] {entry});
            string entryData = StrUtil.Utf8.GetString(memStream.ToArray());
            intent.PutExtra(Strings.ExtraEntryData, entryData);
            */
            //add the output string array (placeholders replaced taking into account the db context)
            Dictionary<string, string> outputFields = entry.OutputStrings.ToDictionary(pair => StrUtil.SafeXmlString(pair.Key), pair => pair.Value.ReadString());

            JSONObject jsonOutput = new JSONObject(outputFields);
            var jsonOutputStr = jsonOutput.ToString();
            intent.PutExtra(Strings.ExtraEntryOutputData, jsonOutputStr);

            JSONArray jsonProtectedFields = new JSONArray(
                (System.Collections.ICollection)entry.OutputStrings
                    .Where(pair => pair.Value.IsProtected)
                    .Select(pair => pair.Key)
                    .ToArray());
            intent.PutExtra(Strings.ExtraProtectedFieldsList, jsonProtectedFields.ToString());

            intent.PutExtra(Strings.ExtraEntryId, entry.Uuid.ToHexString());
        }
Beispiel #2
0
        public static string ToJsonString(this ulong[] objs)
        {
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put(obj.ToString());
            }

            return array.ToString();
        }
Beispiel #3
0
        public static string ToJsonString(this TimeSpan[] objs)
        {
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put(JsonConvert.ToString(obj));
            }

            return array.ToString();
        }
Beispiel #4
0
        public static string ToJsonString(this float[] objs)
        {
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put((double)obj);
            }

            return array.ToString();
        }
Beispiel #5
0
        public static string ToJsonString(this short[] objs)
        {
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put((long)obj);
            }

            return array.ToString();
        }
Beispiel #6
0
        public static string ToJsonString(this byte[] objs)
        {
            //TODO: byte array is a special one, convert to base64?
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put((int)obj);
            }

            return array.ToString();
        }
 protected static Stream GetStream(JSONArray jsonArray)
 {
     var json = jsonArray.ToString();
     return GetStream(json);
 }