static void Main(string[] args) { var rawFeeds = new[] { FeedReader.Read("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml") }; var feeds = rawFeeds.Select(feed => new { feed.Title, Items = feed.Items.Select(item => new { item.Title, item.Content }).ToArray() }).ToArray(); using (var luaWriter = LuaWriter.Create("SavedVariables.lua", new LuaWriterSettings { Indent = true })) { var luaSerializer = new LuaSerializer(); luaWriter.WriteStartAssignment("FEED_READER_FEEDS"); luaSerializer.Serialize(luaWriter, feeds); luaWriter.WriteEndAssignment(); } }
public void SetUp() { stringBuilder = new StringBuilder(); luaWriter = LuaWriter.Create(stringBuilder); luaSerializer = new LuaSerializer(); }
/// <summary> /// Text is either import string or name of the WeakAura. /// </summary> public WeakAura(string text) { if (text.StartsWith("!")) { var table = text.DecompressToLuaTable(); Table = LuaSerializer.Deserialize <WeakAuraTable>(table); } else { Table = WeakAuraTable.Generate(text); } }
public void SaveFeeds() { Feed[] feeds = this.GetTopLevelFeeds(); if (feeds != null) { using (var luaWriter = LuaWriter.Create(savedVariablesPath)) { var luaSerializer = new LuaSerializer(); luaWriter.WriteStartAssignment(feedsVariableName); luaSerializer.Serialize(luaWriter, feeds); luaWriter.WriteEndAssignment(); } } }
// Use this for initialization void Start() { Dictionary <string, string> dic = new Dictionary <string, string>(); dic["a"] = "aaaa"; dic["b"] = "bbbb"; dic["c"] = "cccc"; string lua = LuaSerializer.Serialize(dic); Debug.Log(lua); List <ushort> sList = new List <ushort>() { 1, 2, 0, 3, 4 }; string sLua = LuaSerializer.Serialize(sList); Debug.Log(sLua); MyClass myClass = new MyClass("myclass", 20); Debug.Log(LuaSerializer.Serialize(myClass)); }
public void TestTable() { var reg = new MessageRegistry(); var a = new LuaSerializer(reg, LuaTypeRegistry.CreateDefault()); var ser = new DefaultSerializer<SubMessage>(reg, TypeRegistry.CreateDefault()); using (var buf = new ThreadSafeWriteQueue(1024)) { var dictionary = new Dictionary<LuaObject, LuaObject> { }; dictionary.Add(LuaObject.FromString("MessageId"), LuaObject.FromNumber(ser.MessageId)); var table = LuaObject.FromTable(dictionary); table[LuaObject.FromString("Text")] = LuaObject.FromString("abc"); a.Send(buf, table); int pos = buf.ReadMessage(); var id = buf.ReadInt32(pos); Assert.AreEqual(ser.MessageId, id); var table2 = a.Receive(buf, pos); Assert.AreEqual(ser.MessageId, table2[LuaObject.FromString("MessageId")].AsNumber()); Assert.AreEqual(table[LuaObject.FromString("Text")].AsString(), table2[LuaObject.FromString("Text")].AsString()); } }
public void InitializeSerializer() { Serializer = new LuaSerializer(); Stopwatch = new Stopwatch(); }
public override string Serialize() { return(LuaSerializer.SerializeTable(InternalTable)); }
public LuaTable ToLuaTable() => LuaSerializer.Serialize(Table);
public WeakAura(LuaTable table) { Table = LuaSerializer.Deserialize <WeakAuraTable>(table); }