public ItemDish MenuXmlToList(XElement doc)
 {
     //Надо добавить ButtonName, они выбиваются из стиля
     var buttons = doc.Elements("ButtonName").Elements("Наименование");
     foreach (var item in buttons.Select(p => new ItemDish
                                              {
                                                  Price = "This Bigfolder!",
                                                  IdFather = "This Bigfolder!",
                                                  Name = p.Value,
                                                  Id = "This Bigfolder!"
                                              }))
     {
         Menu.Children.Add(item);
     }
     //ПАПКИ с блюдами
     var rootMenu = doc.Elements("ButtonName").Elements("ItemName").Elements("Наименование");
     //Добавляем папки и детей
     foreach (var item in rootMenu.Select(p => new ItemDish
                                               {
                                                   Price = "This folder!",
                                                   IdFather = "This folder!",
                                                   Name = p.Value,
                                                   Id = ((XElement)p.PreviousNode).Value
                                               }))
     {
         Menu.Children.Add(item);
         GetChildren(item.Id, doc);
     }
     return Menu;
 }
        // jsc, why not allow static methods
        public void Foo(XElement PageContainer, Action<XElement> y)
        {
            PageContainer.Elements().WithEach(
                e =>
                {
                    e.Elements().WithEach(
                        span =>
                        {
                            // what about xmlns like facebook?
                            span.Add(new XElement("code", " (" + span.Name.LocalName + ")"));
                        }
                    );

                    e.Add(new XElement("code", " (element of PageContainer)"));
                }
            );


            PageContainer.Elements().Elements("span").WithEach(
                span =>
                {
                    span.Add(
                        new XAttribute("style", "color: red;")
                    );

                }
            );

            y(PageContainer);
        }
Example #3
0
        private LoadPackage ReadPackage(XElement pkge) {
            var result = new LoadPackage {Code = pkge.Attr("code")};
            var level = pkge.Attr("level");
            if (!string.IsNullOrWhiteSpace(level)) {
                result.Level = (LoadLevel) Enum.Parse(typeof (LoadLevel), level, true);
            }

            result.Arm = pkge.Attr("arm","default");
            result.Command = pkge.Attr("command", "");
               

            var deps = pkge.Elements("uses");
            foreach (var dep in deps) {
                result.Dependency.Add(dep.Attr("code"));
            }
            foreach (var item in pkge.Elements("load")) {
                result.Items.Add(ReadItem(item));
            }
            foreach (var item in pkge.Elements("widget")) {
                ReadWidget(result, item);
            }


            return result;
        }
Example #4
0
        static void ProcessElement(Counter counter, XElement element, Node rootNode)
        {
            foreach (XElement e in element.Elements("File"))
            {
                XAttribute attribute = e.Attribute("RelativePath");
                if (attribute == null)
                    continue;

                FileNode file = new FileNode();
                file.Path = Path.Combine(Path.GetDirectoryName(projectPath), attribute.Value);
                counter.CountFile(file);

                if (file.Valid)
                    rootNode.ChildNodes.Add(file);
            }

            foreach (XElement e in element.Elements("Filter"))
            {
                XAttribute attribute = e.Attribute("Name");
                if (attribute == null)
                    continue;

                Node node = new Node();
                node.Name = attribute.Value;
                ProcessElement(counter, e, node);

                rootNode.ChildNodes.Add(node);
            }
        }
        private static JObject CreateJsonColourPair(XElement liElement)
        {
            var name = liElement.Elements("span").First().Value;
            var hex = liElement.Elements("span").Last().Value;

            var prefix = "Primary";
            if (name.StartsWith("A"))
            {
                prefix = "Accent";
                name = name.Skip(1).Aggregate("", (current, next) => current + next);
            }

            var liClass = liElement.Attribute("class").Value;
            Color foregroundColour;
            if (!ClassNameToForegroundIndex.TryGetValue(liClass, out foregroundColour))
                throw new Exception("Unable to map foreground color from class " + liClass);

            var foreGroundColorHex = string.Format("#{0}{1}{2}",
                ByteToHex(foregroundColour.R),
                ByteToHex(foregroundColour.G),
                ByteToHex(foregroundColour.B));

            var foregroundOpacity = Math.Round((double) foregroundColour.A/(255.0), 2);

            return new JObject(
                new JProperty("backgroundName", string.Format("{0}{1}", prefix, name)),
                new JProperty("backgroundColour", hex),
                new JProperty("foregroundName", string.Format("{0}{1}Foreground", prefix, name)),
                new JProperty("foregroundColour", foreGroundColorHex),
                new JProperty("foregroundOpacity", foregroundOpacity)
                );
        }
Example #6
0
        public static void Parse(dynamic parent, XElement node)
        {
            if (node.HasElements)
                if (node.Elements(node.Elements().First().Name.LocalName).Count() > 1)
                {
                    //list
                    var item = new ExpandoObject();
                    var list = new List<dynamic>();
                    foreach (var element in node.Elements())
                        Parse(list, element);

                    AddProperty(item, node.Elements().First().Name.LocalName, list);
                    AddProperty(parent, node.Name.ToString(), item);
                }
                else
                {
                    var item = new ExpandoObject();

                    foreach (var attribute in node.Attributes())
                        AddProperty(item, attribute.Name.ToString(), attribute.Value.Trim());

                    //element
                    foreach (var element in node.Elements())
                        Parse(item, element);

                    AddProperty(parent, node.Name.ToString(), item);
                }
            else
                AddProperty(parent, node.Name.ToString(), node.Value.Trim());
        }
Example #7
0
        public UserInfo(XElement element)
        {
            this.Name = element.Element("name").Value;
            this.id = Int32.Parse(element.Element("id").Value);
            this.url = new Uri(element.Element("url").Value);

            if (element.Element("realname") != null && element.Element("realname").Value != null)
                this.RealName = element.Element("realname").Value;
            if (element.Element("age") != null && !String.IsNullOrEmpty(element.Element("age").Value))
                this.Age = Int32.Parse(element.Element("age").Value);
            if (element.Element("playcount") != null)
                this.PlayCount = Int32.Parse(element.Element("playcount").Value);
            try
            { this.SmallImage = new Uri((from el in element.Elements("image") where el.Attribute("size").Value.ToString() == "small" select el.Value.ToString()).First()); }
            catch (UriFormatException) { this.SmallImage = null; }
            try
            { this.MediumImage = new Uri((from el in element.Elements("image") where el.Attribute("size").Value.ToString() == "medium" select el.Value.ToString()).First()); }
            catch (UriFormatException) { this.MediumImage = null; }
            try
            { this.LargeImage = new Uri((from el in element.Elements("image") where el.Attribute("size").Value.ToString() == "large" select el.Value.ToString()).First()); }
            catch (UriFormatException) { this.LargeImage = null; }
            try
            { this.ExtraLargeImage = new Uri((from el in element.Elements("image") where el.Attribute("size").Value.ToString() == "extralarge" select el.Value.ToString()).First()); }
            catch (UriFormatException) { this.ExtraLargeImage = null; }
        }
 /// <summary>
 /// Creates scope definitions from the given element
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="fileName">Name of the file.</param>
 /// <returns>collection of scope definitions for each scope found</returns>
 public static IEnumerable<ScopeDefinition> CreateFromElement(XElement element, string fileName)
 {
     if (MethodDefinition.ValidNames.Contains(element.Name))
     {
         yield return new MethodDefinition(element, fileName);
     }
     else if (TypeDefinition.ValidNames.Contains(element.Name))
     {
         if (element.Elements(SRC.Name).Count() > 0)
         {
             foreach (var nameElement in element.Elements(SRC.Name))
             {
                 yield return new TypeDefinition(element, nameElement.Value, fileName);
             }
         }
         else
         {
             yield return new TypeDefinition(element, fileName);
         }
     }
     else
     {
         yield return new ScopeDefinition(element, fileName);
     }
 }
