Beispiel #1
0
 public static TinyMceFontConfig From(XElement xml)
 {
     return new TinyMceFontConfig(
         xml.AttributeValue("culture"),
         xml.AttributeValue("fonts")
     );
 }
        public void GetAttributeValueTest0()
        {
            var e1 = new XElement("Foo");
            Assert.AreEqual("beer", e1.AttributeValue("a1", "beer"));

            e1.SetAttributeValue("a1", "baz");
            Assert.AreEqual("baz", e1.AttributeValue("a1", "beer"));
        }
Beispiel #3
0
 public DomElement(XElement el) {
   name = el.Name.LocalName;
   cls = el.AttributeValue("class");
   id = el.AttributeValue("id");
   if (name != typeof(body).Name) parent = new DomElement(el.Parent);
   uniqueId = cnt++.ToString();
   this.el = el;
 }
        public void GetAttributeValueTest1()
        {
            var e1 = new XElement("Foo");
            Assert.AreEqual(2, e1.AttributeValue<int>("a1", 2, s => int.Parse(s)));

            e1.SetAttributeValue("a1", "4");
            Assert.AreEqual(4, e1.AttributeValue<int>("a1", 2, s => int.Parse(s)));
            Assert.AreEqual(4.0, e1.AttributeValue<double>("a1", 2, s => double.Parse(s)));
        }
Beispiel #5
0
 internal static EntitySet FromXml(XElement xml)
 {
     if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml was not an EntitySet element");
     var obj = new EntitySet
     {
         Name = xml.AttributeValue("Name"),
         EntityType = xml.AttributeValue("EntityType")
     };
     return obj;
 }
Beispiel #6
0
        public static Annotation FromXml(XElement xml)
        {
            if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml was not an Annotation element");

            var obj = new Annotation
            {
                Term = xml.AttributeValue("Term"),
                String = xml.AttributeValue("String")
            };
            return obj;
        }
        public static int AssemblyPosition(XElement element)
        {
            var targetFilename = element.AttributeValue("targetFilename");
            if (targetFilename != null)
                return AssemblyPosition(Path.GetFileName(targetFilename));

            var path = element.AttributeValue("path");
            if (path != null)
                return AssemblyPosition(Path.GetFileName(path));

            return 0;
        }
Beispiel #8
0
        internal static ReturnType FromXml(XElement xml)
        {
            if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml wasn't a ReturnType element");

            var obj = new ReturnType
            {
                Type = xml.AttributeValue("Type"),
                Nullable = xml.AttributeValue("Nullable").ToBoolean()
            };

            return obj;
        }
Beispiel #9
0
        public static Property FromXml(XElement xml)
        {
            if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml wasn't a Property element");

            var obj = new Property
            {
                Name = xml.AttributeValue("Name"),
                Type = xml.AttributeValue("Type"),
                Nullable = xml.AttributeValue("Nullable").ToBoolean()
            };

            return obj;
        }
Beispiel #10
0
        public static Term FromXml(XElement xml)
        {
            if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml was not a Term element");

            var obj = new Term
            {
                Name = xml.AttributeValue("Name"),
                Type = xml.AttributeValue("Type"),
                AppliesTo = xml.AttributeValue("AppliesTo")
            };
            obj.Annotations.AddRange(from e in xml.Elements()
                                     where e.Name.LocalName == Annotation.ElementName
                                     select Annotation.FromXml(e));
            return obj;
        }
        public CruiseControlNetBuildStatus(XElement projectElem)
        {
            Name = BuildDefinitionId = projectElem.AttributeValue("name");

            BuildStatusInfo buildStatusInfo;
            if (!_buildStatusInfo.TryGetValue(BuildDefinitionId, out buildStatusInfo))
            {
                buildStatusInfo = new BuildStatusInfo();
                _buildStatusInfo.Add(BuildDefinitionId, buildStatusInfo);
            }

            var lastBuildTimeStr = projectElem.AttributeValueOrDefault("lastBuildTime");
            DateTime dt;
            DateTime? lastBuildTime = null;
            if (DateTime.TryParse(lastBuildTimeStr, out dt))
            {
                lastBuildTime = dt;
            }

            BuildStatusEnum = ToBuildStatusEnum(projectElem.AttributeValueOrDefault("activity"), projectElem.AttributeValueOrDefault("lastBuildStatus"));
            StartedTime = GetStartedTime(buildStatusInfo, BuildStatusEnum, lastBuildTime);
            FinishedTime = GetFinishedTime(buildStatusInfo, BuildStatusEnum, lastBuildTime);
            Comment = null;
            RequestedBy = GetRequestedBy(projectElem);

            var webUrl = projectElem.AttributeValueOrDefault("webUrl");
            string lastBuildTimeAsId = ParseCruiseControlDateToId(lastBuildTimeStr);
            Url = string.Format("{0}/server/local/project/{1}/build/log{2}.xml/ViewBuildReport.aspx", webUrl, Name, lastBuildTimeAsId);
            BuildId = GetBuildIdOrDefault(projectElem, lastBuildTimeAsId);

            buildStatusInfo.LastBuildStatusEnum = BuildStatusEnum;
        }
