コード例 #1
0
        public void WriteStructs()
        {
            var w = JWriter.New();

            WriteStructs(w, ListOfStructs);
            var s = w.GetString();
        }
コード例 #2
0
 internal DataKind(
     string name,
     SerializerToJWriter internalSerializer,
     DeserializerFromJReader internalDeserializer)
 {
     _name = name;
     _internalSerializer   = internalSerializer;
     _internalDeserializer = internalDeserializer;
     _serializer           = item =>
     {
         var w = JWriter.New();
         if (item.Item is null)
         {
             var obj = w.Object();
             obj.Name("version").Int(item.Version);
             obj.Name("deleted").Bool(true);
             obj.End();
         }
         else
         {
             internalSerializer(item.Item, w);
         }
         return(w.GetString());
     };
     _deserializer = s =>
     {
         var r = JReader.FromString(s);
         return(_internalDeserializer(ref r));
     };
 }
コード例 #3
0
ファイル: ReadWriter.cs プロジェクト: olessuah/OOPSZI
        static public void Write(T data)
        {
            string current_data;

            try
            {
                current_data = File.ReadAllText(path, Encoding.Default);

                using (StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.Default))
                {
                    if (data != null)
                    {
                        sw.WriteLine(JWriter <T> .Write(data, current_data));
                    }
                    else
                    {
                        sw.WriteLine();
                    }
                }
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(ex.Message);
            }
        }
コード例 #4
0
        public void WriteBools()
        {
            var w = JWriter.New();

            WriteBools(w, ListOfBools);
            var s = w.GetString();
        }
コード例 #5
0
        public string SerializeOutputEvents(object[] events, EventSummary summary, out int eventCountOut)
        {
            var jsonWriter = JWriter.New();
            var scope      = new EventOutputFormatterScope(_config, jsonWriter, _config.InlineUsersInEvents);

            eventCountOut = scope.WriteOutputEvents(events, summary);
            return(jsonWriter.GetString());
        }
コード例 #6
0
        public async Task <IActionResult> Export()
        {
            try
            {
                using (StreamWriter sw = new StreamWriter("DataFile.json", false, System.Text.Encoding.Default))
                {
                    sw.WriteLine(JWriter <List <PoliceStationInfo> > .Write(await db.PoliceStations.Include(s => s.PublicPhone).ToListAsync()));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(Ok("Данные экспортированны в формат .json"));
        }
コード例 #7
0
        /// <summary>
        /// Converts the value to its JSON encoding.
        /// </summary>
        /// <remarks>
        /// For instance, <c>LdValue.Of(1).ToJsonString()</c> returns <c>"1"</c>;
        /// <c>LdValue.Of("x").ToJsonString()</c> returns <c>"\"x\""</c>; and
        /// <c>LdValue.Null.ToJsonString()</c> returns <c>"null"</c>.
        /// </remarks>
        /// <returns>the JSON encoding of the value</returns>
        /// <see cref="Parse(string)"/>
        public string ToJsonString()
        {
            switch (_type)
            {
            case LdValueType.Null:
                return("null");

            case LdValueType.Bool:
                return(_boolValue ? "true" : "false");

            default:
                var writer = JWriter.New();
                LdJsonConverters.LdValueConverter.WriteJsonValue(this, writer);
                return(writer.GetString());
            }
        }
コード例 #8
0
        internal static string MakeJsonData(FullDataSet data)
        {
            var w = JWriter.New();

            using (var ow = w.Object())
            {
                foreach (var item in data.Items)
                {
                    if (item.Value.Item != null)
                    {
                        FeatureFlagJsonConverter.WriteJsonValue(item.Value.Item, ow.Name(item.Key));
                    }
                }
            }
            return(w.GetString());
        }
コード例 #9
0
        /// <summary>
        /// Returns a JSON representation of the user index.
        /// </summary>
        /// <returns>the JSON representation</returns>
        public string Serialize()
        {
            var w = JWriter.New();

            using (var aw0 = w.Array())
            {
                foreach (var e in Data)
                {
                    using (var aw1 = aw0.Array())
                    {
                        aw1.String(e.UserId);
                        aw1.Long(e.Timestamp.Value);
                    }
                }
            }
            return(w.GetString());
        }
コード例 #10
0
 public async Task <IActionResult> Show()
 {
     return(Ok(JWriter <List <PoliceStationInfo> > .Write(await db.PoliceStations.Include(s => s.PublicPhone).ToListAsync())));
 }
コード例 #11
0
ファイル: DataController.cs プロジェクト: AlexPriahin/PZ
 public async Task <IActionResult> Show()
 {
     return(Ok(JWriter <List <TransportNodeInfo> > .Write(await db.TransportNodes.ToListAsync())));
 }
コード例 #12
0
 public async Task <IActionResult> Show()
 {
     return(Ok(JWriter <List <PriorityproductInfo> > .Write(await db.Priorityproducts.ToListAsync())));
 }
コード例 #13
0
ファイル: DataController.cs プロジェクト: tony69084/PZ-OOP
 public async Task <IActionResult> Show()
 {
     return(Ok(JWriter <List <FootballFieldInfo> > .Write(await db.FootballFields.Include(s => s.WorkingHoursWinter).ToListAsync())));
 }
コード例 #14
0
 public async Task <IActionResult> Show()
 {
     return(Ok(JWriter <List <RestroomInfo> > .Write(await db.Place.Include(s => s.WorkingHours).ToListAsync())));
 }
コード例 #15
0
 public EventOutputFormatterScope(EventsConfiguration config, JWriter jw, bool inlineUsers)
 {
     _config     = config;
     _jsonWriter = jw;
     _obj        = new ObjectWriter();
 }
コード例 #16
0
 public async Task <IActionResult> Show()
 {
     return(Ok(JWriter <List <HotelInfo> > .Write(await db.Hotels.Include(s => s.ContactPhone).ToListAsync())));
 }
コード例 #17
0
 public async Task <IActionResult> Show()
 {
     return(Ok(JWriter <List <CompetitionsListInfo> > .Write(await db.CompetitionsLists.Include(s => s.WebSite).ToListAsync())));
 }