Example #9
0
        private XElement RemoveElement(XElement input)
        {
            XElement output = new XElement("objects", new XAttribute("filename", input.Element("filename").Value));
            Random rand = new Random();
            int outElement = rand.Next(input.Elements("object").Count());

            XElement element = input.Element("object");
            for (int i = 0; i < input.Elements("object").Count(); i++)
            {
                if (element.Element("name") != null)
                {

                    if (i != outElement)
                    {
                        output.Add(new XElement("object", new XAttribute("name", element.Element("name").Value.ToLower().Replace("\n", "").Replace("\b", ""))));
                    }
                    else
                    {
                        output.Add(new XElement("result", new XAttribute("name", element.Element("name").Value.ToLower().Replace("\n", "").Replace("\b", ""))));
                    }
                }
                element = (XElement)element.NextNode;
            }

            return output;
        }
        void MapForInputOutput(XElement rootEl)
        {
            if (rootEl == null)
            {
                return;
            }
            Inputs.AddRange(
                rootEl.Elements().Where(el =>
                {
                    var firstOrDefault = el.Attributes("ColumnIODirection").FirstOrDefault();
                    var removeCondition = firstOrDefault != null &&
                                          (firstOrDefault.Value == enDev2ColumnArgumentDirection.Input.ToString() ||
                                           firstOrDefault.Value == enDev2ColumnArgumentDirection.Both.ToString());
                    return removeCondition && !el.HasElements;
                }).Select(element => element.Name.ToString()));

            Outputs.AddRange(
                rootEl.Elements().Where(el =>
                {
                    var firstOrDefault = el.Attributes("ColumnIODirection").FirstOrDefault();
                    var removeCondition = firstOrDefault != null &&
                                          (firstOrDefault.Value == enDev2ColumnArgumentDirection.Output.ToString() ||
                                           firstOrDefault.Value == enDev2ColumnArgumentDirection.Both.ToString());
                    return removeCondition && !el.HasElements;
                }).Select(element => element.Name.ToString()));

            var xElements = rootEl.Elements().Where(el => el.HasElements);
            var enumerable = xElements as IList<XElement> ?? xElements.ToList();
            Inputs.AddRange(enumerable.Elements().Select(element =>
            {
                var xAttribute = element.Attributes("ColumnIODirection").FirstOrDefault();
                var include = xAttribute != null &&
                              (xAttribute.Value == enDev2ColumnArgumentDirection.Input.ToString() ||
                               xAttribute.Value == enDev2ColumnArgumentDirection.Both.ToString());
                if (include)
                {
                    if (element.Parent != null)
                    {
                        return DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*"));
                    }
                }
                return "";
            }));

            Outputs.AddRange(enumerable.Elements().Select(element =>
            {
                var xAttribute = element.Attributes("ColumnIODirection").FirstOrDefault();
                var include = xAttribute != null &&
                              (xAttribute.Value == enDev2ColumnArgumentDirection.Output.ToString() ||
                               xAttribute.Value == enDev2ColumnArgumentDirection.Both.ToString());
                if (include)
                {
                    if (element.Parent != null)
                    {
                        return DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*"));
                    }
                }
                return "";
            }));
        }
		bool RewriteElement(XamlContext ctx, XElement parent, XElement elem) {
			var type = parent.Annotation<XamlType>();
			var property = elem.Annotation<XamlProperty>();
			if ((property == null || type == null) && elem.Name != key)
				return false;

			if (elem.Elements().Count() != 1 || elem.Attributes().Any(t => t.Name.Namespace != XNamespace.Xmlns))
				return false;

			var value = elem.Elements().Single();

			if (!CanInlineExt(ctx, value))
				return false;

			var ext = InlineExtension(ctx, value);
			if (ext == null)
				return false;

			ctx.CancellationToken.ThrowIfCancellationRequested();

			var extValue = ext.ToString(ctx, parent);

			var attrName = elem.Name;
			if (attrName != key)
				attrName = property.ToXName(ctx, parent, property.IsAttachedTo(type));
			var attr = new XAttribute(attrName, extValue);
			parent.Add(attr);
			elem.Remove();

			return true;
		}
        public PauseScreen(XElement reader, string basePath)
        {
            weapons = new List<PauseWeaponInfo>();
            inventory = new List<InventoryInfo>();

            XElement changeNode = reader.Element("ChangeSound");
            if (changeNode != null) ChangeSound = SoundInfo.FromXml(changeNode, basePath);

            XElement soundNode = reader.Element("PauseSound");
            if (soundNode != null) PauseSound = SoundInfo.FromXml(soundNode, basePath);

            XElement backgroundNode = reader.Element("Background");
            if (backgroundNode != null) Background = FilePath.FromRelative(backgroundNode.Value, basePath);

            foreach (XElement weapon in reader.Elements("Weapon"))
                weapons.Add(PauseWeaponInfo.FromXml(weapon, basePath));

            XElement livesNode = reader.Element("Lives");
            if (livesNode != null)
            {
                LivesPosition = new Point(livesNode.GetInteger("x"), livesNode.GetInteger("y"));
            }

            foreach (XElement inventoryNode in reader.Elements("Inventory"))
            {
                inventory.Add(InventoryInfo.FromXml(inventoryNode, basePath));
            }
        }
