示例#1
0
        public Chart()
        {
            Xml      = XDocument.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n                   <c:chartSpace xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">  \r\n                       <c:roundedCorners val=\"0\"/>\r\n                       <c:chart>\r\n                           <c:autoTitleDeleted val=\"0\"/>\r\n                           <c:plotVisOnly val=\"1\"/>\r\n                           <c:dispBlanksAs val=\"gap\"/>\r\n                           <c:showDLblsOverMax val=\"0\"/>\r\n                       </c:chart>\r\n                   </c:chartSpace>");
            ChartXml = CreateChartXml();
            XElement xElement = new XElement(XName.Get("plotArea", DocX.c.NamespaceName), new XElement(XName.Get("layout", DocX.c.NamespaceName)), ChartXml);
            XElement content  = XElement.Parse("<c:dLbls xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\">\r\n                    <c:showLegendKey val=\"0\"/>\r\n                    <c:showVal val=\"0\"/>\r\n                    <c:showCatName val=\"0\"/>\r\n                    <c:showSerName val=\"0\"/>\r\n                    <c:showPercent val=\"0\"/>\r\n                    <c:showBubbleSize val=\"0\"/>\r\n                    <c:showLeaderLines val=\"1\"/>\r\n                </c:dLbls>");

            ChartXml.Add(content);
            if (IsAxisExist)
            {
                CategoryAxis = new CategoryAxis("148921728");
                ValueAxis    = new ValueAxis("154227840");
                XElement content2  = XElement.Parse($"<c:axId val=\"{CategoryAxis.Id}\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"/>");
                XElement content3  = XElement.Parse($"<c:axId val=\"{ValueAxis.Id}\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"/>");
                XElement xElement2 = ChartXml.Element(XName.Get("gapWidth", DocX.c.NamespaceName));
                if (xElement2 != null)
                {
                    xElement2.AddAfterSelf(content3);
                    xElement2.AddAfterSelf(content2);
                }
                else
                {
                    ChartXml.Add(content2);
                    ChartXml.Add(content3);
                }
                xElement.Add(CategoryAxis.Xml);
                xElement.Add(ValueAxis.Xml);
            }
            ChartRootXml = Xml.Root.Element(XName.Get("chart", DocX.c.NamespaceName));
            ChartRootXml.Element(XName.Get("autoTitleDeleted", DocX.c.NamespaceName)).AddAfterSelf(xElement);
        }
        private XElement ProcessItemIfElement(TableElement itemIfElement, DataReader dataReader, int index, XElement previous)
        {
            bool condition;

            try
            {
                condition = bool.Parse(dataReader.ReadText(itemIfElement.Expression));
            }
            catch (FormatException)
            {
                condition = false;
            }
            catch (System.Xml.XPath.XPathException)
            {
                condition = false;
            }
            var currentCell = itemIfElement.StartTag.Ancestors().First(element => element.Name == WordMl.TableCellName);

            if (condition)
            {
                this.ProcessElements(itemIfElement.TagElements, dataReader, index, previous, false);
                itemIfElement.StartTag.Remove();
                itemIfElement.EndTag.Remove();

                if (previous != null && !previous.Equals(currentCell))
                {
                    currentCell.Remove();
                    previous.AddAfterSelf(currentCell);
                }
            }
            else
            {
                this.CleanUp(itemIfElement.StartTag, itemIfElement.EndTag);
                if (!currentCell.Elements(WordMl.ParagraphName).Any())
                {
                    currentCell.Add(new XElement(WordMl.ParagraphName));
                }

                if (previous != null && !previous.Equals(currentCell))
                {
                    currentCell.Remove();
                    previous.AddAfterSelf(currentCell);
                }
                else if (previous == null)
                {
                    var parentRow = currentCell.Parent;
                    currentCell.Remove();
                    parentRow.Add(currentCell);
                }
            }
            return(currentCell);
        }
示例#3
0
        public bool Execute(string packageName, XElement xmlData)
        {
            string path = IOHelper.MapPath("~/Web.config");

            try {
                // Load the XML document
                XDocument document = XDocument.Load(path, LoadOptions.PreserveWhitespace);

                // Locate the <module> element
                XElement modules = document.Root.XPathSelectElement("//configuration/system.webServer/modules");
                if (modules == null)
                {
                    throw new Exception("<modules> element not found.");
                }

                // Stop execution if the module has already been added
                XElement redirectsModule = modules.XPathSelectElement($"add[@name='{ModuleAlias}']");
                if (redirectsModule != null)
                {
                    return(true);
                }

                // Attempt to find "UmbracoModule"
                XElement xmlUmbracoModule = modules.XPathSelectElement("add[@name='UmbracoModule']");
                if (xmlUmbracoModule == null)
                {
                    throw new Exception("'UmbracoModule' HTTP module not found.");
                }

                // Add the redirects module right after "UmbracoModule"
                xmlUmbracoModule.AddAfterSelf(new XElement(
                                                  "add",
                                                  new XAttribute("name", ModuleAlias),
                                                  new XAttribute("type", "Skybrud.Umbraco.Redirects.Routing.RedirectsModule, Skybrud.Umbraco.Redirects")
                                                  ));

                // Then add the <remove> element right after the "UmbracoModule" (so it's before the <add> element)
                xmlUmbracoModule.AddAfterSelf(new XElement(
                                                  "remove",
                                                  new XAttribute("name", ModuleAlias)
                                                  ));

                // Save the document
                document.Save(path);

                return(true);
            } catch (Exception ex) {
                Current.Logger.Error <AddRedirectsModuleAction>("Failed adding redirects HTTP module", ex);

                return(false);
            }
        }
示例#4
0
        public void AddTagsNoWebConfig()
        {
            //Verificar se ja adicionou o nuget (Verifica se tem a tag Membership)
            //Caso tenha adicionado, é só alterar os application name e colocar outro atributos nas tags
            XElement webConfig = XElement.Load(_ParametroTO.Pasta + "\\Web.config");

            XElement systemWeb      = webConfig.Element(XName.Get("system.web"));
            XElement profile        = systemWeb.Element(XName.Get("profile"));
            XElement membership     = systemWeb.Element(XName.Get("membership"));
            XElement role           = systemWeb.Element(XName.Get("roleManager"));
            XElement authentication = systemWeb.Element(XName.Get("authentication"));
            XElement authorization  = systemWeb.Element(XName.Get("authorization"));

            List <XElement> locations = webConfig.Elements(XName.Get("location")).ToList();

            XElement connectionString = webConfig.Element(XName.Get("connectionStrings"));

            Set_SystemWebProfileElements(profile);
            Set_SystemWebMembershipElements(membership);
            Set_SystemWebRoleElements(role);

            if (authentication == null)
            {
                systemWeb.Add(XElement.Parse(Get_SystemWebAutenticationElements()));
            }
            if (authorization == null)
            {
                systemWeb.Add(XElement.Parse(Get_SystemWebAuthorizationElements()));
            }

            if (locations.Count > 0)
            {
                foreach (var location in locations)
                {
                    if (location.Attribute(XName.Get("path")).Value.Equals("Account/Forgot"))
                    {
                        location.Remove();
                    }
                    if (location.Attribute(XName.Get("path")).Value.Equals("Account/InstalarSistema"))
                    {
                        location.Remove();
                    }
                }
            }
            systemWeb.AddAfterSelf(XElement.Parse(Get_LocationsForgotElements()));
            systemWeb.AddAfterSelf(XElement.Parse(Get_LocationInstalarSistemaElements()));

            Set_ConnectionString(connectionString);

            webConfig.Save(_ParametroTO.Pasta + "\\Web.config");
        }
示例#5
0
        public void InvalidNodeTypes()
        {
            runWithEvents = (bool)Params[0];
            var      root     = new XElement("root", new XAttribute("a", "b"), new XElement("here"), "tests");
            var      rootCopy = new XElement(root);
            XElement elem     = root.Element("here");

            object[] nodes = { new XAttribute("xx",      "yy"), new XDocument(),
                               new XDocumentType("root", null,  null, null) };

            if (runWithEvents)
            {
                eHelper = new EventsHelper(elem);
            }
            foreach (object o in nodes)
            {
                try
                {
                    elem.AddAfterSelf(o);
                    if (runWithEvents)
                    {
                        eHelper.Verify(XObjectChange.Add, o);
                    }
                    TestLog.Compare(false, "Should fail!");
                }
                catch (Exception)
                {
                    TestLog.Compare(XNode.DeepEquals(root, rootCopy), "root.Equals(rootCopy)");
                }
            }
        }
示例#6
0
        private void toolStripMenuItemTableCreate_Click(object sender, EventArgs e)
        {
            List <string> tables = new List <string>();

            foreach (var item in listBoxTables.Items)
            {
                tables.Add(item.ToString());
            }
            var dialog = new FormTableName(string.Empty, tables);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                XElement previousElement = _document.GetElementToAddAfterSelf("CustomTable");
                XElement newElement      = new XElement(ns + "CustomTable", new XAttribute("Id", dialog.TableName),
                                                        new XElement(ns + "Column",
                                                                     new XAttribute("Id", "Id"),
                                                                     new XAttribute("Category", "Identifier"),
                                                                     new XAttribute("PrimaryKey", "yes"),
                                                                     new XAttribute("Nullable", "no"),
                                                                     new XAttribute("Type", "string"),
                                                                     new XAttribute("Width", "72")));

                if (previousElement == null)
                {
                    _document.GetProductModuleOrFragmentElement().AddFirst(newElement);
                }
                else
                {
                    previousElement.AddAfterSelf(newElement);
                }
                LoadData();
            }
        }