Beispiel #12
0
 public static Action FromXml(XElement xml)
 {
     if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml was not a Action element");
     var obj = new Action
     {
         Name = xml.AttributeValue("Name"),
         IsBound = xml.AttributeValue("IsBound").ToBoolean()
     };
     obj.Parameters.AddRange(from e in xml.Elements()
                             where e.Name == Parameter.ElementName
                             select Parameter.FromXml(e));
     obj.ReturnType = (from e in xml.Elements()
                       where e.Name.LocalName == ReturnType.ElementName
                       select ReturnType.FromXml(e)).FirstOrDefault();
     return obj;
 }
 public TcProject Parse(string xml)
 {
     xElement = XElement.Parse(xml);
     var id = xElement.AttributeValue("id");
     var tcProject = new TcProject(id);
     var xElements = xElement.Elements("build-type");
     xElements.ForEach(AddBuildConfigurationToProject(tcProject));
     return tcProject;
 }
Beispiel #14
0
 public static ComplexType FromXml(XElement xml)
 {
     if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml was not a ComplexType element");
     var obj = new ComplexType { Name = xml.AttributeValue("Name") };
     obj.Properties.AddRange(from e in xml.Elements()
                             where e.Name.LocalName == "Property"
                             select Property.FromXml(e));
     return obj;
 }
 public ExpandableOptionModel(XElement node, OptionGroupModel model)
 {
     Instance = new ExpandableOption {DataContext = this};
     _model = model;
     Title = node.ChildNodeValue("Title");
     Description = node.ChildNodeValue("Description");
     IsChecked = node.AttributeValue("checked", false);
     DetailsLinkText = node.ChildNodeValue("DetailsText", "more details");
     Branch = node.ChildNodeValue("SettingKey");
     _detailsUrl = node.ChildNodeValue("DetailsUrl");
 }
Beispiel #16
0
        public static new EntityType FromXml(XElement xml)
        {
            if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml is not an EntityType element");

            var obj = new EntityType { Name = xml.AttributeValue("Name") };

            obj.Properties.AddRange(from e in xml.Elements()
                                    where e.Name.LocalName == Property.ElementName
                                    select Property.FromXml(e));
            obj.NavigationProperties.AddRange(from e in xml.Elements()
                                              where e.Name.LocalName == NavigationProperty.ElementName
                                              select NavigationProperty.FromXml(e));

            return obj;
        }
		private ContentTypeConfiguration GetContentTypeConfiguration(
			XElement contentTypeConfiguration, 
			CodeGeneratorConfiguration config,
			string contentTypeName)
		{
			return new ContentTypeConfiguration(config)
			{
				BaseClass = contentTypeConfiguration.AttributeValue("BaseClass"),
				GenerateClasses = Convert.ToBoolean(contentTypeConfiguration.AttributeValue("GenerateClasses", "false")),
				GenerateXml = Convert.ToBoolean(contentTypeConfiguration.AttributeValue("GenerateXml", "false")),
				ModelPath = contentTypeConfiguration.AttributeValue("ModelPath", "Models"),
				Namespace = contentTypeConfiguration.AttributeValue("Namespace"),
				RemovePrefix = contentTypeConfiguration.AttributeValue("RemovePrefix"),
				ContentTypeName = contentTypeName
			};
		}