Example #13
0
        protected void savedSearchResultsRepeater_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem)
            {
                System.Data.DataRowView currentRow = e.Item.DataItem as System.Data.DataRowView;
                string itemLinkValue = currentRow["HitHighlightedPropertiesXml"] as string;

                System.Xml.Linq.XElement xEl            = System.Xml.Linq.XElement.Parse(itemLinkValue);
                System.Xml.Linq.XElement hhTitleElement =
                    (from node in xEl.Elements()
                     where node.Name == "HHTitle"
                     select node).FirstOrDefault();

                System.Xml.Linq.XElement hhUrlElement =
                    (from node in xEl.Elements()
                     where node.Name == "HHUrl"
                     select node).FirstOrDefault();

                string hhTitle = hhTitleElement != null ? hhTitleElement.Value : string.Empty;
                string hhUrl   = hhUrlElement != null ? hhUrlElement.Value : string.Empty;;
                string iconUrl = Microsoft.SharePoint.Publishing.Fields.LinkFieldValue.GetDefaultIconUrl(currentRow["Url"] as string, SPContext.Current.Web);

                System.Web.UI.WebControls.Image docTypeImage = e.Item.FindControl("docTypeImage") as System.Web.UI.WebControls.Image;
                if (docTypeImage != null)
                {
                    docTypeImage.ImageUrl = iconUrl;
                }

                System.Web.UI.WebControls.HyperLink titleLink = e.Item.FindControl("titleLink") as System.Web.UI.WebControls.HyperLink;
                if (titleLink != null)
                {
                    titleLink.NavigateUrl = hhUrl;
                    titleLink.Text        = hhTitle;
                }

                System.Web.UI.WebControls.CheckBox reviewedCheckBox = e.Item.FindControl("reviewedCheckBox") as System.Web.UI.WebControls.CheckBox;
                if (reviewedCheckBox != null)
                {
                    reviewedCheckBox.InputAttributes.Add("onclick",
                                                         String.Format("SaveSearchResultData({0}, {1}, {2});",
                                                                       currentRow["Id"],
                                                                       "'reviewed'",
                                                                       "$('#" + reviewedCheckBox.ClientID + "').prop('checked')")
                                                         );
                    reviewedCheckBox.Checked = (currentRow.Row.IsNull("Reviewed")) ? false: (bool)currentRow["Reviewed"];
                }

                System.Web.UI.WebControls.CheckBox includeInSetCheckBox = e.Item.FindControl("includeInSetCheckBox") as System.Web.UI.WebControls.CheckBox;
                if (includeInSetCheckBox != null)
                {
                    includeInSetCheckBox.InputAttributes.Add("onclick",
                                                             String.Format("SaveSearchResultData({0}, {1}, {2});",
                                                                           currentRow["Id"],
                                                                           "'IncludeInSet'",
                                                                           "$('#" + includeInSetCheckBox.ClientID + "').prop('checked')")
                                                             );
                    includeInSetCheckBox.Checked = (currentRow.Row.IsNull("IncludeInSet")) ? false : (bool)currentRow["IncludeInSet"];
                }
            }
        }
        public static void SetValue(XElement _parent, PropertyExtensionContext _context, XName xName, string value)
        {
            string propertyValue;
            if (value != null)
                propertyValue = value.Trim();
            else
                propertyValue = string.Empty;

            using (EntityDesignerChangeScope scope = _context.CreateChangeScope("Set EDMXFileTools"))
            {
                if (_parent.HasElements)
                {
                    XElement lastChild = _parent.Elements().Where<XElement>(element => element != null && element.Name == xName).LastOrDefault();
                    if (lastChild != null)
                    {
                        lastChild.SetValue(propertyValue);
                    }
                    else
                    {
                        // MyNewProperty element does not exist, so create a new one as the last
                        // child of the EntityType element.
                        _parent.Elements().Last().AddAfterSelf(new XElement(xName, propertyValue));
                    }
                }
                else
                {
                    // The EntityType element has no child elements so create a new MyNewProperty
                    // element as its first child.
                    _parent.Add(new XElement(xName, propertyValue));
                }

                // Commit the changes.
                scope.Complete();
            }
        }