示例#7
0
        static void ConfigureEventLoggerAppender(string applicationNameForEventLog, string logLevel, XElement element)
        {
            var eventAppenderElement = new XElement("appender");

            eventAppenderElement.SetAttributeValue("name", "EventLogLogger");
            eventAppenderElement.SetAttributeValue("type", "log4net.Appender.EventLogAppender");
            eventAppenderElement.Add(new XElement("threshold", new XAttribute("value", logLevel)));
            eventAppenderElement.Add(GetMappingElement("ERROR", "Error"));
            eventAppenderElement.Add(GetMappingElement("DEBUG", "Information"));
            eventAppenderElement.Add(GetMappingElement("INFO", "Information"));
            eventAppenderElement.Add(GetMappingElement("WARN", "Warning"));

            var logNameElement = new XElement("logName");

            logNameElement.SetAttributeValue("value", "Warewolf");
            eventAppenderElement.Add(logNameElement);
            var applicationNameElement = new XElement("applicationName");

            applicationNameElement.SetAttributeValue("value", applicationNameForEventLog);
            eventAppenderElement.Add(applicationNameElement);
            var layoutElement = new XElement("layout");

            layoutElement.SetAttributeValue("type", "log4net.Layout.PatternLayout");
            var conversionPattenElement = new XElement("conversionPattern");

            conversionPattenElement.SetAttributeValue("value", "%date [%thread] %-5level - %message%newline");
            layoutElement.Add(conversionPattenElement);
            eventAppenderElement.Add(layoutElement);
            element.AddAfterSelf(eventAppenderElement);
        }
        /// <summary>
        /// 将指定的菜单项移动到另一个菜单项之后
        /// 原 MoveDown
        /// </summary>
        /// <param name="code"></param>
        /// <param name="afterCode"></param>
        public void MoveAfter(string id, string afterId)
        {
            if (id.Equals(afterId))
            {
                Debug.Assert(false, "id 和 afterId 相同");
                return;
            }

            XElement element      = _indexXml.XPathSelectElement(String.Format(XPATH_Index_SelectToolStrip, id));
            XElement afterElement = _indexXml.XPathSelectElement(String.Format(XPATH_Index_SelectToolStrip, afterId));

            Debug.Assert(element != null && afterId != null, "指定的节点没有找到");

            if (element == null || afterId == null)
            {
                return;
            }

            XElement elementNew = new XElement(element);

            afterElement.AddAfterSelf(elementNew);
            element.Remove();

            SaveIndexFile();

            //发布事件
            ToolStripItemMoveAfterEventArgs args = new ToolStripItemMoveAfterEventArgs(id, afterId);

            _eventAggregator.GetEvent <ToolStripItemMoveAfterEvent>().Publish(args);
        }
        public XDocument AddSingleNode(XDocument diffXDoc, XDocument resultXDoc)
        {
            diffXDoc.Descendants(diffXDoc.Root.Name.Namespace + Immutables.ADD).Where(s => s.Attribute(Immutables.TYPE) == null && s.Attribute(Immutables.OPID) == null && s.Attribute(Immutables.NAME) == null).ToList()
            .ForEach(item =>
            {
                string parentposition = item.Attribute(Immutables.CS_PARENT).Value;
                XElement xNode        = CommonUtilities.GetActualNd(parentposition, item, resultXDoc) as XElement;
                xNode.AddAfterSelf(new XElement(Immutables.ADDITION, item.Descendants().ToList()));
                item.Add(new XAttribute(Immutables.PROCESSED, Immutables.TRUE));
            });

            diffXDoc.Descendants(diffXDoc.Root.Name.Namespace + Immutables.ADD).Where(s => s.Attribute(Immutables.TYPE) != null && s.Attribute(Immutables.TYPE).Value == Immutables.ONE && s.Attribute(Immutables.PROCESSED) == null).ToList()
            .ForEach(item =>
            {
                if (item.Descendants(diffXDoc.Root.Name.Namespace + Immutables.ADD).ToList().Count > 0)
                {
                    ProcessNode(item, diffXDoc, resultXDoc);
                }
                else
                {
                    string parentposition = item.Attribute(Immutables.CS_PARENT).Value;
                    XElement nd           = CommonUtilities.GetActualNd(parentposition, item, resultXDoc) as XElement;
                    nd.AddAfterSelf(new XElement(Immutables.ADDITION, new XElement(item.Attribute(Immutables.NAME).Value, "")));
                    item.Add(new XAttribute(Immutables.PROCESSED, Immutables.TRUE));
                }
            });
            return(resultXDoc);
        }
        /// <summary>
        /// Convert the runtimes section to the RuntimeIdentifiers section
        /// </summary>
        private void MaybeAddRuntimeIdentifiers(XElement target)
        {
            var json = GetProjectJsonFilePath();

            if (!File.Exists(json))
            {
                return;
            }

            var obj = JObject.Parse(File.ReadAllText(json), new JsonLoadSettings()
            {
                CommentHandling = CommentHandling.Load
            });
            var runtimes = (JObject)obj["runtimes"];

            if (runtimes == null)
            {
                return;
            }

            string content = null;

            foreach (var cur in runtimes.Properties())
            {
                var item = cur.Name;
                content = (content == null) ? item : $"{content};{item}";
            }

            if (content != null)
            {
                var e = new XElement(_namespace.GetName("RuntimeIdentifiers"), content);
                target.AddAfterSelf(e);
            }
        }