Beispiel #18
0
        public static SecurityConfig From(XElement element)
        {
            var settings = new SecurityConfig();

            var loginMode = element.AttributeValue("sa-login-mode");
            if (!String.IsNullOrEmpty(loginMode))
            {
                settings.SaLoginMode = (LoginMode)Enum.Parse(typeof(LoginMode), loginMode);
            }

            var permissionsElement = element.Element("permissions");
            if (permissionsElement != null)
            {
                foreach (var each in permissionsElement.Elements())
                {
                    var group = PermissionGroup.From(each, null);
                    settings.PermissionGroups.Add(group);
                }
            }

            return settings;
        }
 private TcArtifacts CreateArtifact(XElement sd, XElement element)
 {
     return new TcArtifacts(sd.AttributeValue("sourceBuildTypeId"), element.AttributeValue("sourcePath"));
 }
Beispiel #20
0
 public LingeaDictFile(XElement root, Langs cl = Langs.no, Langs nl = Langs.no) {
   this.root = root;
   crsLang = LowUtils.EnumParse<Langs>(root.AttributeValue("crsLang", cl.ToString()));
   nativeLang = LowUtils.EnumParse<Langs>(root.AttributeValue("nativeLang", nl.ToString()));
   var subroot = root.Element("entries");
   if (subroot != null) entryIdToEntry = subroot.Elements().ToDictionary(el => el.AttributeValue("id"), el => el); else entryIdToEntry = new Dictionary<string, XElement>();
   subroot = root.Element("courseUses");
 }
Beispiel #21
0
 private static Link ReadLink(XElement element)
 {
     var name = element.AttributeValue(NameAttr, true);
     var path = element.AttributeValue(PathAttr, true);
     var user = element.AttributeValue(UserAttr);
     var pwd = element.AttributeValue(PWdAttr);
     return new Link {Name = name, Path = path, User = user, Password = pwd};
 }
Beispiel #22
0
 private static Category ReadCategory(XElement element)
 {
     var name = element.AttributeValue(NameAttr, true);
     var res = new Category {Name = name};
     foreach (var childElement in element.Elements())
     {
         res.AddChild(ReadItem(childElement));
     }
     return res;
 }
 public WfPackageRelationMapping(XElement node)
 {
     this.MatrixDefID = node.AttributeValue("matrixDefID");
     this.MatrixPath = node.AttributeValue("matrixID");
     this.ProcessDescriptionID = node.AttributeValue("processDescID");
 }
Beispiel #24
0
		private void ParseTriangles(
			XElement mesh, MeshSkinAndMaterials skinAndMaterials, SeparateStreamsMesh dstMesh, XElement element)
		{
			var meshInputs = this.ParseInputs(element);
			
			int[] p = new int[meshInputs.Count * meshInputs.Stride * 3];
			this.ParseIntArray(element.ElementValue(this.schema.pName), p);

			var subMesh = dstMesh.CreateSubmesh();
			subMesh.Material = skinAndMaterials.GetAnyMaterialFor(element.AttributeValue(this.schema.materialAttributeName));
			subMesh.VertexSourceType = VertexSourceType.TriangleList;

			var streamList = StreamListOrderedByOffset(meshInputs, subMesh);

			for (int polygonIndex = 0; polygonIndex < meshInputs.Count; ++polygonIndex)
			{
				AddVertex(p, polygonIndex*3, streamList, meshInputs.Stride);
				AddVertex(p, polygonIndex * 3+1, streamList, meshInputs.Stride);
				AddVertex(p, polygonIndex * 3+2, streamList, meshInputs.Stride);
			}
		}