Example #15
0
        private void ParseCommand(System.Xml.Linq.XElement commandElement)
        {
            // Wrap a big, OMG, what have I done ???, undo around the whole thing !!!

            int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("ParseCommand");

            // These are the top level elements that can appear in a command.
            // A command can contain more than one.

            if (commandElement.Elements("Documents").Any())
            {
                ProcessCommand_Documents(commandElement.Element("Documents").Elements());
            }

            if (commandElement.Elements("Layers").Any())
            {
                ProcessCommand_Layers(commandElement.Element("Layers").Elements());
            }

            if (commandElement.Elements("Pages").Any())
            {
                ProcessCommand_Pages(commandElement.Element("Pages").Elements());
            }

            if (commandElement.Elements("Shapes").Any())
            {
                ProcessCommand_Shapes(commandElement.Element("Shapes").Elements());
            }

            Globals.ThisAddIn.Application.EndUndoScope(undoScope, true);
        }
        public IComponentInfo Load(XElement node, Project project)
        {
            var comp = new StateComponentInfo();
            foreach (var state in node.Elements("State"))
            {
                var stateInfo = ReadState(state);
                comp.States.Add(stateInfo);
            }

            foreach (var triggerInfo in node.Elements("Trigger"))
            {
                var statesNode = triggerInfo.Element("States");
                var states = statesNode != null ? statesNode.Value.Split(',').Select(s => s.Trim()).ToList() : null;

                var trigger = _triggerReader.Load(triggerInfo);

                if (trigger.Priority == null)
                    trigger.Priority = ((IXmlLineInfo)triggerInfo).LineNumber;

                comp.Triggers.Add(new MultiStateTriggerInfo() {
                    States = states,
                    Trigger = trigger
                });
            }

            return comp;
        }
        private string ParseDocument(XElement document)
        {
            StringBuilder result = new StringBuilder();
            IEnumerable<XElement> obxSegments = document.Elements("OBX");
            foreach (XElement obxSegment in obxSegments)
            {
                XElement obx5 = obxSegment.Element("OBX.5");
                XElement obx51 = obx5.Element("OBX.5.1");
                if (obx51 != null)
                {
                    result.AppendLine(obx51.Value);
                }
                else
                {
                    result.AppendLine();
                }
            }

            IEnumerable<XElement> nteSegments = document.Elements("NTE");
            foreach (XElement nteSegment in nteSegments)
            {
                XElement nte3 = nteSegment.Element("NTE.3");
                if (nte3 != null)
                {
                    XElement nte31 = nte3.Element("NTE.3.1");
                    result.AppendLine(nte31.Value);
                }
                else
                {
                    result.AppendLine();
                }
            }

            return result.ToString();
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="loopTag"></param>
        /// <param name="exchange"></param>
        /// <param name="route"></param>
        public static void Execute(XElement loopTag, Exchange exchange, Route route)
        {
            Camel.TryLog(exchange, "processor", "loop");
            var expressionTag = loopTag.Elements().FirstOrDefault();
            if (expressionTag == null || (expressionTag.Name != "count"))
                return;

            var xpression = expressionTag.Value;
            var count = SimpleExpression.ResolveSpecifiedUriPart(xpression, exchange);

            var mCount = Convert.ToInt32(count);
            for (var i = 0; i < mCount; i++)
            {
                var data = loopTag.Elements().Skip(1);
                foreach (var dataItem in data)
                {
                    try
                    {
                        RouteStep.ProcessStep(dataItem, route, exchange);
                    }
                    catch (Exception exception)
                    {

                    }
                }
            }
        }
        //wird nicht gebraucht (fetch bookings with Dates)
        public static XElement addDate(XElement xmlString, String from, String dto)
        {
            //version 1 
                //XElement dateXml = getXmlFile(System.IO.Path.Combine(@"..\..\xml-Strings\alternativeStringDate.xml"));
            
                //dateXml.Elements("value").Elements("array").Elements("data").Elements("value")
                //    .Elements("struct").Elements("member").Take(1).Elements("value").Elements("string")
                //    .LastOrDefault().Add(from);

                //dateXml.Elements("value").Elements("array").Elements("data").Elements("value")
                //   .Elements("struct").Elements("member").Take(2).Elements("value").Elements("string")
                //   .LastOrDefault().Add(dto);
  
            //version 2
            XElement date1 = new XElement("param",
                                    new XElement("value",
                                        new XElement("string",from
                                            )));
            XElement date2 = new XElement("param",
                                   new XElement("value",
                                       new XElement("string", dto
                                           )));

            xmlString.Elements("params").Take(3).LastOrDefault().AddAfterSelf(date1);
            xmlString.Elements("params").Take(3).LastOrDefault().AddAfterSelf(date2);

            return xmlString;
        }
Example #20
0
 public UPnPService(UPnPDevice parent, XNamespace ns, XElement service)
 {
     ParentDevice = parent;
       ServiceType = service.Elements().First(e => e.Name.LocalName == "serviceType").Value;
       ServiceID = service.Elements().First(e => e.Name.LocalName == "serviceId").Value;
       ControlUrl = service.Elements().First(e => e.Name.LocalName == "controlURL").Value;
 }
Example #21
0
File: Program.cs Project: AxFab/amy
        public Delivery(XElement dom, Project project)
            : base(dom)
        {
            FileInfo cur = new FileInfo(".");
              foreach (XElement child in dom.Elements("Source")) {
            string url = child.Value;
            if (url.Contains("*"))
              foreach (string file in Glob.Enumerate(url)) {
            FileInfo fi = new FileInfo(file);
            sources_.Add(fi.FullName.Replace(cur.FullName + '\\', ""));
              }
            else {
              FileInfo fi = new FileInfo(url);
              sources_.Add(fi.FullName.Replace(cur.FullName+'\\', ""));
            }
              }

              dependancies_.Add("System");
              dependancies_.Add("System.Core");
              dependancies_.Add("System.Xml");
              dependancies_.Add("System.Xml.Linq");

              foreach (XElement child in dom.Elements("Reference")) {
            string refer = child.Value;
            references_.Add(project.Delivery(refer));
              }
        }
Example #22
0
        public WebDavResponse(XElement response)
        {
            if (response == null)
                throw new ArgumentNullException ("response");

            Element = response;

            Href    = response.GetElementPathValue (WebDavNames.Href);
            Hrefs   = response.Elements (WebDavNames.Href)
                .Select (h => h.Value)
                .Skip (1);
            if (Hrefs.Any ()) {
                Status              = response.GetElementPathValue (WebDavNames.Status);
                PropertyStatuses    = new WebDavPropertyStatus [0];
            }
            else {
                PropertyStatuses = response.Elements (WebDavNames.Propstat)
                    .Select (propstat => new WebDavPropertyStatus (propstat));
            }

            Error = response.GetElementPath (WebDavNames.Error);
            if (Error != null)
                Error = Error.Elements ().FirstOrDefault ();

            ResponseDescription = response.GetElementPathValue (WebDavNames.ResponseDescription);
            Location            = response.GetElementPathValue (WebDavNames.Location, WebDavNames.Href);
        }
        private static void AddColour(XElement liElement, XNamespace defaultNamespace, XNamespace xNamespace, XDocument doc, string swatchName="")
        {
            var name = liElement.Elements("span").First().Value;
            var hex = liElement.Elements("span").Last().Value;

            var prefix = "Primary";
            if (name.StartsWith("A"))
            {
                prefix = "Accent";
                name = name.Skip(1).Aggregate("", (current, next) => current + next);
            }

            var backgroundColourElement = new XElement(defaultNamespace + "Color", hex);
            // new XAttribute()
            backgroundColourElement.Add(new XAttribute(xNamespace + "Key", string.Format("{0}{1}{2}", swatchName, prefix, name)));
            doc.Root.Add(backgroundColourElement);

            var liClass = liElement.Attribute("class").Value;
            Color foregroundColour;
            if (!ClassNameToForegroundIndex.TryGetValue(liClass, out foregroundColour))
                throw new Exception("Unable to map foreground color from class " + liClass);

            var foreGroundColorHex = string.Format("#{0}{1}{2}{3}",
                ByteToHex(foregroundColour.A),
                ByteToHex(foregroundColour.R),
                ByteToHex(foregroundColour.G),
                ByteToHex(foregroundColour.B));

            var foregroundColourElement = new XElement(defaultNamespace + "Color", foreGroundColorHex);
            foregroundColourElement.Add(new XAttribute(xNamespace + "Key", string.Format("{0}{1}{2}Foreground", swatchName, prefix, name)));
            doc.Root.Add(foregroundColourElement);
        }
Example #24
0
		public static void Parse(dynamic parent, XElement node)
		{
			foreach (var a in node.Attributes())
				AddProperty(parent, a.Name.ToString(), a.Value);
			if (node.HasElements)
			{
				IEnumerable<XElement> sorted = from XElement elt in node.Elements() orderby node.Elements(elt.Name.LocalName).Count() descending select elt;
				string elementName = string.Empty;
				List<dynamic> list = null;
				foreach (var element in sorted)
				{
					var item = new ExpandoObject();
					Parse(item, element);
					if (element.Name.LocalName != elementName)
					{
						list = null;
						AddProperty(parent, elementName = element.Name.LocalName, item);
					}
					else
						if (list == null)
							AddProperty(parent, element.Name.LocalName, list = new List<dynamic>() { (parent as IDictionary<string, object>)[element.Name.LocalName], item });
						else
							list.Add(item);
				}
			}
			else if (!string.IsNullOrWhiteSpace(node.Value))
				AddProperty(parent, "TextValue", node.Value.Trim());
		}
Example #25
0
        /// <summary>
        /// Parses a single csdl/ssdl file.
        /// </summary>
        /// <param name="model">the entity model schema which the csdl/ssdl file parses to</param>
        /// <param name="schemaElement">the top level schema element in the csdl/ssdl file</param>
        protected virtual void ParseSingleXsdl(EntityModelSchema model, XElement schemaElement)
        {
            this.AssertXsdlElement(schemaElement, "Schema");

            this.SetupNamespaceAndAliases(schemaElement);

            foreach (var entityContainerElement in schemaElement.Elements().Where(el => this.IsXsdlElement(el, "EntityContainer")))
            {
                model.Add(this.ParseEntityContainer(entityContainerElement));
            }

            foreach (var entityTypeElement in schemaElement.Elements().Where(el => this.IsXsdlElement(el, "EntityType")))
            {
                model.Add(this.ParseEntityType(entityTypeElement));
            }

            foreach (var associationTypeElement in schemaElement.Elements().Where(el => this.IsXsdlElement(el, "Association")))
            {
                model.Add(this.ParseAssociation(associationTypeElement));
            }

            foreach (var functionElement in schemaElement.Elements().Where(el => this.IsXsdlElement(el, "Function")))
            {
                model.Add(this.ParseFunction(functionElement));
            }
        }
Example #26
0
 private static bool ProcessAttachElement(XElement attach)
 {
     // Basic lement is here - it is namespace which we add to all element names
     XNamespace ns = "http://schemas.microsoft.com/exchange/services/2006/types";
     bool hasChanges = false;
     if (!attach.Elements().Any(el => el.Name.LocalName == "LastModifiedTime"))
     {
         XElement elem = new XElement(ns + "LastModifiedTime");
         elem.Name = ns + "LastModifiedTime";
         elem.Value = "2015-11-30T13:29:11.6088823+03:00";
         attach.Add(elem);
         hasChanges = true;
     }
     if (!attach.Elements().Any(el => el.Name.LocalName == "IsContactPhoto"))
     {
         XElement elem = new XElement(ns + "IsContactPhoto");
         elem.Name = ns +"IsContactPhoto";
         elem.Value = "false";
         attach.Add(elem);
         hasChanges = true;
     }
     else
     {
         if (attach.Elements().First(el => el.Name.LocalName == "IsContactPhoto").Value == "False")
         {
             attach.Elements().First(el => el.Name.LocalName == "IsContactPhoto").Value = "false";
             hasChanges = true;
         }
     }
     return hasChanges;
 }
Example #27
0
 public Service(XElement baseElement, Product parent)
 {
     _nameAndRev = baseElement.Elements(_ns + "span").Nodes().OfType<XText>().FirstOrDefault();
       _amountSpan = baseElement.Elements(_ns + "span").Elements(_ns + "span").Nodes().OfType<XText>().ToList();
       _options = new List<Option>();
       Product = parent;
 }
        public void LoadFromXml(XElement xmlElement)
        {
            IdManager idManager = IdManager.GetIdManager();

            InventoryItems = new List<InventoryItem>();

            foreach (XElement inventoryItemsElement in xmlElement.Elements("InventoryItems"))
            {
                foreach (XElement inventoryItemElement in inventoryItemsElement.Elements("InventoryItem"))
                {
                    InventoryItem inventoryItem = new InventoryItem();

                    inventoryItem.LoadFromXml(inventoryItemElement);

                    InventoryItems.Add(inventoryItem);
                }
            }

            foreach (var locationsElement in xmlElement.Elements("Locations"))
            {
                foreach (var locationElement in locationsElement.Elements("Location"))
                {
                    Location location = new Location();

                    location.LoadFromXml(locationElement);

                    Locations.Add(location);

                    idManager.RegisterId(location, location.Id);
                }
            }

            MerryUpLocationsWithInventoryItems();
        }
Example #29
0
        private static Department HandleDepartment(XElement xml)
        {
            var d = new Department();
            var name = xml.Elements("Name").First().Value;
            d.Name = name;
            d.Manager = HandleEmployee(xml.Elements("Manager").FirstOrDefault());

            var xmlEmployees = xml.Elements("Employees");
            if (xmlEmployees.Elements().Count() > 0)
            {
                foreach (var xmlEmployee in xmlEmployees.Elements("Employee"))
                {
                    d.Employees.Add(HandleEmployee(xmlEmployee));
                }
            }

            var xmlSubUnits = xml.Elements("SubDepartments");
            if (xmlSubUnits.Elements().Count() > 0)
            {
                foreach (var xmlSubUnit in xmlSubUnits.Elements("Department"))
                {
                    d.SubDepartments.Add(HandleDepartment(xmlSubUnit));
                }
            }

            return d;
        }
        public void Initialise(XElement xElement, IDocumentAccessor accessor)
        {
            xElement = Persistence.ThisOrSingleChild(XName, xElement);

            var identity = Persistence.Identity.Parse(xElement, accessor);

            SetIdentity(identity);

            var xComponentType = xElement
                .Elements("ComponentType")
                .SingleOrDefault();

            ComponentType.Initialise(xComponentType, accessor);

            var xEngineType = xElement
                .Elements("EngineType")
                .SingleOrDefault();

            EngineType.Initialise(xEngineType, accessor);

            UseNativeEngine = Utilities.Xml.GetAttribute(xElement, "useNativeEngine", false);

            Arguments = Persistence.Arguments
                .Parse(xElement, accessor)
                .ToList();

            Inputs = Persistence.Inputs
                .Parse(xElement, accessor)
                .ToList();

            Outputs = Persistence.Outputs
                .Parse(xElement, accessor)
                .ToList();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SectionDefinition"/> class.
        /// </summary>
        /// <param name="element">The XML-element to read the data from.</param>
        public SectionDefinition(XElement element)
            : this()
        {
            this.SectionString.String = element.TryGetAttributeValue("Text", null);

            // Parse the aspects...
            foreach (XElement aspectE in element.Elements("Aspect"))
            {
                SectionParserDefinition spDefinition = new SectionParserDefinition(aspectE);
                if (string.IsNullOrWhiteSpace(spDefinition.Type))
                {
                    // TODO: Log warning
                    continue;
                }

                this.Parsers.Add(spDefinition);
            }

            // Parse the areas...
            foreach (XElement areaE in element.Elements("Area"))
            {
                AreaDefinition areaDefinition = new AreaDefinition(areaE);
                if (!areaDefinition.IsValidDefinition())
                {
                    // TODO: Log warning
                    continue;
                }

                this.Areas.Add(areaDefinition);
            }
        }
Example #32
0
		internal static void SortMainRtElement(XElement rootData)
		{
			var className = rootData.Attribute(SharedConstants.Class).Value;
			var classInfo = MetadataCache.MdCache.GetClassInfo(className);

			// Get collection properties for the class.
			var collData = (from collProp in classInfo.AllCollectionProperties select collProp.PropertyName).ToList();
			var multiAltData = (from multiAltProp in classInfo.AllMultiAltProperties select multiAltProp.PropertyName).ToList();

			var sortedPropertyElements = new SortedDictionary<string, XElement>();
			foreach (var propertyElement in rootData.Elements())
			{
				var propName = propertyElement.Name.LocalName;
				// <Custom name="Certified" val="True" />
				if (propName == SharedConstants.Custom)
					propName = propertyElement.Attribute(SharedConstants.Name).Value; // Sort custom props by their name attrs.
				if (collData.Contains(propName))
					SortCollectionProperties(propertyElement);
				if (multiAltData.Contains(propName))
					SortMultiSomethingProperty(propertyElement);
				sortedPropertyElements.Add(propName, propertyElement);
			}
			rootData.Elements().Remove();
			foreach (var kvp in sortedPropertyElements)
				rootData.Add(kvp.Value);

			// 3. Sort attributes at all levels.
			SortAttributes(rootData);
		}
Example #33
0
        private static void RemoveSCCElementsAttributes(System.Xml.Linq.XElement el)
        {
            el.Elements().Where(x => x.Name.LocalName.StartsWith("Scc")).Remove();
            el.Attributes().Where(x => x.Name.LocalName.StartsWith("Scc")).Remove();

            foreach (var child in el.Elements())
            {
                RemoveSCCElementsAttributes(child);
            }
        }
Example #34
0
        public override void FromXML(System.Xml.Linq.XElement xParameters)
        {
            base.FromXML(xParameters);

            foreach (XElement group in xParameters.Elements("group"))
            {
                this.Groups.Add(new dmGroup(this, group));
            }
            foreach (XElement ruleset in xParameters.Elements("ruleset"))
            {
                this.Rulesets.Add(new dmRuleset(this, ruleset));
            }
        }
Example #35
0
        public static Effect ParseEffect(System.Xml.Linq.XElement effectNode)
        {
            Effect action = entity => { };

            foreach (XElement prop in effectNode.Elements())
            {
                switch (prop.Name.LocalName)
                {
                case "Pause":
                    action += entity =>
                    {
                        entity.GetComponent <InputComponent>().Paused = true;
                    };
                    break;

                case "Unpause":
                    action += entity =>
                    {
                        entity.GetComponent <InputComponent>().Paused = false;
                    };
                    break;
                }
            }

            return(action);
        }
Example #36
0
        public object ParseArgumentValue(System.Xml.Linq.XElement ele)
        {
            if (ele == null)
            {
                return(null);
            }
            IEnumerable <XElement> elements = ele.Elements("ValueItem");

            if (elements != null && elements.Count() > 0)
            {
                string name;
                defaultArgs = new List <string>();
                foreach (XElement item in elements)
                {
                    name = item.Attribute("name").Value.ToUpper();
                    foreach (Control tb in this.Controls)
                    {
                        if (tb is TextBox)
                        {
                            if (tb.Name.Contains(name))
                            {
                                tb.Text = item.Attribute("value").Value;
                                defaultArgs.Add(tb.Text);
                            }
                        }
                    }
                }
            }
            return(null);
        }
Example #37
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Label  lblID      = (Label)GridView1.Rows[e.RowIndex].FindControl("lblID");
            string UserID     = Session["UserID"].ToString();
            string pathA      = ConfigurationManager.AppSettings["attactFile"].ToString();
            string pathServer = pathA + @"\XMLFileProjectN.xml";

            System.Xml.Linq.XElement XDoc = System.Xml.Linq.XElement.Load(pathServer);

            IEnumerable <System.Xml.Linq.XElement> Query = (from Q in XDoc.Elements("AttactID")
                                                            where Q.Element("ID").Value == lblID.Text.Trim() && Q.Element("UserID").Value == UserID
                                                            select Q).Distinct();

            if (Query.Count() > 0)
            {
                foreach (System.Xml.Linq.XElement X in Query)
                {
                    X.Remove();
                }


                XDoc.Save(pathServer);
            }
            HienThiDanhSachFileDinhKemTam();
        }
        public static DgShapeInfo FromXml(Client client, SXL.XElement shape_el)
        {
            var info = new DgShapeInfo();

            info.ID = shape_el.Attribute("id").Value;
            client.Output.WriteVerbose("Reading shape id={0}", info.ID);

            info.Label   = shape_el.Attribute("label").Value;
            info.Stencil = shape_el.Attribute("stencil").Value;
            info.Master  = shape_el.Attribute("master").Value;
            info.Element = shape_el;
            info.Url     = shape_el.GetAttributeValue("url", null);

            info.CustProps = new CustomPropertyDictionary();
            foreach (var customprop_el in shape_el.Elements("customprop"))
            {
                string cp_name  = customprop_el.Attribute("name").Value;
                string cp_value = customprop_el.Attribute("value").Value;

                var cp = new CustomPropertyCells();
                cp.Value = cp_value;

                info.CustProps.Add(cp_name, cp);
            }

            return(info);
        }
Example #39
0
        public static ShapeInfo FromXml(Client client, SXL.XElement shape_el)
        {
            var info = new ShapeInfo();

            info.ID = shape_el.Attribute("id").Value;
            client.WriteVerbose("Reading shape id={0}", info.ID);

            info.Label   = shape_el.Attribute("label").Value;
            info.Stencil = shape_el.Attribute("stencil").Value;
            info.Master  = shape_el.Attribute("master").Value;
            info.Element = shape_el;
            info.URL     = VA.Scripting.XmlUtil.GetAttributeValue(shape_el, "url", null);

            info.custprops = new Dictionary <string, VACUSTPROP.CustomPropertyCells>();
            foreach (var customprop_el in shape_el.Elements("customprop"))
            {
                string cp_name  = customprop_el.Attribute("name").Value;
                string cp_value = customprop_el.Attribute("value").Value;

                var cp = new VACUSTPROP.CustomPropertyCells();
                cp.Value = cp_value;

                info.custprops.Add(cp_name, cp);
            }

            return(info);
        }
Example #40
0
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Xml.Linq.XElement xeResources = null;
        commonCulture.appData.getLocalResource(out xeResources);
        customConfig.OperatorSettings opSettings = new customConfig.OperatorSettings("W88");
        string strLPNumber = string.Empty;
        string strAppKey   = string.Empty;
        string strSkill    = string.Empty;

        System.Web.UI.WebControls.Literal litScript = (System.Web.UI.WebControls.Literal)Page.FindControl("litScript");

        if (!Page.IsPostBack)
        {
            System.Text.StringBuilder sbJSDictionary = new System.Text.StringBuilder();
            foreach (System.Xml.Linq.XElement xeLabel in xeResources.Elements())
            {
                sbJSDictionary.Append("dictionary.setData('" + xeLabel.Name + "', '" + xeLabel.Value + "');");
            }

            strLPNumber = opSettings.Values.Get("LPNumber");
            strAppKey   = opSettings.Values.Get("LPAppKey");
            strSkill    = commonCulture.ElementValues.getResourceString("lblSkill", xeResources);

            btnSend.InnerText    = commonCulture.ElementValues.getResourceString("btnSend", xeResources);
            btnReqChat.InnerText = commonCulture.ElementValues.getResourceString("btnReqChat", xeResources);
            btnEndChat.InnerText = commonCulture.ElementValues.getResourceString("btnEndChat", xeResources);
            //LPVariables.SessionId = '" + System.Guid.NewGuid().ToString().ToUpper() + "';
            if (litScript != null)
            {
                litScript.Text += "<script type='text/javascript'> $(function () { LPVariables.LPNumber = '" + strLPNumber + "'; LPVariables.AppKey = '" + commonEncryption.decrypting(strAppKey) + "'; LPVariables.Skill = '" + strSkill + "'; LPVariables.VisitorName = '" + base.userInfo.MemberCode + "'; LPVariables.SessionId = '" + System.Guid.NewGuid().ToString().ToUpper() + "'; " + Convert.ToString(sbJSDictionary) + " });</script>";
            }
        }
    }
