/// <summary> /// Provides a mechanism for releasing unmanaged resources. /// </summary> public void Dispose() { if (!_LeaveOpen) { BaseWriter?.Close(); } BaseWriter = null; }
/// <summary> /// Closes this stream and the underlying stream. /// </summary> public override void Close() { base.Close(); if (CloseOutput) { _writer?.Close(); } }
/// <inheritdoc /> public override void Close() => _writer.Close();
internal void GltfSerialize(JsonWriter writer) { writer.AddObject(); writer.Close(); throw new System.NotImplementedException($"GltfSerialize missing on {GetType()}"); }
public override void Close() { inner.Close(); }
/// <summary> /// Dispose underlying JSON writer. /// </summary> public override void Dispose() { _jsonWriter.Close(); ((IDisposable)_jsonWriter).Dispose(); base.Dispose(); }
static void Main(string[] args) { FileInfo assemblyFileInfo = new FileInfo(args[0]); string savePath = args[1]; DirectoryInfo fireMLDirInfo = assemblyFileInfo.Directory; DirectoryInfo contentDirInfo = fireMLDirInfo.Parent; List <string> plotFileList = new List <string>(); List <string> assetFileList = new List <string>(); foreach (FileInfo fileInfo in fireMLDirInfo.GetFiles("*.*", SearchOption.AllDirectories)) { string ext = fileInfo.Extension; if (ext == ".fmlplot") { plotFileList.Add(fileInfo.FullName); } else if (ext == ".fmlasset") { assetFileList.Add(fileInfo.FullName); } } string xsdDirPath = fireMLDirInfo.FullName + "\\" + "XSD"; //FireEngine.XNAContent.ContentManager contentManager = new FireEngine.XNAContent.ContentManager(contentDirInfo.FullName); CompilerKernel kernel = new CompilerKernel(plotFileList.ToArray(), assetFileList.ToArray(), xsdDirPath, null /*contentManager*/); FireMLRoot result = kernel.CompileFireML(); Error[] errors = kernel.CheckPoint(); foreach (Error e in errors) { Console.WriteLine("{0}\n{1},{2}\n{3}", e.Location.FileName, e.Location.Line, e.Location.Column, e.Message); Console.WriteLine(); } if (errors.Length > 0) { Environment.Exit(-1); return; } Stream bsonStream = new FileStream(savePath, FileMode.Create); BsonBuffer bsonBuffer = new BsonBuffer(); BsonBinaryWriterSettings bsonSettings = new BsonBinaryWriterSettings(); BsonBinaryWriter bsonWriter = new BsonBinaryWriter(bsonStream, bsonBuffer, bsonSettings); BsonSerializer.Serialize <FireMLRoot>(bsonWriter, result); bsonWriter.Close(); JsonWriterSettings jsonSettings = new JsonWriterSettings(); jsonSettings.NewLineChars = "\r\n"; jsonSettings.OutputMode = JsonOutputMode.JavaScript; jsonSettings.Indent = true; jsonSettings.IndentChars = " "; StreamWriter streamWriter = new StreamWriter(new FileStream(savePath + ".json", FileMode.Create)); JsonWriter jsonWriter = new JsonWriter(streamWriter, jsonSettings); BsonSerializer.Serialize <FireMLRoot>(jsonWriter, result); jsonWriter.Close(); }
public override string BuildJson(int indicator = 0) { /* { * "Action":1/2/4, * "ItemId":"PBT=[Usernames]", "ItemId": "PBT=[MCBCustomers] mcb.ID=[70c0b27f-8151-4f3a-8fcf-a8a8381823b4] mcb.DT=[2015-01-07 13:13:04.660]", * "Properties": * [ * {"IsNull":false,"Modified":true/false,"Name":"Username","Value":"newuser54"}, * {"IsNull":false,"Modified":true/false,"Name":"EditLevel","Value":"2"}, * {"IsNull":false,"Modified":true/false,"Name":"UserDesc","Value":"user description"}, * {"IsNull":false,"Modified":true/false,"Name":"SuperUserFlag","Value":"1"} * ] * } */ string output = ""; StringWriter writer = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(writer); if (string.IsNullOrEmpty(iResult.IDOName)) { return(""); } jsonWriter.BeginObject(); jsonWriter.Name("Action").Value(indicator); switch (indicator) { case 1: jsonWriter.Name("ItemId").Value(string.Format("PBT=[{0}]", iResult.IDOName)); break; case 2: case 4: string.Format("PBT=[{0}] {0}.DT=[{1}] {0}.ID=[{2}]", iResult.IDOName, "", ""); break; default: break; } jsonWriter.Name("Properties"); jsonWriter.BeginArray(); foreach (BaseIDOObject obj in iResult.Objects) { if (((indicator == 1) && (!obj.Inserted)) || ((indicator == 2) && (obj.Inserted || obj.Deleted)) || ((indicator == 4) && (!obj.Deleted))) { continue; } foreach (BaseIDOObjectItem objitem in obj.ObjectItems) { jsonWriter.BeginObject(); jsonWriter.Name("IsNull").Value((string.IsNullOrEmpty(objitem.ItemValue) ? true : false)); jsonWriter.Name("Modified").Value(objitem.Updated); jsonWriter.Name("Name").Value(objitem.ItemName); jsonWriter.Name("Value").Value(objitem.ItemValue); jsonWriter.EndObject(); } } jsonWriter.EndObject(); jsonWriter.EndArray(); jsonWriter.EndObject(); jsonWriter.Flush(); jsonWriter.Close(); output = writer.ToString(); return(output); }
private string GetVoteInfo(HttpContext context) { NameValueCollection nv = GetParas(context); int voiteId = int.Parse(nv["voteid"]); Vote.BLL.VoteTopic vtbll = new NoName.NetShop.Vote.BLL.VoteTopic(); Vote.BLL.VoteItemGroup vgbll = new NoName.NetShop.Vote.BLL.VoteItemGroup(); Vote.BLL.VoteItem vibll = new NoName.NetShop.Vote.BLL.VoteItem(); StringBuilder sb = new StringBuilder(200); JsonWriter jw = new JsonWriter(new StringWriter(sb)); Vote.Model.VoteTopic vtmodel = vtbll.GetModel(voiteId); List <Vote.Model.VoteItemGroup> vgmodels = vgbll.GetModelList(voiteId); List <Vote.Model.VoteItem> vimodels = vibll.GetItemsOfVote(voiteId); if (vtmodel != null && vtmodel.StartTime < DateTime.Now && vtmodel.EndTime > DateTime.Now && vtmodel.Status == true) { jw.WriteStartObject(); jw.WritePropertyName("voteid"); jw.WriteValue(vtmodel.VoteId); jw.WritePropertyName("topic"); jw.WriteValue(vtmodel.Topic); jw.WritePropertyName("votenum"); jw.WriteValue(vtmodel.VoteUserNum); jw.WritePropertyName("ismulti"); jw.WriteValue(vtmodel.IsMulti); jw.WritePropertyName("groupcount"); jw.WriteValue(vgmodels.Count); if (vgmodels.Count > 0) { jw.WritePropertyName("groups"); jw.WriteStartArray(); foreach (Vote.Model.VoteItemGroup vgmodel in vgmodels) { jw.WriteStartObject(); jw.WritePropertyName("subject"); jw.WriteValue(vgmodel.Subject); jw.WritePropertyName("groupid"); jw.WriteValue(vgmodel.ItemGroupId); jw.WritePropertyName("items"); jw.WriteStartArray(); foreach (Vote.Model.VoteItem vitem in vimodels.Where(s => s.ItemGroupId == vgmodel.ItemGroupId)) { jw.WriteStartObject(); jw.WritePropertyName("itemid"); jw.WriteValue(vitem.ItemId); jw.WritePropertyName("subject"); jw.WriteValue(vitem.ItemContent); jw.WritePropertyName("count"); jw.WriteValue(vitem.VoteCount); jw.WritePropertyName("percent"); jw.WriteValue(vitem.Percent); jw.WriteEndObject(); } jw.WriteEndArray(); jw.WriteEndObject(); } jw.WriteEndArray(); } jw.WriteEndObject(); jw.Close(); } return(sb.ToString()); }
internal void GltfSerialize(JsonWriter writer) { writer.AddObject(); writer.Close(); }
public void Dispose() { _jsonWriter.Close(); }
public virtual void GltfSerialize(JsonWriter writer) { writer.AddObject(); GltfSerializeTextureInfo(writer); writer.Close(); }
public void Dispose() { _jsonWriter.WriteEndArray(); _jsonWriter.Close(); }
public override void Close() { _innerWriter.Close(); }
public void Finish() { writer.WriteEndArray(); writer.WriteEndObject(); writer.Close(); }
protected override void DisposeManaged() { m_writer.Close(); }
//protected override void WriteIndentSpace() //{ // _textWriter.WriteIndentSpace(); // _innerWriter.WriteIndentSpace(); // base.WriteIndentSpace(); //} public override void Close() { _textWriter.Close(); _innerWriter.Close(); base.Close(); }
public void Finish() //write to JSON log file and close writer { writer.WriteEndArray(); writer.WriteEndObject(); writer.Close(); }
public void Dispose() { _writer?.Close(); _streamWriter?.Dispose(); _stream?.Dispose(); }
public void Dispose() => _instance.Close();