Beispiel #25
0
		private void ParsePolylist(
			XElement mesh, MeshSkinAndMaterials skinAndMaterials, SeparateStreamsMesh dstMesh, XElement element)
		{
			var meshInputs = this.ParseInputs(element);

			
			int[] vcount = new int[meshInputs.Count];
			this.ParseIntArray(element.ElementValue(this.schema.vcountName), vcount);
			var points = vcount.Sum(a => a);
			var firstSize = vcount[0];
			bool isAllTheSame = vcount.All(i => i == firstSize);

			int[] p = new int[points * meshInputs.Stride];
			this.ParseIntArray(element.ElementValue(this.schema.pName), p);

			var subMesh = dstMesh.CreateSubmesh();
			subMesh.Material = skinAndMaterials.GetAnyMaterialFor(element.AttributeValue(this.schema.materialAttributeName));

			var streamList = StreamListOrderedByOffset(meshInputs, subMesh);

			//if (isAllTheSame)
			//{
			//	if (firstSize == 3)
			//	{
			//		subMesh.VertexSourceType = VertexSourceType.TrianleList;
			//		this.ParseElements(p, subMesh, meshInputs, points);
			//		return;
			//	}
			//	if (firstSize == 4)
			//	{
			//		subMesh.VertexSourceType = VertexSourceType.QuadList;
			//		this.ParseElements(p, subMesh, meshInputs, points);
			//		return;
			//	}
			//}

			subMesh.VertexSourceType = VertexSourceType.TriangleList;
			int startIndex = 0;
			for (int polygonIndex = 0; polygonIndex < vcount.Length; ++polygonIndex)
			{
				for (int i = 2; i < vcount[polygonIndex]; i++)
				{
					AddVertex(p, 0, streamList, meshInputs.Stride);
					AddVertex(p, i-1, streamList, meshInputs.Stride);
					AddVertex(p, i , streamList, meshInputs.Stride);
				}
				startIndex += vcount[polygonIndex];
			}
		}
Beispiel #26
0
		private void ParsePolygons( MeshSkinAndMaterials skinAndMaterials, SeparateStreamsMesh dstMesh, XElement element)
		{
			var meshInputs =  this.ParseInputs(element);
			var subMesh = dstMesh.CreateSubmesh();
			subMesh.Material = skinAndMaterials.GetAnyMaterialFor(element.AttributeValue(this.schema.materialAttributeName));
			subMesh.VertexSourceType = VertexSourceType.TriangleList;

			var streamList = StreamListOrderedByOffset(meshInputs, subMesh);
			foreach (var polygon in element.Elements(this.schema.pName))
			{
				var list = this.ParseIntList(polygon.Value);
				int numElements = list.Count / meshInputs.Stride;

				for (int i=1; i<numElements-1; ++i)
				{
					AddVertex(list, 0, streamList, meshInputs.Stride);
					AddVertex(list, i, streamList, meshInputs.Stride);
					AddVertex(list, i+1, streamList, meshInputs.Stride);
				}
			}
		}
Beispiel #27
0
		private void ParseGeometry(Scene scene, XElement geometry)
		{
			var skinAndMaterials = this.FindContext(scene, geometry);

			var mesh = geometry.Element(this.schema.meshName);

			var dstMesh = new SeparateStreamsMesh();
			this.ParseIdAndName(geometry, dstMesh);
			scene.Geometries.Add(dstMesh);
			if (mesh != null)
			{
				this.ParseMesh(scene, mesh, skinAndMaterials, dstMesh);
				return;
			}
			throw new DaeException(
				string.Format("Geometry type at {0} not supported yet.", geometry.AttributeValue(this.schema.idName)));
		}