Example #41
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Label  lblID      = (Label)GridView1.Rows[e.RowIndex].FindControl("lblID");
            string UserID     = Session["UserID"].ToString();
            string pathA      = ConfigurationManager.AppSettings["attactFile"].ToString();
            string pathServer = pathA + @"\XMLFileSystem.xml";

            //System.Xml.Linq.XElement XDoc = System.Xml.Linq.XElement.Load(Server.MapPath("~/XML/XMLFileSystem.xml"));
            System.Xml.Linq.XElement XDoc = System.Xml.Linq.XElement.Load(pathServer);

            IEnumerable <System.Xml.Linq.XElement> Query = (from Q in XDoc.Elements("AttactID")
                                                            where Q.Element("ID").Value == lblID.Text.Trim() && Q.Element("UserID").Value == UserID
                                                            select Q).Distinct();


            // Check the count is grether thae equal 1
            if (Query.Count() > 0)
            {
                // Remove the element
                foreach (System.Xml.Linq.XElement X in Query)
                {
                    X.Remove();
                }

                // Save the Xml File
                //XDoc.Save(Server.MapPath("~/XML/XMLFileSystem.xml"));
                // XDoc.Save(Server.MapPath("~/AttactFilePDN/XML/XMLFileSystem.xml"));
                XDoc.Save(pathServer);
            }

            HienThiFileDinhKem();
        }
        public static IEnumerable <SXL.XElement> ElementsVisioSchema2003(this SXL.XElement el, string name)
        {
            string fullname  = string.Format("{0}{1}", Constants.VisioXmlNamespace2003, name);
            var    child_els = el.Elements(fullname);

            return(child_els);
        }