示例#11
0
 private static void ApplyActor(Template templ, Node leaf, ref XElement lastActor)
 {
     if (!leaf.IsActor)
     {
         if (false) // es soll nie gelöscht werden
         {
             templ.OriginalNodes.Where(node => node.Attribute("EibAddr").Value == leaf.Address && node.Attribute("Type").Value == "EIBactor").Remove();
         }
     }
     else
     {
         List <XElement> existing = templ.OriginalNodes.Where(node => node.Attribute("EibAddr").Value == leaf.Address && node.Attribute("Type").Value == "EIBactor").ToList();
         if (existing.Count > 0)
         {
             foreach (XElement actor in existing)
             {
                 actor.SetAttributeValue("Title", leaf.Name);
                 actor.SetAttributeValue("EIBType", ((int)leaf.Type).ToString());
             }
         }
         else
         {
             XElement newActor = XElement.Parse(CreateActor(leaf, templ));
             lastActor.AddAfterSelf(newActor);
             lastActor = newActor;
         }
     }
 }
示例#12
0
        public void WriteToLog(string message)
        {
            if (!File.Exists(_xmlFile))
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(_xmlFile))
                {
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement("Log");

                    xmlWriter.WriteStartElement("LogEntry");
                    xmlWriter.WriteElementString("LogDate", DateTime.Now.ToString());
                    xmlWriter.WriteElementString("Message", message);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndDocument();
                    xmlWriter.Flush();
                    xmlWriter.Close();
                }
            }
            else
            {
                XDocument xDoc = XDocument.Load(_xmlFile);
                XElement  root = xDoc.Element("Log");
                IEnumerable <XElement> rows = root.Descendants("LogEntry");
                XElement lastRow            = rows.Last();
                lastRow.AddAfterSelf(
                    new XElement("LogEntry",
                                 new XElement("LogDate", DateTime.Now.ToString()),
                                 new XElement("Message", message)));
                xDoc.Save(_xmlFile);
            }
        }
        private XElement ProcessStaticCells(XElement currentElement, XElement previous)
        {
            var staticCells =
                currentElement.ElementsBeforeSelf(WordMl.TableCellName)
                .Where(element => element.IsBefore(previous))
                .ToList();

            if (staticCells.Any())
            {
                if (previous == null)
                {
                    var parentRow = staticCells.First().Parent;
                    staticCells.Remove();
                    parentRow.Add(staticCells);
                    previous = staticCells.Last();
                }
                else
                {
                    staticCells.Remove();
                    previous.AddAfterSelf(staticCells);
                    previous = staticCells.Last();
                }
            }

            return(previous);
        }
        public void appendToXML()
        {
            DateTime today = DateTime.Today;

            // String filename = "PatientDetails_" + today.Day + "_" + today.Month + "_" + today.Year;
            String filename = ConfigurationManager.AppSettings["path"].ToString() + "PatientDetails_" + today.Day + "_" + today.Month + "_" + today.Year;

            filename += ".xml";

            XDocument xDocument         = XDocument.Load(filename);
            XElement  root              = xDocument.Element("Patients");
            IEnumerable <XElement> rows = root.Descendants("Patient");
            XElement firstRow           = rows.Last();

            for (int i = resumeCount; i < Patient_Record.Count; i++)
            {
                firstRow.AddAfterSelf(
                    new XElement("Patient",
                                 new XAttribute("name", name),
                                 new XAttribute("age", age),
                                 new XAttribute("email", Email),
                                 new XAttribute("gender", gender + ""),
                                 new XElement("bpm", Patient_Record[i].getbpm()),
                                 new XElement("time", Patient_Record[i].getTime()),
                                 new XElement("Confidence", ConfidenceLevel)));
            }
            xDocument.Save(filename);
        }
