public void Save(string route, MeekContent content) { var caseSensitiveKey = Content.Select(x => x.Key).FirstOrDefault(x => x.ToLower() == route.ToLower()); if (!string.IsNullOrEmpty(caseSensitiveKey)) Content[caseSensitiveKey] = content; else Content.Add(route, content); }
public void Save(string route, MeekContent content) { //enforce keys to lower for querying Content.Save(new { Id = route.ToLower(), content.Title, content.Partial, content.Contents }); if (ContentChanged != null) { ContentChanged(this, new ResourceChangedArgs { Path = route }); } }
public void Save(string route, MeekContent content) { var caseSensitiveKey = Content.Select(x => x.Key).FirstOrDefault(x => x.ToLower() == route.ToLower()); if (!string.IsNullOrEmpty(caseSensitiveKey)) { Content[caseSensitiveKey] = content; } else { Content.Add(route, content); } }
public void Save(string route, MeekContent content) { var parent = DataFile.Element("Meek"); var element = parent.Elements("content").SingleOrDefault(ByRoute(route)); string fileKey; if (element == null) { fileKey = Guid.NewGuid().ToString(); var newElement = new XElement("content"); newElement.Add(new XAttribute("route", route)); newElement.Add(new XAttribute("fileName", fileKey)); newElement.Add(new XAttribute("partial", content.Partial.ToString())); if (!string.IsNullOrEmpty(content.Title)) { newElement.Add(new XAttribute("title", content.Title)); } parent.Add(newElement); } else { fileKey = element.Attribute("fileName").Value; element.SetAttributeValue("title", content.Title); element.SetAttributeValue("partial", content.Partial.ToString()); } var stream = File.CreateText(Path.Combine(_baseDir, fileKey)); var binaryWriter = new BinaryWriter(stream.BaseStream); var contentBytes = Encoding.UTF8.GetBytes(content.Contents); binaryWriter.Write(contentBytes, 0, contentBytes.Length); stream.Close(); DataFile = parent.Document; if (ContentChanged != null) { ContentChanged(this, new ResourceChangedArgs { Path = route }); } }
public void Save(string route, MeekContent content) { string commandText; if (Exists(route)) { commandText = "UPDATE MeekContent SET Title = @Title, Partial = @Partial, Data = @Data WHERE Route = @Route"; } else { commandText = "INSERT INTO MeekContent (Route, Title, Partial, Data) Values (@Route, @Title, @Partial, @Data)"; } using (var conn = OpenConnection()) { var command = _factory.CreateCommand(); command.Connection = conn; command.CommandText = commandText; AddParam(command, SqlDbType.NVarChar, route, "Route"); if (string.IsNullOrEmpty(content.Title)) { AddParam(command, SqlDbType.NVarChar, DBNull.Value, "Title"); } else { AddParam(command, SqlDbType.NVarChar, content.Title, "Title"); } AddParam(command, SqlDbType.Bit, content.Partial, "Partial"); AddParam(command, SqlDbType.NVarChar, content.Contents, "Data"); command.ExecuteNonQuery(); } if (ContentChanged != null) { ContentChanged(this, new ResourceChangedArgs { Path = route }); } }
public void Save(string route, MeekContent content) { var caseSensitiveKey = Content.Select(x => x.Key).FirstOrDefault(x => x.ToLower() == route.ToLower()); if (!string.IsNullOrEmpty(caseSensitiveKey)) { Content[caseSensitiveKey] = content; } else { Content.Add(route, content); } if (ContentChanged != null) { ContentChanged(this, new ResourceChangedArgs { Path = route }); } }
public void Save(string route, MeekContent content) { string commandText; if (Exists(route)) commandText = "UPDATE MeekContent SET Title = @Title, Partial = @Partial, Data = @Data WHERE Route = @Route"; else commandText = "INSERT INTO MeekContent (Route, Title, Partial, Data) Values (@Route, @Title, @Partial, @Data)"; using (var conn = OpenConnection()) { var command = _factory.CreateCommand(); command.Connection = conn; command.CommandText = commandText; AddParam(command, SqlDbType.NVarChar, route, "Route"); if (string.IsNullOrEmpty(content.Title)) AddParam(command, SqlDbType.NVarChar, DBNull.Value, "Title"); else AddParam(command, SqlDbType.NVarChar, content.Title, "Title"); AddParam(command, SqlDbType.Bit, content.Partial, "Partial"); AddParam(command, SqlDbType.NVarChar, content.Contents, "Data"); command.ExecuteNonQuery(); } }
public void Save(string route, MeekContent content) { var parent = DataFile.Element("Meek"); var element = parent.Elements("content").SingleOrDefault(ByRoute(route)); string fileKey; if (element == null) { fileKey = Guid.NewGuid().ToString(); var newElement = new XElement("content"); newElement.Add(new XAttribute("route", route)); newElement.Add(new XAttribute("fileName", fileKey)); newElement.Add(new XAttribute("partial", content.Partial.ToString())); if (!string.IsNullOrEmpty(content.Title)) newElement.Add(new XAttribute("title", content.Title)); parent.Add(newElement); } else { fileKey = element.Attribute("fileName").Value; element.SetAttributeValue("title", content.Title); element.SetAttributeValue("partial", content.Partial.ToString()); } var stream = File.CreateText(Path.Combine(_baseDir, fileKey)); var binaryWriter = new BinaryWriter(stream.BaseStream); var contentBytes = Encoding.UTF8.GetBytes(content.Contents); binaryWriter.Write(contentBytes, 0, contentBytes.Length); stream.Close(); DataFile = parent.Document; }
public void Save(string route, MeekContent content) { var caseSensitiveKey = Content.Select(x => x.Key).FirstOrDefault(x => x.ToLower() == route.ToLower()); if (!string.IsNullOrEmpty(caseSensitiveKey)) Content[caseSensitiveKey] = content; else Content.Add(route, content); if (ContentChanged != null) ContentChanged(this, new ResourceChangedArgs { Path = route }); }
public void Save(string route, MeekContent content) { EnsureFolder(RouteToFolderPath(route)); File.WriteAllText(RouteToContentsPath(route), content.Contents); File.WriteAllLines(RouteToPropertiesPath(route), new[] { "Title: " + (content.Title ?? "").Replace(Environment.NewLine, @"<br/>"), "Partial: " + content.Partial }); var e = ContentChanged; if (e != null) e(this, new ResourceChangedArgs { Path = route }); }
public void Save(string route, MeekContent content) { //enforce keys to lower for querying Content.Save(new { Id = route.ToLower(), content.Title, content.Partial, content.Contents }); }
public void Save(string route, MeekContent content) { //enforce keys to lower for querying Content.Save(new { Id = route.ToLower(), content.Title, content.Partial, content.Contents }); if (ContentChanged != null) ContentChanged(this, new ResourceChangedArgs { Path = route }); }