Example #43
0
        public object ParseArgumentValue(System.Xml.Linq.XElement ele)
        {
            //解析区域及初始化公式
            var eles = ele.Elements("Region");

            if (eles == null)
            {
                return(null);
            }
            _stageRegions = new List <StageRegionDef>();
            string         name        = null;
            string         formula     = null;
            string         envlopeStr  = null;
            StageRegionDef stageRegion = null;

            foreach (XElement item in eles)
            {
                name                = item.Attribute("name").Value;
                formula             = item.Attribute("formula").Value;
                envlopeStr          = item.Attribute("envelope").Value;
                stageRegion         = new StageRegionDef(name, formula);
                stageRegion.Evelope = GetRegionEnvelope(envlopeStr);
                if (!_stageRegions.Contains(stageRegion))
                {
                    _stageRegions.Add(stageRegion);
                }
            }
            return(_stageRegions);
        }
Example #44
0
        public static Value ParseXml(SXL.XElement value_el)
        {
            if (value_el.Name != "value")
            {
                string msg = string.Format("XML Element should have name \"value\" instead found \"{0}\"", value_el.Name);
                throw new XmlRPCException();
            }

            var input_value = value_el.Value;

            if (value_el.HasElements)
            {
                var type_el = value_el.Elements().First();

                string typename = type_el.Name.ToString();
                if (typename == Array.TypeString)
                {
                    return(Array.XmlToValue(type_el));
                }
                else if (typename == Struct.TypeString)
                {
                    return(Struct.XmlToValue(type_el));
                }
                else if (typename == StringValue.TypeString)
                {
                    return(StringValue.XmlToValue(type_el));
                }
                else if (typename == DoubleValue.TypeString)
                {
                    return(DoubleValue.XmlToValue(type_el));
                }
                else if (typename == Base64Data.TypeString)
                {
                    return(Base64Data.XmlToValue(type_el));
                }
                else if (typename == DateTimeValue.TypeString)
                {
                    return(DateTimeValue.XmlToValue(type_el));
                }
                else if (typename == IntegerValue.TypeString || typename == IntegerValue.AlternateTypeString)
                {
                    return(IntegerValue.XmlToValue(type_el));
                }
                else if (typename == BooleanValue.TypeString)
                {
                    return(BooleanValue.XmlToValue(type_el));
                }
                else
                {
                    string msg = string.Format("Unsupported type: {0}", typename);
                    throw new XmlRPCException(msg);
                }
            }
            else
            {
                // no <type> element provided. Treat the content as a string
                return(new StringValue(input_value));
            }
        }