示例#15
0
        /// <summary>
        /// 获取或设置指定位置的项目。
        /// </summary>
        /// <param name="index"></param>
        /// <exception cref="ArgumentOutOfRangeException" />
        /// <returns></returns>
        public XspfTrack this[int index]
        {
            get
            {
                return(new XspfTrack(XEle.Elements("track").ElementAt(index)));
            }

            set
            {
                if (index == 0)
                {
                    try { XEle.Element("track").Remove(); }
                    catch (NullReferenceException)
                    { throw new ArgumentOutOfRangeException("index"); }
                    XEle.AddFirst(value.XEle);
                }
                else
                {
                    XElement prev = XEle.Elements("track").ElementAt(index - 1);
                    try { prev.ElementsAfterSelf("track").First().Remove(); }
                    catch (NullReferenceException) { throw new ArgumentOutOfRangeException("index"); }
                    prev.AddAfterSelf(value.XEle);
                }
            }
        }
示例#16
0
        private void InsertBreakPast(XElement l)
        {
            string n = XmlHelper.GetBreakPointCitation(0, l, _docId);

            l.AddAfterSelf(new XElement(XmlHelper.TEI + "pb",
                                        new XAttribute("n", n)));
        }
示例#17
0
        internal static void InsertElement([NotNull] string filePath, [NotNull] IEnumerable <XElement> elementsToInsert, string afterTag = "", bool insertOnlyOnce = true)
        {
            bool      insertAfter = !StringUtility.IsNullEmptyOrWhiteSpace(afterTag);
            XDocument file        = XDocument.Load(filePath);

            if (file.Root != null)
            {
                if (insertAfter)
                {
                    XElement ele = file.Root.Element(afterTag);
                    if (ele != null)
                    {
                        ele.AddAfterSelf(elementsToInsert);
                        if (insertOnlyOnce)
                        {
                            Save(filePath, file);
                            return;
                        }
                    }
                    InsertElementAfterInternal(file.Root.Elements(), elementsToInsert, afterTag, insertOnlyOnce);
                }
                else
                {
                    foreach (XElement element in elementsToInsert)
                    {
                        file.Root.Add(element);
                    }
                }
            }

            Save(filePath, file);
        }