Beispiel #28
0
		private MeshSkinAndMaterials FindContext(Scene scene, XElement geometry)
		{
			var sam = new MeshSkinAndMaterials();

			var geometryId = "#" + geometry.AttributeValue(this.schema.idName);

			var controllers = this.collada.Element(this.schema.libraryControllersName);
			if (controllers != null)
			{
				sam.SkinController = (from controller in controllers.Elements(this.schema.controllerName)
				                      let skin = controller.Element(this.schema.skinName)
				                      where skin != null && skin.AttributeValue(this.schema.sourceAttributeName) == geometryId
				                      select controller).FirstOrDefault();
			}

			string controllerId = "#";

			if (sam.SkinController != null)
			{
				controllerId = "#" + sam.SkinController.AttributeValue(this.schema.idName);
			}

			var libScenes = this.collada.Element(this.schema.libraryVisualScenesName);
			if (libScenes != null)
			{
				foreach (var visualScene in libScenes.Elements(this.schema.visualSceneName))
				{
					foreach (var node in visualScene.Descendants(this.schema.nodeName))
					{
						var instanceGeo = node.Element(this.schema.instanceGeometryName);
						if (instanceGeo != null && instanceGeo.AttributeValue(this.schema.urlName) == geometryId)
						{
							this.CopySkin(scene, instanceGeo, sam);
						}
						var instanceCtrl = node.Element(this.schema.instanceControllerName);
						if (instanceCtrl != null && instanceCtrl.AttributeValue(this.schema.urlName) == controllerId)
						{
							this.CopySkin(scene, instanceCtrl, sam);
						}
					}
				}
			}
			return sam;
		}
Beispiel #29
0
		public static IEnumerable<XElement> GetForm(string FormId, string HTMLForm, string Response, bool ShowFormPost, string EmailFrom, string EmailRecipients, string ReceiptEmailField, string ReceiptEmailIntro, string ReceiptEmailSubject)
		{
			XElement HTMLFormXml = GetXmlMarkup(HTMLForm);
			XElement ResponseXml = GetXmlMarkup(Response);
			var Request = HttpContext.Current.Request;

			if (Request.Form[FormId] == null)
			{
				Helper.ReplaceFormTagByDivTag(HTMLFormXml);
				Helper.SetNameForSubmitButtons(FormId, HTMLFormXml);
				yield return HTMLFormXml;
			}
			else
			{
				var result = new XElement("Result");
				foreach (var input in SelectInputs(HTMLFormXml))
				{
					var name = input.AttributeValue("name");
					if (name != null)
					{
						var values = Request.Form.GetValues(name) ?? new string[0];

						
						name = Helper.ToValidIndefiniter(name);
						result.SetAttributeValue(name, string.Join(",", values));

						switch (input.Name.LocalName)
						{
							case "input":
								var type = (input.AttributeValue("type")??string.Empty).ToLower();
								switch (type)
								{
									case "checkbox":
									case "radio":
										var checkboxValue = input.AttributeValue("value");
										input.SetAttributeValue("checked", values.Where(d => d == checkboxValue).FirstOrDefault());
										input.SetAttributeValue("disabled", "disabled");
										break;
									case "hidden":
									case "submit":
									case "image":
										input.Remove();
										break;
									default:
										input.ReplaceWith(new XText(values.FirstOrDefault() ?? string.Empty));
										break;

								}
								break;
							case "select":
								var options = input.Elements(ns + "option").Where(o => values.Contains(o.AttributeValue("value")) || (o.Attribute("value") == null) && values.Contains(o.Value.Trim()));
								input.ReplaceWith(options
									.Select(o =>
										new List<XNode> { new XText(o.Value), new XElement("br") }
										)
									);
								break;
							default:
								input.ReplaceWith(new XText(values.FirstOrDefault() ?? string.Empty));
								break;
						}
					}
					else
						input.Remove();
				}

				// remove from email "marked" nodes <span class="hidefromemail">xxx</span>
				HTMLFormXml.Descendants().Where(n => n.Attribute("class") != null && n.Attribute("class").Value == "hidefromemail").Remove();

				StoreHelper.Save(FormId, result);

				yield return ResponseXml;

				if (ShowFormPost)
					yield return HTMLFormXml;


				if (!string.IsNullOrEmpty(ReceiptEmailIntro.Trim()))
				{
					XElement ReceiptEmailIntroXml = GetXmlMarkup(ReceiptEmailIntro);
					HTMLFormXml.Element(ns + "body").AddFirst(
						new XElement(ns + "p", ReceiptEmailIntroXml)
						);
				}

				if (!string.IsNullOrEmpty(EmailRecipients.Trim()) && !string.IsNullOrEmpty(EmailFrom.Trim()))
				{
					SendEmail(EmailFrom, EmailRecipients, ReceiptEmailSubject, HTMLFormXml);
				}

				if (!string.IsNullOrEmpty(ReceiptEmailField.Trim()) && !string.IsNullOrEmpty(EmailFrom.Trim()))
				{
					var recipients = result.AttributeValue(ReceiptEmailField.Trim());
					if (!string.IsNullOrEmpty(recipients))
					{
						SendEmail(EmailFrom, recipients, ReceiptEmailSubject, HTMLFormXml);
					}
				}
			}
		}
