Novacode.Paragraph.CreateEdit C# (CSharp) Method

CreateEdit() static private method

Creates an Edit either a ins or a del with the specified content and date
static private CreateEdit ( EditType t, System.DateTime edit_time, object content ) : System.Xml.Linq.XElement
t EditType The type of this edit (ins or del)
edit_time System.DateTime The time stamp to use for this edit
content object The initial content of this edit
return System.Xml.Linq.XElement
        internal static XElement CreateEdit(EditType t, DateTime edit_time, object content)
        {
            if (t == EditType.del)
            {
                foreach (object o in (IEnumerable<XElement>)content)
                {
                    if (o is XElement)
                    {
                        XElement e = (o as XElement);
                        IEnumerable<XElement> ts = e.DescendantsAndSelf(XName.Get("t", DocX.w.NamespaceName));

                        for (int i = 0; i < ts.Count(); i++)
                        {
                            XElement text = ts.ElementAt(i);
                            text.ReplaceWith(new XElement(DocX.w + "delText", text.Attributes(), text.Value));
                        }
                    }
                }
            }

            return
            (
                new XElement(DocX.w + t.ToString(),
                    new XAttribute(DocX.w + "id", 0),
                    new XAttribute(DocX.w + "author", WindowsIdentity.GetCurrent().Name),
                    new XAttribute(DocX.w + "date", edit_time),
                content)
            );
        }