示例#18
0
        protected void AddDevicesList(XElement doc)
        {
            String headerId = GetIdWithPostfix(ID_DEVICE_TABLE, 1);

            var deviceTableHeaderTemplate = XmlUtil.GetElementById(doc, headerId);
            var deviceTableTemplate       = deviceTableHeaderTemplate.NextNode as XElement;

            XElement lastElement = deviceTableTemplate;

            if (null == deviceTableTemplate)
            {
                throw new XmlException("device table does not exist");
            }

            var devices = UnitSet.GetDevices();
            int count   = 3 > devices.Count ? 3 : devices.Count;

            for (int i = 1; i < count; ++i)
            {
                var newHeader = new XElement(deviceTableHeaderTemplate);
                var newTable  = new XElement(deviceTableTemplate);

                ProcessDeviceHeader(newHeader, i + 1);
                ProcessDeviceTable(newTable, i + 1);

                lastElement.AddAfterSelf(newHeader);
                newHeader.AddAfterSelf(newTable);

                lastElement = newTable;
            }
        }
示例#19
0
        private string GetRecordListManiaLinkPage(PlayerRank[] rankings, string login)
        {
            // show at least top 3
            int recordsToShow = Convert.ToInt32(Math.Max(Math.Min(Settings.MaxRecordsToShow, rankings.Length), 3));

            double totalHeight = Math.Abs(Settings.RankingPlayerToContainerMarginY * 2) + Math.Abs(Settings.RankingPlayerRecordHeight * recordsToShow) + Math.Abs(Settings.RankingTop3Gap) + Math.Abs(Settings.RankingPlayerEndMargin);

            XElement mainTemplate       = XElement.Parse(Settings.RankingListTemplate.Replace("{[ManiaLinkID]}", LIVE_RANKING_LIST_MANIA_LINK_PAGE_ID).Replace("{[ContainerHeight}}", totalHeight.ToString(Context.Culture)));
            XElement rankingPlaceHolder = mainTemplate.Descendants("RankingPlaceHolder").First();
            double   currentY           = Settings.RankingPlayerStartMargin;

            XElement lastInsertedNode = rankingPlaceHolder;

            SortedList <uint, PlayerRank> localRankings = GetRankingsToShow(rankings, login, Settings.MaxRecordsToShow);

            foreach (KeyValuePair <uint, PlayerRank> localRanking in localRankings)
            {
                XElement currentElement = GetPlayerRecordElement(localRanking.Value, currentY, localRanking.Key, login);
                lastInsertedNode.AddAfterSelf(currentElement);
                lastInsertedNode = currentElement;
                currentY        -= Settings.RankingPlayerRecordHeight;

                if (localRanking.Key == 3 && localRankings.Count > 3)
                {
                    currentY -= Settings.RankingTop3Gap;
                }
            }

            rankingPlaceHolder.Remove();

            return(mainTemplate.ToString());
        }