Beispiel #30
0
        /// <summary>
        /// Creates a document from an XML XElement representation
        /// </summary>
        public static DocumentMetadata ConsumeDocument(XElement docXEl)
        {
            DocumentMetadata doc = new DocumentMetadata();
            doc.Author = ConsumeAuthor(docXEl.Classification(XDMetadataStandard.UUIDs.DocumentAuthor));
            doc.Class = ConsumeCodedValue(docXEl.Classification(XDMetadataStandard.UUIDs.DocumentClass));
            doc.Comments = docXEl.DescriptionValue();
            doc.Confidentiality = ConsumeCodedValue(docXEl.Classification(XDMetadataStandard.UUIDs.DocumentConfidentiality));
            doc.CreatedOn = docXEl.SlotValue<DateTime?>(XDMetadataStandard.Slots.CreationTime, s => HL7Util.DateTimeFromHL7Value(s));
            doc.EventCodes = docXEl.Classifications(XDMetadataStandard.UUIDs.EventCode).Select(c => ConsumeCodedValue(c));
            doc.FormatCode = ConsumeCodedValue(docXEl.Classification(XDMetadataStandard.UUIDs.FormatCode));
            doc.FacilityCode = ConsumeCodedValue(docXEl.Classification(XDMetadataStandard.UUIDs.FacilityCode));
            doc.Hash = docXEl.SlotValue(XDMetadataStandard.Slots.Hash);
            doc.LanguageCode = docXEl.SlotValue(XDMetadataStandard.Slots.LanguageCode);
            doc.LegalAuthenticator = docXEl.SlotValue<Person>(XDMetadataStandard.Slots.LegalAuthenticator, s => Person.FromXCN(s));
            doc.MediaType = docXEl.AttributeValue(XDMetadataStandard.Attrs.MimeType);
            doc.PatientID = docXEl.ExternalIdentifierValue(XDMetadataStandard.UUIDs.DocumentEntryPatientIdentityScheme, s => PatientID.FromEscapedCx(s));
            doc.ServiceStart = docXEl.SlotValue<DateTime?>(XDMetadataStandard.Slots.ServiceStart, s => HL7Util.DateTimeFromHL7Value(s));
            doc.ServiceStop = docXEl.SlotValue<DateTime?>(XDMetadataStandard.Slots.ServiceStop, s => HL7Util.DateTimeFromHL7Value(s));
            doc.PracticeSetting = ConsumeCodedValue(docXEl.Classification(XDMetadataStandard.UUIDs.PracticeSetting));
            doc.Size = docXEl.SlotValue<int?>(XDMetadataStandard.Slots.Size, s => Parse(s));
            doc.SourcePtId = docXEl.SlotValue<PatientID>(XDMetadataStandard.Slots.SourcePatientID, s => PatientID.FromEscapedCx(s));
            doc.Patient = Person.FromSourcePatientInfoValues(docXEl.SlotValues(XDMetadataStandard.Slots.SourcePatientInfo));
            doc.Title = docXEl.NameValue();
            // Ignore TypeCode
            doc.UniqueId = docXEl.ExternalIdentifierValue(XDMetadataStandard.UUIDs.DocumentUniqueIdIdentityScheme);
            doc.Uri = ConsumeUriValues(docXEl.SlotValues(XDMetadataStandard.Slots.Uri));

            return doc;
        }