Example #45
0
        public Exception CreateExceptionFromError(System.Xml.Linq.XElement element)
        {
            Debug.Assert(element != null, "element != null");
            string    message = element.Elements().Where(e => e.Name.LocalName == "message").Single().Value;
            Exception result  = new Exception(message);

            return(result);
        }
        public void LoadMenu(System.Xml.Linq.XElement data)
        {
            this.Clear();

            foreach (XElement item in data.Elements())
            {
                CreateMenuItem(item, this);
            }
        }
Example #47
0
        public string ExtraerValorDeNodoXml(System.Xml.Linq.XElement elemento, string nombre, bool retornarCero = false)
        {
            try
            {
                string[] nombres = nombre.Split('/');
                string   valor   = "";

                if (nombres.Length == 1)
                {
                    valor = elemento.Elements().Where(m => m.Name.LocalName == nombres[0]).FirstOrDefault().Value;
                }
                else if (nombres.Length == 2)
                {
                    valor = elemento.Elements().Where(m => m.Name.LocalName == nombres[0]).FirstOrDefault()
                            .Elements().Where(m => m.Name.LocalName == nombres[1]).FirstOrDefault().Value;
                }
                else if (nombres.Length == 3)
                {
                    valor = elemento.Elements().Where(m => m.Name.LocalName == nombres[0]).FirstOrDefault()
                            .Elements().Where(m => m.Name.LocalName == nombres[1]).FirstOrDefault()
                            .Elements().Where(m => m.Name.LocalName == nombres[2]).FirstOrDefault().Value;
                }
                else if (nombres.Length == 4)
                {
                    valor = elemento.Elements().Where(m => m.Name.LocalName == nombres[0]).FirstOrDefault()
                            .Elements().Where(m => m.Name.LocalName == nombres[1]).FirstOrDefault()
                            .Elements().Where(m => m.Name.LocalName == nombres[2]).FirstOrDefault()
                            .Elements().Where(m => m.Name.LocalName == nombres[3]).FirstOrDefault().Value;
                }

                return(valor);
            }
            catch (Exception ex)
            {
                if (retornarCero)
                {
                    return("0");
                }
                else
                {
                    return("");
                }
            }
        }
Example #48
0
        public override void Build(Test.PanelSetOrder panelSetOrder, System.Xml.Linq.XElement panelSetOrderElement)
        {
            List <XElement> markerElements = (from item in panelSetOrderElement.Elements("FlowMarkerCollection")
                                              select item).ToList <XElement>();

            foreach (XElement markerElement in markerElements.Elements("FlowMarker"))
            {
                Flow.FlowMarkerItem flowMarkerItem = new Flow.FlowMarkerItem();
                YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriter = new YellowstonePathology.Business.Persistence.XmlPropertyWriter(markerElement, flowMarkerItem);
                xmlPropertyWriter.Write();
                ((Test.LLP.PanelSetOrderLeukemiaLymphoma)panelSetOrder).FlowMarkerCollection.Add(flowMarkerItem);
            }
        }
    protected override void ParseElementConditions(System.Xml.Linq.XElement elemtype, ContentConfiguration <T> .Content content)
    {
        var elemRandoms = elemtype.Elements("random");

        foreach (XElement elemRandom in elemRandoms)
        {
            //right now, we don't actuallyu care about any parameters
            int        seed      = items.Count;
            RandomItem item      = new RandomItem();
            XAttribute elemScale = elemRandom.Attribute("scale");
            if (elemScale != null)
            {
                float scale = 1;
                float.TryParse(elemScale.Value, out scale);
                item.scale_x = scale;
                item.scale_y = scale;
                item.scale_z = scale;
            }
            XAttribute elemScaleX = elemRandom.Attribute("scale_x");
            if (elemScaleX != null)
            {
                float scale = 1;
                float.TryParse(elemScaleX.Value, out scale);
                item.scale_x = scale;
            }
            XAttribute elemScaleY = elemRandom.Attribute("scale_y");
            if (elemScaleY != null)
            {
                float scale = 1;
                float.TryParse(elemScaleY.Value, out scale);
                item.scale_y = scale;
            }
            XAttribute elemScaleZ = elemRandom.Attribute("scale_z");
            if (elemScaleZ != null)
            {
                float scale = 1;
                float.TryParse(elemScaleZ.Value, out scale);
                item.scale_z = scale;
            }
            XAttribute elemIntensity = elemRandom.Attribute("intensity");
            if (elemIntensity != null)
            {
                float scale = 1;
                float.TryParse(elemIntensity.Value, out scale);
                item.intensity = scale;
            }
            item.content = content;
            item.noise   = new OpenSimplexNoise(seed);
            items.Add(item);
        }
    }
Example #50
0
        private void saveNodeData(string thisID)
        {
            //IEnumerable<XElement> items  = getIDNodes(thisID);

            if (xTree == null)
            {
                xTree = new XElement("root", "");
            }
            XElement xEtappe = makeNewXEtappe(thisID);

            if (!(geaendert || picBsChanged))
            {
                return;
            }

/**********
*       // Etappe hinzufügen oder ersetzen ?
*       DialogResult result = new DialogResult();
*       if (etappeExist(xEtappe))
*               {result = MessageBox.Show("Etappe existiert schon - überschreiben?",
*                                  "Etappe existiert", MessageBoxButtons.YesNoCancel );
*               switch (result) {
*                       case DialogResult.Yes:
*                               break;
*                       case DialogResult.No:
*                               return;
*                       case DialogResult.Cancel:
*                               return;
*               }
*       } else {
**********/
            if (etappeExist(xEtappe)) // etappeExist erzeugt ggf. itemsID
            // etappe überschreiben:
            {
                foreach (XElement xelem in xTree.Elements())
                {
                    if (xelem.Element("ID").Value == thisID)
                    {
                        xelem.ReplaceWith(xEtappe);
                        continue;       // nur einmal, IDs sind eindeutig
                    }
                }
            }
            else
            {
                xTree.Add(xEtappe);
            }
            xTree.Save(XMLfile);
            picBsChanged = false;
            geaendert    = false;
        }
            public Row(XE rowElement)
            {
                var columns = rowElement.Elements(C.Col).ToArray();

                Columns = new Dictionary <string, string>();

                foreach (var c in columns)
                {
                    var typeAttribute = ExpectAttribute(c, C.type);
                    var key           = FieldTypes.AssertString(c.Value);
                    var value         = FieldTypes.AssertString(typeAttribute.Value);
                    Columns.Add(key, value);
                }
            }