示例#20
0
        public static void CreateFakeEntityAfterSelf(this XElement cet, XElement entityBound, bool preventSetInquiryType = true)
        {
            if (!cet.IsElementCET())
            {
                throw (new ArgumentException("!cet.IsElementCET()"));
            }
            if (!entityBound.IsElementENTITY())
            {
                throw (new ArgumentException("!entityBound.IsElementENTITY()"));
            }

            var type = entityBound.GetAttributeTYPE().GetValueOrDefault(TypeAttributeValue.Unknown);

            if (preventSetInquiryType && (type == TypeAttributeValue.Inquiry))
            {
                type = TypeAttributeValue.Unknown;
            }

            var entity = new XElement(Consts.ENTITY_ELEMENT);

            entity.SetAttributeROLE(cet.GetAttributeROLE());
            entity.SetAttributeTYPE(type);
            entity.SetAttributeSNT(entityBound.GetAttributeSNT());
            entity.SetAttributeFRT(entityBound.GetAttributeFRT());

            cet.AddAfterSelf(CreateEmptyU(), entity);
        }
        public XDocument ProcessNode(XElement item, XDocument diffXDoc, XDocument resultXDoc)
        {
            if (item.Attribute(Immutables.PROCESSED) == null)
            {
                XElement xElement = new XElement(item.Attribute(Immutables.NAME).Value, "");
                item.Add(new XAttribute(Immutables.PROCESSED, Immutables.TRUE));

                item.Descendants(diffXDoc.Root.Name.Namespace + Immutables.ADD).ToList()
                .ForEach(s =>
                {
                    //single node or moved node///////////////////////////////////////////////
                    if (s.Attribute(Immutables.TYPE) != null && s.Attribute(Immutables.TYPE).Value == Immutables.ONE && s.Attribute(Immutables.PROCESSED) == null && s.Attribute(Immutables.TYPE) != null)
                    {
                        if (xElement.Descendants().Elements() != null)
                        {
                            if (xElement.Elements().Count() > 0)
                            {
                                xElement.Elements().Last().Add(new XElement(s.Attribute(Immutables.NAME).Value), "");
                            }
                            else
                            {
                                xElement.Add(new XElement(s.Attribute(Immutables.NAME).Value), "");
                            }

                            s.Add(new XAttribute(Immutables.PROCESSED, Immutables.TRUE));
                        }
                        else
                        {
                            if (xElement.Elements().Count() > 0)
                            {
                                xElement.Elements().Last().Add(new XElement(s.Attribute(Immutables.NAME).Value), "");
                            }
                            else
                            {
                                xElement.Add(new XElement(s.Attribute(Immutables.NAME).Value), "");
                            }
                            s.Add(new XAttribute(Immutables.PROCESSED, Immutables.TRUE));
                        }
                    }
                    else if (s.Attribute(Immutables.OPID).Value == Immutables.ONE)
                    {
                        var x = resultXDoc.Descendants().Where(a => a.Attribute(Immutables.MOVEDPOS) != null && a.Attribute(Immutables.MOVEDPOS).Value == s.Attribute(Immutables.OPID).Value.ToString()).FirstOrDefault();
                        if (xElement.Elements().Count() > 0)
                        {
                            xElement.Elements().Last().Add(x);
                        }
                        else
                        {
                            xElement.Add(x);
                        }

                        s.Add(new XAttribute(Immutables.PROCESSED, Immutables.TRUE));
                    }
                });
                string   parentposition = item.Attribute(Immutables.CS_PARENT).Value;
                XElement nd             = CommonUtilities.GetActualNd(parentposition, item, resultXDoc) as XElement;
                nd.AddAfterSelf(new XElement(Immutables.ADDITION, xElement));
            }
            return(resultXDoc);
        }
        public override bool Execute()
        {
            string    xml                   = File.ReadAllText(NuGetConfigFile);
            string    newLineChars          = FileUtilities.DetectNewLineChars(xml);
            XDocument d                     = XDocument.Parse(xml);
            XElement  packageSourcesElement = d.Root.Descendants().First(e => e.Name == "packageSources");
            XElement  toAdd                 = new XElement("add", new XAttribute("key", SourceName), new XAttribute("value", SourcePath));
            XElement  clearTag              = new XElement("clear");

            XElement exisitingSourceBuildElement = packageSourcesElement.Descendants().FirstOrDefault(e => e.Name == "add" && e.Attribute(XName.Get("key")).Value == SourceName);
            XElement lastClearElement            = packageSourcesElement.Descendants().LastOrDefault(e => e.Name == "clear");

            if (exisitingSourceBuildElement != null)
            {
                exisitingSourceBuildElement.ReplaceWith(toAdd);
            }
            else if (lastClearElement != null)
            {
                lastClearElement.AddAfterSelf(toAdd);
            }
            else
            {
                packageSourcesElement.AddFirst(toAdd);
                packageSourcesElement.AddFirst(clearTag);
            }

            using (var w = XmlWriter.Create(NuGetConfigFile, new XmlWriterSettings {
                NewLineChars = newLineChars, Indent = true
            }))
            {
                d.Save(w);
            }

            return(true);
        }
