Esempio n. 1
0
        public Model.Data.Json.Entry Copy(Entry source, bool copyOptions)
        {
            var destination = new Model.Data.Json.Entry
            {
                Date    = DateAssembler.Copy(source.DateEntry),
                First   = FirstAssembler.Copy(source.First),
                Title   = TitleAssembler.Copy(source.Title),
                Info    = copyOptions ? InfoAssembler.Copy(source.Info) : null,
                Version = source.Version
            };

            if (source.Info != null)
            {
                if (source.Info.Content != null)
                {
                    var imagesOccurrences = CountOccurences(source.Info.OriginalContent, "<image");
                    //var imagesOccurrences = CountOccurences(source.Info.Content, "class='diaryImage'");
                    destination.Images = imagesOccurrences;
                }
            }
            return(destination);
        }
        private XmlNode GetNextNode(string nodeToFind, DiaryDatabase.Model.Data.Xml.Entry entry, ref int indexFound, int currentIndex = 0)
        {
            if (entry.Info == null)
            {
                return(null);
            }

            var woopsStartIndex = entry.Info.OriginalContent.IndexOf("<" + nodeToFind, currentIndex, StringComparison.Ordinal);

            if (woopsStartIndex == -1)
            {
                return(null);
            }

            string endTagName    = string.Format("</{0}>", nodeToFind);
            var    woopsEndIndex = entry.Info.OriginalContent.IndexOf(endTagName, StringComparison.Ordinal) + endTagName.Length;
            var    content       = entry.Info.OriginalContent.Substring(woopsStartIndex, woopsEndIndex - woopsStartIndex);

            var xmlDocument = this.ConvertToXml(content);
            var xPath       = string.Format(@"root//{0}", nodeToFind);

            indexFound = woopsEndIndex;
            return(xmlDocument.SelectSingleNode(xPath));
        }