Example #52
0
        public object ParseArgumentValue(System.Xml.Linq.XElement ele)
        {
            var    argEle  = ele.Elements("ArgFile");
            string argFile = "";

            if (argEle != null && argEle.Count() != 0)
            {
                argFile = argEle.ToArray()[0].Value;
            }
            if (!string.IsNullOrEmpty(argFile))
            {
                _argsFilename = argFile.StartsWith("\\") ? AppDomain.CurrentDomain.BaseDirectory + argFile : argFile;
            }
            return(GetArgumentValue());
        }
Example #53
0
        private void Transit(System.Xml.Linq.XElement expression)
        {
            if (expression == null)
            {
                return;
            }

            if (expression.Elements().Any())
            {
                foreach (var element in expression.Elements())
                {
                    Transit(element);
                }
            }
            var attirbs = from attirb in expression.Attributes()
                          where attirb.Value == typeof(DTO).FullName
                          select attirb;

            foreach (var attrib in attirbs)
            {
                attrib.Value = typeof(Entity).FullName;
                //expression.ReplaceAttributes(new XAttribute("Name", typeof(Entity).FullName));
            }
        }
Example #54
0
        protected override void LoadConfig(System.Xml.Linq.XElement moduleEl)
        {
            base.LoadConfig(moduleEl);

            foreach (var userEl in moduleEl.Elements("user"))
            {
                var user = new User();
                BotModule.LoadProperties(user, userEl);
                if (_userIndex.ContainsKey(user.Name))
                {
                    throw new BotConfigException(string.Format(
                                                     "There are multiple users with the name {0}.", user.Name));
                }
                _users.Add(user);
                _userIndex.Add(user.Name, user);
            }
        }
Example #55
0
        public static Struct XmlToValue(SXL.XElement type_el)
        {
            var member_els = type_el.Elements("member").ToList();
            var struct_    = new Struct();

            foreach (var member_el in member_els)
            {
                var    name_el = member_el.GetElement("name");
                string name    = name_el.Value;

                var value_el2 = member_el.GetElement("value");
                var o         = Value.ParseXml(value_el2);

                struct_[name] = o;
            }
            return(struct_);
        }
Example #56
0
    protected void Page_Load(object sender, EventArgs e)
    {
        commonCulture.appData.getRootResource("/Slots/Default.aspx", out xeResources);

        if (Page.IsPostBack)
        {
            return;
        }

        SetTitle(commonCulture.ElementValues.getResourceXPathString("/Products/ClubCrescendo/Label", commonVariables.ProductsXML));
        System.Text.StringBuilder sbGames = new System.Text.StringBuilder();

        System.Xml.Linq.XElement xeCategories = xeResources.Element("Category");

        bool collapsed = false;

        foreach (System.Xml.Linq.XElement xeCategory in xeCategories.Elements())
        {
            sbGames.AppendFormat("<div data-role='collapsible' data-collapsed='false' data-theme='b' data-content-theme='a' data-mini='true'><h4>{0}</h4>", xeCategory.Attribute("Label").Value);

            sbGames.AppendFormat("<div id='div{0}' class='div-product'><div><ul>", xeCategory.Name);

            foreach (System.Xml.Linq.XElement xeGame in xeCategory.Elements())
            {
                sbGames.AppendFormat("<li class='bkg-game'><div rel='{0}-{1}.jpg'><div class='div-links'>", xeCategory.Name, xeGame.Name);

                if (string.IsNullOrEmpty(commonVariables.CurrentMemberSessionId))
                {
                    sbGames.AppendFormat("<a target='_blank' href='/_Secure/Login.aspx?redirect=" + Server.UrlEncode("/ClubCrescendo") + "' data-rel='dialog' data-transition='slidedown'>");
                }
                else
                {
                    sbGames.AppendFormat("<a href='{0}' target='_blank'>", commonCulture.ElementValues.getResourceString("PlayForRealURL", xeGame).Replace("{SlotsUrl}", commonClubCrescendo.getSlotsUrl).Replace("{token}", commonVariables.CurrentMemberSessionId));
                }

                sbGames.AppendFormat("{0}</a>", commonCulture.ElementValues.getResourceXPathString("/Products/Play", commonVariables.ProductsXML));
                sbGames.AppendFormat("<a target='_blank' href='{1}' data-ajax='false'>{0}</a></div>", commonCulture.ElementValues.getResourceXPathString("/Products/Try", commonVariables.ProductsXML), commonCulture.ElementValues.getResourceString("PlayForFunURL", xeGame).Replace("{SlotsUrl}", commonClubCrescendo.getSlotsUrl).Replace("{token}", commonVariables.CurrentMemberSessionId));
                sbGames.Append("</div></li>");
            }

            sbGames.Append("</ul></div></div></div>");
            collapsed = true;
        }

        divContainer.InnerHtml = Convert.ToString(sbGames);
    }
Example #57
0
        public object ParseArgumentValue(System.Xml.Linq.XElement ele)
        {
            List <string>          templates = new List <string>();
            IEnumerable <XElement> node      = ele.Elements("Value");

            if (node != null && node.Count() != 0)
            {
                foreach (XElement item in node)
                {
                    string value = item.Value;
                    if (!string.IsNullOrEmpty(value))
                    {
                        templates.Add(value);
                    }
                }
                return(templates.ToArray());
            }
            return(null);
        }
Example #58
0
    //Core recursion function
    private static System.Xml.Linq.XElement RemoveAllNamespaces(System.Xml.Linq.XElement xmlDocument)
    {
        if (xmlDocument.HasAttributes)
        {
            xmlDocument.RemoveAttributes();
        }
        if (!xmlDocument.HasElements)
        {
            System.Xml.Linq.XElement xElement = new System.Xml.Linq.XElement(xmlDocument.Name.LocalName);
            xElement.Value = xmlDocument.Value;

            foreach (System.Xml.Linq.XAttribute attribute in xmlDocument.Attributes())
            {
                xElement.Add(attribute);
            }

            return(xElement);
        }
        return(new System.Xml.Linq.XElement(xmlDocument.Name.LocalName, xmlDocument.Elements().Select(el => RemoveAllNamespaces(el))));
    }
Example #59
0
        public object ParseArgumentValue(System.Xml.Linq.XElement ele)
        {
            IEnumerable <XElement> node       = ele.Elements("ValueItem");
            List <string>          areaRegion = new List <string>();

            if (node != null && node.Count() != 0)
            {
                foreach (XElement item in node)
                {
                    string value = item.Attribute("value").Value;
                    if (!string.IsNullOrEmpty(value))
                    {
                        areaRegion.Add(value);
                        lsbAreaRegion.Items.Add(value);
                    }
                }
                return(areaRegion.ToArray());
            }
            return(null);
        }
Example #60
0
        public object ParseArgumentValue(System.Xml.Linq.XElement ele)
        {
            IEnumerable <XElement> node     = ele.Elements("ValueItem");
            List <string>          infoType = new List <string>();

            if (node != null && node.Count() != 0)
            {
                foreach (XElement item in node)
                {
                    string value = item.Attribute("value").Value;
                    if (!string.IsNullOrEmpty(value))
                    {
                        infoType.Add(value);
                        cmbType.Items.Add(value);
                    }
                }
                cmbType.SelectedIndex = 0;
                return(infoType.ToArray());
            }
            return(null);
        }