示例#23
0
        public string GenerateSndXML(string devID, string cmdStr, List <string> productList)
        {
            string   xmlStr = "<?xml version=\"1.0\" encoding=\"GB2312\" ?><MesDT transFlag=\"COMMAND\" cmd=\"Ready\"><Desc deviceID=\"电池极性检测\"></Desc></MesDT>";
            XElement root   = XElement.Parse(xmlStr);

            if (root == null)
            {
                xmlStr = string.Empty;
                return(xmlStr);
            }
            root.Attribute("cmd").Value = cmdStr;
            XElement xeDesc = root.Element("Desc");

            xeDesc.Attribute("deviceID").Value = devID;
            if (cmdStr.ToUpper() == "START" && productList != null && productList.Count() > 0)
            {
                for (int i = productList.Count() - 1; i >= 0; i--)
                {
                    //int seq = 0;

                    int      seq = i + 1;
                    XElement xe  = new XElement("ProductID", new XAttribute("seq", seq.ToString()));
                    xe.Value = productList[i].Trim();
                    xeDesc.AddAfterSelf(xe);
                }
            }
            xmlStr = root.ToString();
            xmlStr = "<?xml version=\"1.0\" encoding=\"GB2312\" ?>\r\n" + xmlStr;
            return(xmlStr);
        }
示例#24
0
        static void RemoveButKeepChildren(XElement path)
        {
            var parent = path.Parent;

            path.AddAfterSelf(path.Elements());
            path.Remove();
        }
        private void LoadExtraSettings(FormFieldModel field, XElement bindingsXElement, XElement lastTabElement)
        {
            var config          = FormBuilderConfiguration.GetSection();
            var plugin          = (DynamicFormBuilderConfiguration)config.Plugins["dynamic"];
            var inputElement    = plugin.InputElementHandlers.Single(el => el.ElementType.GetType() == field.InputElementType.GetType());
            var settingsHandler = inputElement.SettingsHandler;

            if (settingsHandler != null)
            {
                var formFile = "\\InstalledPackages\\CompositeC1Contrib.FormBuilder.Dynamic\\InputElementSettings\\" + inputElement.Name + ".xml";
                var settingsMarkupProvider = new FormDefinitionFileMarkupProvider(formFile);
                var formDefinitionElement  = XElement.Load(settingsMarkupProvider.GetReader());

                var settingsTab = new XElement(Namespaces.BindingFormsStdUiControls10 + "PlaceHolder");
                var layout      = formDefinitionElement.Element(Namespaces.BindingForms10 + FormKeyTagNames.Layout);
                var bindings    = formDefinitionElement.Element(Namespaces.BindingForms10 + FormKeyTagNames.Bindings);

                settingsTab.Add(new XAttribute("Label", StringResourceSystemFacade.ParseString(inputElement.Name)));
                settingsTab.Add(layout.Elements());
                bindingsXElement.Add(bindings.Elements());

                lastTabElement.AddAfterSelf(settingsTab);

                settingsHandler.Load(field);

                foreach (var prop in settingsHandler.GetType().GetProperties())
                {
                    var value = prop.GetValue(settingsHandler, null);

                    Bindings.Add(prop.Name, value);
                }
            }
        }
        public override bool Execute()
        {
            XDocument d = XDocument.Load(NuGetConfigFile);
            XElement  packageSourcesElement = d.Root.Descendants().First(e => e.Name == "packageSources");
            XElement  toAdd = new XElement("add", new XAttribute("key", SourceName), new XAttribute("value", SourcePath));

            XElement exisitingSourceBuildElement = packageSourcesElement.Descendants().FirstOrDefault(e => e.Name == "add" && e.Attribute(XName.Get("key")).Value == SourceName);
            XElement lastClearElement            = packageSourcesElement.Descendants().LastOrDefault(e => e.Name == "clear");

            if (exisitingSourceBuildElement != null)
            {
                exisitingSourceBuildElement.ReplaceWith(toAdd);
            }
            else if (lastClearElement != null)
            {
                lastClearElement.AddAfterSelf(toAdd);
            }
            else
            {
                packageSourcesElement.AddFirst(toAdd);
            }

            using (FileStream fs = new FileStream(NuGetConfigFile, FileMode.Create, FileAccess.ReadWrite))
            {
                d.Save(fs);
            }

            return(true);
        }
