Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
        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
                });
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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
                });
            }
        }
Exemplo n.º 5
0
        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
                });
            }
        }
Exemplo n.º 6
0
        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
                });
            }
        }
Exemplo n.º 7
0
        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();
            }
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
        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 });
        }
Exemplo n.º 10
0
        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 });
        }
Exemplo n.º 11
0
 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 });
 }
Exemplo n.º 12
0
        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 });
        }
Exemplo n.º 13
0
 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 });
 }