示例#27
0
        public new void Add(IsWiXDependency Dependency)
        {
            base.Add(Dependency);
            var newdependency =
                new XElement(ns + "Dependency",
                             new XAttribute("RequiredId", Dependency.RequiredId),
                             new XAttribute("RequiredLanguage", Dependency.RequiredLanguage),
                             new XAttribute("RequiredVersion", Dependency.RequiredVersion
                                            ));

            _documentManager.Document.GetElementToAddAfterSelf("Dependency").AddAfterSelf(newdependency);


            var currentDependencies = from a in _documentManager.Document.Descendants(ns + "Dependency")
                                      orderby(string) a.Attribute("RequiredId").Value, (string)a.Attribute("RequiredLanguage").Value ascending
            select new { dependency = a };

            var temp = XDocument.Parse(_documentManager.Document.ToString());

            temp.Descendants(ns + "Dependency").Remove();

            XElement previousNode = temp.Descendants(ns + "Package").First();

            foreach (var dependency in currentDependencies)
            {
                previousNode.AddAfterSelf(dependency.dependency);
                previousNode = temp.Descendants(ns + "Dependency").Last();
            }
            _documentManager.Document.Descendants(ns + "Dependency").Remove();
            _documentManager.Document.GetElementToAddAfterSelf("Dependency").AddAfterSelf(temp.Descendants(ns + "Dependency"));
        }
示例#28
0
        private void WriteCustomXML(CustomTool tool)
        {
            string xmlPath = @"data/data_custom.xml";

            XDocument xDocument         = XDocument.Load(xmlPath);
            XElement  root              = xDocument.Element(@"tools");
            IEnumerable <XElement> rows = root.Descendants("tool");

            if (rows.Count() == 0)
            {
                root.Add(new XElement("tool",
                                      new XElement("name", tool.name),
                                      new XElement("desc", tool.desc),
                                      new XElement("path", tool.path)));
            }
            else
            {
                XElement lastRow = rows.Last();
                lastRow.AddAfterSelf(
                    new XElement("tool",
                                 new XElement("name", tool.name),
                                 new XElement("desc", tool.desc),
                                 new XElement("path", tool.path)));
            }
            xDocument.Save(xmlPath);
        }
示例#29
0
        private static FlatText FlattenRunElement(XElement run)
        {
            XElement[] childs        = run.Elements().ToArray();
            XElement   runProperties = childs[0].Name == FlatConstants.RunPropertiesElementName ? childs[0] : null;

            int childCount     = childs.Length;
            int flatChildCount = 1 + (runProperties != null ? 1 : 0);

            // Break current Run into multiple Run elements which have one child,
            // or two childs in case it has first RunProperties child.
            while (childCount > flatChildCount)
            {
                // Move last child element from current Run into new Run which is added after the current Run.
                XElement child = childs[childCount - 1];
                run.AddAfterSelf(
                    new XElement(FlatConstants.RunElementName,
                                 runProperties != null ? new XElement(runProperties) : null,
                                 new XElement(child)));

                child.Remove();
                --childCount;
            }

            XElement remainingChild = childs[childCount - 1];

            return(remainingChild.Name == FlatConstants.TextElementName ? new FlatText(remainingChild) : null);
        }
示例#30
0
        private static XDocument AddIcon(XDocument svg, string base64EncodedImage)
        {
            if (svg == null || string.IsNullOrEmpty(base64EncodedImage) || svg.Descendants("circle").Any())
            {
                return(svg);
            }

            XElement circleElement = svg.Descendants().FirstOrDefault(x => x.Name.LocalName == "circle");

            if (circleElement == null)
            {
                throw new NullReferenceException("circle element could not found in SVG");
            }

            XNamespace ns      = svg.Root.Name.Namespace;
            XNamespace xlinkNs = "http://www.w3.org/1999/xlink";

            XElement imageElement = new XElement(ns + "image",
                                                 new XAttribute("x", 19.8),
                                                 new XAttribute("y", 15.8),
                                                 new XAttribute("width", 10),
                                                 new XAttribute("height", 10),
                                                 new XAttribute(xlinkNs + "href", "data:image/png;base64," + base64EncodedImage));

            circleElement.AddAfterSelf(imageElement);

            return(svg);
        }