protected override void AddCompositeIdGenerator(XmlDocument xmldoc, XmlElement idElement, List<ColumnDetail> compositeKey, ApplicationPreferences applicationPreferences) { foreach (ColumnDetail column in compositeKey) { var keyElement = xmldoc.CreateElement("key-property"); string propertyName = column.ColumnName.GetPreferenceFormattedText(applicationPreferences); if (applicationPreferences.FieldGenerationConvention == FieldGenerationConvention.Property) { idElement.SetAttribute("name", propertyName.MakeFirstCharLowerCase()); } else { if (applicationPreferences.FieldGenerationConvention == FieldGenerationConvention.AutoProperty) { propertyName = column.ColumnName.GetFormattedText(); } keyElement.SetAttribute("name", propertyName); } var mapper = new DataTypeMapper(); Type mapFromDbType = mapper.MapFromDBType(column.DataType, column.DataLength, column.DataPrecision, column.DataScale); keyElement.SetAttribute("type", mapFromDbType.Name); keyElement.SetAttribute("column", column.ColumnName); if (applicationPreferences.FieldGenerationConvention != FieldGenerationConvention.AutoProperty) { keyElement.SetAttribute("access", "field"); } idElement.AppendChild(keyElement); } }
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context) { Controller.SaveNode(xmlDoc, nodeElement, context); var outEl = xmlDoc.CreateElement("Name"); outEl.SetAttribute("value", NickName); nodeElement.AppendChild(outEl); outEl = xmlDoc.CreateElement("Description"); outEl.SetAttribute("value", Description); nodeElement.AppendChild(outEl); outEl = xmlDoc.CreateElement("Inputs"); foreach (string input in InPortData.Select(x => x.NickName)) { XmlElement inputEl = xmlDoc.CreateElement("Input"); inputEl.SetAttribute("value", input); outEl.AppendChild(inputEl); } nodeElement.AppendChild(outEl); outEl = xmlDoc.CreateElement("Outputs"); foreach (string output in OutPortData.Select(x => x.NickName)) { XmlElement outputEl = xmlDoc.CreateElement("Output"); outputEl.SetAttribute("value", output); outEl.AppendChild(outputEl); } nodeElement.AppendChild(outEl); }
internal StoreMemberProperty(EDMXFile parentFile, StoreEntityType storeEntityType, string name, int ordinal, XmlElement parentTypeElement) : base(parentFile) { _parentEntityType = storeEntityType; _parentEntityType.Removed += new EventHandler(ParentEntityType_Removed); _propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIssdl); if (ordinal > 0) { XmlNodeList propertyNodes = parentTypeElement.SelectNodes("ssdl:Property", NSM); if (propertyNodes.Count >= ordinal) { parentTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]); } else { parentTypeElement.AppendChild(_propertyElement); } } else { parentTypeElement.AppendChild(_propertyElement); } this.Name = name; }
public int CreateLayoutNode(XmlDocument document, XmlElement parent, ILayout layout) { XmlElement element = null, components = null; if (document != null) { element = document.CreateElement("Settings"); components = document.CreateElement("Components"); } var hashCode = SettingsHelper.CreateSetting(document, parent, "Mode", layout.Mode) ^ SettingsHelper.CreateSetting(document, parent, "X", layout.X) ^ SettingsHelper.CreateSetting(document, parent, "Y", layout.Y) ^ SettingsHelper.CreateSetting(document, parent, "VerticalWidth", layout.VerticalWidth) ^ SettingsHelper.CreateSetting(document, parent, "VerticalHeight", layout.VerticalHeight) * 1000 ^ SettingsHelper.CreateSetting(document, parent, "HorizontalWidth", layout.HorizontalWidth) ^ SettingsHelper.CreateSetting(document, parent, "HorizontalHeight", layout.HorizontalHeight) * 1000 ^ ToElement(document, element, layout.Settings); if (document != null) { parent.AppendChild(element); parent.AppendChild(components); } var layoutComponents = new List<ILayoutComponent>(layout.LayoutComponents); var count = 1; foreach (var component in layoutComponents) { try { if (document != null) { var componentElement = document.CreateElement("Component"); components.AppendChild(componentElement); SettingsHelper.CreateSetting(document, componentElement, "Path", component.Path); var settings = document.CreateElement("Settings"); settings.InnerXml = component.Component.GetSettings(document).InnerXml; componentElement.AppendChild(settings); } else { var type = component.Component.GetType(); if (type.GetMethod("GetSettingsHashCode") != null) hashCode ^= ((dynamic)component.Component).GetSettingsHashCode() ^ component.GetHashCode() * count; else hashCode ^= component.Component.GetSettings(new XmlDocument()).InnerXml.GetHashCode() ^ component.GetHashCode() * count; } } catch (Exception e) { Log.Error(e); } count++; } return hashCode; }
// //createDataElement // private static void createDataElement( ref System.Xml.XmlDocument pdoc, string pname, string pvalue, string pcomment) { System.Xml.XmlElement data = pdoc.CreateElement("data"); data.SetAttribute("name", pname); data.SetAttribute("xml:space", "preserve"); System.Xml.XmlElement value = pdoc.CreateElement("value"); value.InnerText = pvalue; data.AppendChild(value); if (!(pcomment == null)) { System.Xml.XmlElement comment = pdoc.CreateElement("comment"); comment.InnerText = pcomment; data.AppendChild(comment); } System.Xml.XmlNode root = pdoc.SelectSingleNode("//root"); System.Xml.XmlNode old_data = root.SelectSingleNode("//data[@name='" + pname + "']"); if (old_data == null) { root.AppendChild(data); } else { root.ReplaceChild(data, old_data); } }
public void WriteTo(XmlElement element) { //JobType Debug.Assert(element.OwnerDocument != null, "element.OwnerDocument != null"); var jobTypeElement = element.OwnerDocument.CreateElement("JobType"); JobType.WriteTo(jobTypeElement); element.AppendChild(jobTypeElement); //JobParameters Debug.Assert(element.OwnerDocument != null, "element.OwnerDocument != null"); var jobParametersElement = element.OwnerDocument.CreateElement("JobParameters"); if (JobParameters != null) { foreach (var jobParameter in JobParameters) { var jobParameterElement = element.OwnerDocument.CreateElement("JobParameter"); var jobParameterNameElement = element.OwnerDocument.CreateAttribute("Name"); jobParameterNameElement.Value = jobParameter.Key; var jobParameterValueElement = element.OwnerDocument.CreateAttribute("Value"); jobParameterValueElement.Value = jobParameter.Value; jobParameterElement.Attributes.Append(jobParameterNameElement); jobParameterElement.Attributes.Append(jobParameterValueElement); jobParametersElement.AppendChild(jobParameterElement); } element.AppendChild(jobParametersElement); } }
// Get the file names array of a given directory public static void FileTree2Xml(XmlDocument xmlDoc, ref XmlElement xmlElement, bool recurse, String ext) { if (recurse) { String[] subDirs = Directory.GetDirectories(xmlElement.GetAttribute("Info")); foreach (String sd in subDirs) { XmlElement newElement = xmlDoc.CreateElement("Path"); newElement.SetAttribute("Info", sd); FileTree2Xml(xmlDoc, ref newElement, recurse, ext); xmlElement.AppendChild(newElement); } } String[] files = Directory.GetFiles(xmlElement.GetAttribute("Info")); foreach (String file in files) { if (!String.IsNullOrEmpty(ext)) { FileInfo fInfo = new FileInfo(file); if (fInfo.Extension != ext) continue; } XmlElement fileElement = xmlDoc.CreateElement("File"); fileElement.SetAttribute("Info", file); xmlElement.AppendChild(fileElement); } }
/// <summary> /// 已重载:从XML节点加载对象数据 /// </summary> /// <param name="myElement"></param> /// <returns></returns> public override bool ToXML(System.Xml.XmlElement myElement) { if (null != myElement) { myAttributes.SetValue("align", this.horizontalAlignment.ToString()); myAttributes.SetValue("title", this.Header); myAttributes.SetValue("fixwidth", (this.IsFixWidth ? 1 : 0).ToString()); myAttributes.SetValue("width", this.Width); myAttributes.SetValue("hidden-all-border", this.HiddenAllBorder ? 1 : 0); XmlElement itemColumn = myElement.OwnerDocument.CreateElement("table-column"); itemColumn.SetAttribute("columns-number", columns.ToString()); for (int i = 0; i < this.absoluteWidths.Length; i++) { XmlElement item = itemColumn.OwnerDocument.CreateElement("column-width"); item.SetAttribute("width", absoluteWidths[i].ToString()); itemColumn.AppendChild(item); } myElement.AppendChild(itemColumn); foreach (TPTextRow row in this) { XmlElement item = myElement.OwnerDocument.CreateElement(row.GetXMLName()); myElement.AppendChild(item); row.ToXML(item); } } myAttributes.ToXML(myElement); return(true); }
static private int addToXml(string filePath, XmlElement root,int count) { DirectoryInfo di = new DirectoryInfo(filePath); foreach (FileInfo file in di.GetFiles()) { XmlElement xel = xmlDoc.CreateElement("FILE");//创建一个<file>节点 xel.SetAttribute("NAME", file.Name);//设置该节点genre属性 xel.SetAttribute("SIZE", file.Length.ToString());//设置该节点genre属性 xel.SetAttribute("CREATE_TIME", file.CreationTime.ToString()); xel.SetAttribute("MODIFY_TIME", file.LastWriteTime.ToString()); xel.SetAttribute("ATTRIBUTES", file.Attributes.ToString()); root.AppendChild(xel); count=count+1; } foreach (DirectoryInfo directory in di.GetDirectories()) { XmlElement xel = xmlDoc.CreateElement("DIRECTORY");//创建一个<directory>节点 xel.SetAttribute("NAME", directory.Name);//设置该节点ISBN属性 xel.SetAttribute("CREATE_TIME", directory.CreationTime.ToString()); xel.SetAttribute("MODIFY_TIME", directory.LastWriteTime.ToString()); xel.SetAttribute("ATTRIBUTES", directory.Attributes.ToString()); root.AppendChild(xel); count= addToXml(filePath + @"\" + directory.Name, xel,count); } return count; }
internal ModelMemberProperty(EDMXFile parentFile, ModelEntityType modelEntityType, string name, int ordinal, XmlElement entityTypeElement) : base(parentFile) { _modelEntityType = modelEntityType; _modelEntityType.Removed += new EventHandler(ModelEntityType_Removed); _propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIcsdl); if (ordinal > 0) { XmlNodeList propertyNodes = entityTypeElement.SelectNodes("edm:Property", NSM); if (propertyNodes.Count >= ordinal) { entityTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]); } else { entityTypeElement.AppendChild(_propertyElement); } } else { entityTypeElement.AppendChild(_propertyElement); } Name = name; }
internal ModelFunctionParameter(EDMXFile parentFile, ModelFunction storeFunction, string name, int ordinal, XmlElement parentTypeElement) : base(parentFile) { _parentFunction = storeFunction; _parameterElement = EDMXDocument.CreateElement("Parameter", NameSpaceURIcsdl); if (ordinal > 0) { XmlNodeList propertyNodes = parentTypeElement.SelectNodes("edm:Parameter", NSM); if (propertyNodes.Count >= ordinal) { parentTypeElement.InsertAfter(_parameterElement, propertyNodes[ordinal - 1]); } else { parentTypeElement.AppendChild(_parameterElement); } } else { parentTypeElement.AppendChild(_parameterElement); } this.Name = name; }
protected override void WriteXml(object entity, XmlElement parent, IFormatProvider formatProvider, string localName, bool mandatory) { object value = GetValue(entity); if (_Adapter.IsEmpty(value)) { if (mandatory) { XmlElement member = parent.OwnerDocument.CreateElement(localName); parent.AppendChild(member); string content = _Adapter.FormatObject(value, formatProvider); if (!string.IsNullOrEmpty(content)) member.AppendChild(member.OwnerDocument.CreateCDataSection(content)); } } else { XmlElement member = parent.OwnerDocument.CreateElement(localName); parent.AppendChild(member); string content = _Adapter.FormatObject(value, formatProvider); member.AppendChild(parent.OwnerDocument.CreateCDataSection(content)); } }
public void ToXML(System.Xml.XmlElement myElement) { //page XmlElement page = myElement.OwnerDocument.CreateElement("page"); page.SetAttribute("kind", this.PaperSize.Kind.ToString()); page.SetAttribute("width", PaperSize.Width.ToString()); page.SetAttribute("height", PaperSize.Height.ToString()); myElement.AppendChild(page); //margins XmlElement margins = myElement.OwnerDocument.CreateElement("margins"); margins.SetAttribute("left", Margins.Left.ToString()); margins.SetAttribute("top", Margins.Top.ToString()); margins.SetAttribute("right", Margins.Right.ToString()); margins.SetAttribute("bottom", Margins.Bottom.ToString()); myElement.AppendChild(margins); //font XmlElement font = myElement.OwnerDocument.CreateElement("font"); font.SetAttribute("fontsize", PaperSize.fontsize.ToString()); font.SetAttribute("fontname", "宋体"); myElement.AppendChild(font); //纵横 XmlElement landscape = myElement.OwnerDocument.CreateElement("landscape"); landscape.SetAttribute("value", Landscape.ToString()); myElement.AppendChild(landscape); }
protected override void WriteXml(object entity, System.Xml.XmlElement parent, IFormatProvider formatProvider, string localName, bool mandatory) { object value = GetValue(entity); if (value == null) { if (mandatory) { XmlElement element = parent.OwnerDocument.CreateElement(localName); parent.AppendChild(element); } } else { foreach (object obj in ((System.Collections.IList)value)) { XmlElement element = parent.OwnerDocument.CreateElement(localName); parent.AppendChild(element); foreach (XmlAspectMember xam in _Aspect) { xam.WriteXml(obj, element, formatProvider); } } } }
private static void AddGeneralProperties(IHeaders props, XmlElement item) { string prop; var ownerDocument = item.OwnerDocument; if (ownerDocument == null) { throw new ArgumentNullException(nameof(item)); } if (props.TryGetValue("DateO", out prop)) { var e = ownerDocument.CreateElement("dc", "date", NS_DC); e.InnerText = prop; item.AppendChild(e); } if (props.TryGetValue("Genre", out prop)) { var e = ownerDocument.CreateElement("upnp", "genre", NS_UPNP); e.InnerText = prop; item.AppendChild(e); } if (props.TryGetValue("Description", out prop)) { var e = ownerDocument.CreateElement("dc", "description", NS_DC); e.InnerText = prop; item.AppendChild(e); } if (props.TryGetValue("Artist", out prop)) { var e = ownerDocument.CreateElement("upnp", "artist", NS_UPNP); e.SetAttribute("role", "AlbumArtist"); e.InnerText = prop; item.AppendChild(e); } if (props.TryGetValue("Performer", out prop)) { var e = ownerDocument.CreateElement("upnp", "artist", NS_UPNP); e.SetAttribute("role", "Performer"); e.InnerText = prop; item.AppendChild(e); e = ownerDocument.CreateElement("dc", "creator", NS_DC); e.InnerText = prop; item.AppendChild(e); } if (props.TryGetValue("Album", out prop)) { var e = ownerDocument.CreateElement("upnp", "album", NS_UPNP); e.InnerText = prop; item.AppendChild(e); } if (props.TryGetValue("Track", out prop)) { var e = ownerDocument.CreateElement( "upnp", "originalTrackNumber", NS_UPNP); e.InnerText = prop; item.AppendChild(e); } if (props.TryGetValue("Creator", out prop)) { var e = ownerDocument.CreateElement("dc", "creator", NS_DC); e.InnerText = prop; item.AppendChild(e); } if (props.TryGetValue("Director", out prop)) { var e = ownerDocument.CreateElement("upnp", "director", NS_UPNP); e.InnerText = prop; item.AppendChild(e); } }
void AddChildren(XmlElement gapi_child) { foreach (XmlNode node in elem.ChildNodes) { XmlElement child = node as XmlElement; if (child == null) continue; switch (node.Name) { case "glib:signal": gapi_child.AppendChild (new Signal (child).CreateGapiElement (gapi_child.OwnerDocument)); break; case "method": gapi_child.AppendChild (new Method (child).CreateGapiElement (gapi_child.OwnerDocument)); break; case "prerequisite": gapi_child.SetAttribute ("prerequisite", child.GetAttribute ("name")); break; case "property": gapi_child.AppendChild (new Property (child).CreateGapiElement (gapi_child.OwnerDocument)); break; case "virtual-method": gapi_child.AppendChild (new VirtualMethod (child).CreateGapiElement (gapi_child.OwnerDocument)); break; default: Console.WriteLine ("Unexpected child on interface element: " + node.Name); break; } } }
void AddChildren(XmlElement gapi_child) { foreach (XmlNode node in elem.ChildNodes) { XmlElement child = node as XmlElement; if (child == null) continue; switch (node.Name) { case "constructor": gapi_child.AppendChild (new Ctor (child).CreateGapiElement (gapi_child.OwnerDocument)); break; case "doc": // Ignore break; case "field": gapi_child.AppendChild (new Field (child).CreateGapiElement (gapi_child.OwnerDocument)); break; case "function": case "method": gapi_child.AppendChild (new Method (child).CreateGapiElement (gapi_child.OwnerDocument)); break; default: Console.WriteLine ("Unexpected child on record element: " + node.Name); break; } } }
internal override void SetXML(XmlElement xml, BaseClassIfc host, HashSet<int> processed) { base.SetXML(xml, host, processed); xml.AppendChild(ContainerProfile.GetXML(xml.OwnerDocument, "ContainerProfile", this, processed)); xml.AppendChild(Operator.GetXML(xml.OwnerDocument, "Operator", this, processed)); setAttribute(xml, "Label", Label); }
private static void KeyValue2Xml(XmlElement node, KeyValuePair<string, object> Source) { object kValue = Source.Value; if (kValue.GetType() == typeof(Dictionary<string, object>)) { foreach (KeyValuePair<string, object> item in kValue as Dictionary<string, object>) { XmlElement element = node.OwnerDocument.CreateElement(item.Key); KeyValue2Xml(element, item); node.AppendChild(element); } } else if (kValue.GetType() == typeof(object[])) { object[] o = kValue as object[]; for (int i = 0; i < o.Length; i++) { XmlElement xitem = node.OwnerDocument.CreateElement("Item"); KeyValuePair<string, object> item = new KeyValuePair<string, object>("Item", o[i]); KeyValue2Xml(xitem, item); node.AppendChild(xitem); } } else { XmlText text = node.OwnerDocument.CreateTextNode(kValue.ToString()); node.AppendChild(text); } }
internal AssociationSetMapping(EDMXFile parentFile, XmlElement entityContainerMappingElement, CSMapping csMapping, string name, ModelAssociationSet modelAssocSet, StoreEntitySet storeEntitySet, StoreAssociationSet fromStoreAssocSet, StoreAssociationSet toStoreAssocSet) : base(parentFile) { _csMapping = csMapping; _modelAssociationSet = modelAssocSet; //create mapping xml elements _asmElement = EDMXDocument.CreateElement("AssociationSetMapping", NameSpaceURImap); entityContainerMappingElement.AppendChild(_asmElement); XmlElement fromEndProp = EDMXDocument.CreateElement("EndProperty", NameSpaceURImap); fromEndProp.SetAttribute("Name", modelAssocSet.FromRoleName); _asmElement.AppendChild(fromEndProp); XmlElement toEndProp = EDMXDocument.CreateElement("EndProperty", NameSpaceURImap); toEndProp.SetAttribute("Name", modelAssocSet.ToRoleName); _asmElement.AppendChild(toEndProp); List<Tuple<ModelMemberProperty, StoreMemberProperty, string>> fromKeys = ( from key in fromStoreAssocSet.Keys select new Tuple<ModelMemberProperty, StoreMemberProperty, string>( key.Item2.ModelMembers.FirstOrDefault(mm => mm.EntityType == modelAssocSet.FromEntityType), key.Item1, key.Item2.Name ) ).ToList(); foreach (var key in fromKeys) { XmlElement scalarProperty = EDMXDocument.CreateElement("ScalarProperty", NameSpaceURImap); scalarProperty.SetAttribute("Name", (key.Item1 != null ? key.Item1.Name : key.Item3)); scalarProperty.SetAttribute("ColumnName", key.Item2.Name); fromEndProp.AppendChild(scalarProperty); } List<Tuple<ModelMemberProperty, StoreMemberProperty, string>> toKeys = ( from key in toStoreAssocSet.Keys select new Tuple<ModelMemberProperty, StoreMemberProperty, string>( key.Item2.ModelMembers.FirstOrDefault(mm => mm.EntityType == modelAssocSet.ToEntityType), key.Item1, key.Item2.Name ) ).ToList(); foreach (var key in toKeys) { XmlElement scalarProperty = EDMXDocument.CreateElement("ScalarProperty", NameSpaceURImap); scalarProperty.SetAttribute("Name", (key.Item1 != null ? key.Item1.Name : key.Item3)); scalarProperty.SetAttribute("ColumnName", key.Item2.Name); toEndProp.AppendChild(scalarProperty); } Name = name; StoreEntitySetName = storeEntitySet.Name; TypeName = modelAssocSet.FullName; }
private void AddCover(IRequest request, IMediaResource resource, XmlElement item) { var result = item.OwnerDocument; var cover = resource as IMediaCover; if (cover == null) { return; } try { var c = cover.Cover; var curl = String.Format( "http://{0}:{1}{2}cover/{3}/i.jpg", request.LocalEndPoint.Address, request.LocalEndPoint.Port, prefix, resource.Id ); var icon = result.CreateElement("upnp", "albumArtURI", NS_UPNP); var profile = result.CreateAttribute("dlna", "profileID", NS_DLNA); profile.InnerText = "JPEG_TN"; icon.SetAttributeNode(profile); icon.InnerText = curl; item.AppendChild(icon); icon = result.CreateElement("upnp", "icon", NS_UPNP); profile = result.CreateAttribute("dlna", "profileID", NS_DLNA); profile.InnerText = "JPEG_TN"; icon.SetAttributeNode(profile); icon.InnerText = curl; item.AppendChild(icon); var res = result.CreateElement(string.Empty, "res", NS_DIDL); res.InnerText = curl; res.SetAttribute("protocolInfo", string.Format( "http-get:*:{1}:DLNA.ORG_PN={0};DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS={2}", c.PN, DlnaMaps.Mime[c.Type], DlnaMaps.DefaultStreaming )); var width = c.MetaWidth; var height = c.MetaHeight; if (width.HasValue && height.HasValue) { res.SetAttribute("resolution", string.Format("{0}x{1}", width.Value, height.Value)); } else { res.SetAttribute("resolution", "200x200"); } res.SetAttribute("protocolInfo", string.Format( "http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN;DLNA.ORG_OP=01;DLNA.ORG_CI=1;DLNA.ORG_FLAGS={0}", DlnaMaps.DefaultInteractive )); item.AppendChild(res); } catch (Exception) { return; } }
public static XmlElement CreateElement(XmlElement parent, string name, string innerText, XmlNamespaceManager nsMgr) { if (parent == null) { throw new Exception("Passed in a null node, which should never happen. Tell Gus!"); } XmlElement newChild = parent.OwnerDocument.CreateElement(name, nsMgr.LookupNamespace("ns1")); XmlElement element2 = (XmlElement) parent.AppendChild(newChild); element2.InnerText = innerText; return (XmlElement) parent.AppendChild(element2); }
private string InitalReceiveData() { XmlElement newReceive = mconfig.OwnerDocument.CreateElement("Receive"); newReceive.SetAttribute("Name", ""); newReceive.SetAttribute("Address", ""); mconfig.AppendChild(newReceive); SmartSchool.Customization.Data.SystemInformation.Preference["懲戒通知單"] = mconfig; return(""); }
public FoDocumentFacade(XmlDocument document) { this.document = document; root = document.CreateElement("fo:root", NS_XSLFO); document.AppendChild(root); layoutMasterSet = document.CreateElement("fo:layout-master-set", NS_XSLFO); root.AppendChild(layoutMasterSet); declarations = document.CreateElement("fo:declarations", NS_XSLFO); root.AppendChild(declarations); }
protected override XmlElement saveToFile(XmlDocument doc, XmlElement root) { base.saveToFile(doc, root); root.AppendChild(PetriXmlHelper.savePointF(doc, this.point, "TopLeftPoint")); root.AppendChild(PetriXmlHelper.savePointF(doc, this.origo, "Origo")); root.AppendChild(PetriXmlHelper.savePointF(doc, this.labelOffset, "LabelOffset")); root.AppendChild(PetriXmlHelper.saveSizeF(doc, this.size, "Size")); XmlAttribute radius = doc.CreateAttribute(PetriXmlHelper.XML_ITEM_NAMESPACE_PREFIX, "radius", PetriXmlHelper.XML_ITEM_NAMESPACE); radius.Value = this.radius.ToString(); root.SetAttributeNode(radius); return root; }
static int ConnectSample() { PmsXchangeService service = new PmsXchangeService(); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //The security header is untyped due to the lax processing instruction System.Xml.XmlElement token = doc.CreateElement("UsernameToken"); System.Xml.XmlElement password = doc.CreateElement("Password"); System.Xml.XmlElement username = doc.CreateElement("Username"); System.Xml.XmlText usernameText = doc.CreateTextNode("SPIOrangeTest"); System.Xml.XmlText passwordText = doc.CreateTextNode("YOURPASSWORD"); username.AppendChild(usernameText); password.AppendChild(passwordText); token.AppendChild(username); token.AppendChild(password); System.Xml.XmlElement[] elements = new System.Xml.XmlElement[] { token }; SecurityHeaderType type = new SecurityHeaderType(); service.Security = type; service.Security.Any = elements; OTA_ReadRQ otaReadRQ = new OTA_ReadRQ(); otaReadRQ.Version = 1.0M; OTA_ReadRQReadRequests rr = new OTA_ReadRQReadRequests(); OTA_ReadRQReadRequestsHotelReadRequest hotelR = new OTA_ReadRQReadRequestsHotelReadRequest(); hotelR.HotelCode = "123"; object[] ob = new object[] { hotelR }; rr.Items = ob; OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria crit = new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria(); OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType selType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered; crit.SelectionType = selType; crit.SelectionTypeSpecified = true; hotelR.SelectionCriteria = crit; otaReadRQ.ReadRequests = rr; // Retrieve the response Console.WriteLine("About to make request :::"); OTA_ResRetrieveRS resRetrieveRS = service.ReadRQ(otaReadRQ); Console.WriteLine("Received response :::"); //Do further work .... // .... return(0); }
public void Init() { document=new XmlDocument(); dIDocumentInterpreter =new PapyrusXmiDIDocumentInterpreter(); diagramElement=ContainedElementStub.CreateContainedElementStub(document); firstContainedElement=GraphNodeSemanticModelElementStub.CreateGraphNodeSemanticModelElementStub(document,"1"); secondContainedElement=GraphNodeSemanticModelElementStub.CreateGraphNodeSemanticModelElementStub(document,"2"); thirdContainedElement=GraphNodeSemanticModelElementStub.CreateGraphNodeSemanticModelElementStub(document,"3"); diagramElement.AppendChild(firstContainedElement); diagramElement.AppendChild(secondContainedElement); diagramElement.AppendChild(thirdContainedElement); }
public void Save(XmlDocument doc, XmlElement parent) { //parent.AppendChild(XmlHelper.CreateSimpleNode("Sheet", Resources.SpriteSheets.Where(pair => pair.Value == SpriteSheet).First().Key, doc)); parent.AppendChild(XmlHelper.CreateSimpleNode("FrameTime", FrameTime, doc)); XmlElement spritesElem = doc.CreateElement("Sprites"); for (int i = 0; i < Sprites.Length; i++) spritesElem.AppendChild(XmlHelper.CreateSimpleNode("S" + i, Resources.GetName(Sprites[i]), doc)); parent.AppendChild(spritesElem); parent.AppendChild(XmlHelper.CreateSimpleNode("IsLooping", IsLooping, doc)); parent.AppendChild(XmlHelper.CreateSimpleNode("Effect", SpriteEffect, doc)); }
public XmiDocumentInterpreterTest() { xmiDocument=new XmlDocument(); //mscEditorContentCreator =new EditorEntryCreator() ; //documentInterpreter=new XmiDocumentInterpreter(mscEditorContentCreator) ; modelElement=ModelElementStub.CreateModelElementStub(xmiDocument); firstInteractionElement=InteractionElementStub.CreateInteractionElementStub(xmiDocument); secondInteractionElement=InteractionElementStub.CreateInteractionElementStub(xmiDocument); thirdInteractionElement=InteractionElementStub.CreateInteractionElementStub(xmiDocument); modelElement.AppendChild(firstInteractionElement); modelElement.AppendChild(secondInteractionElement); modelElement.AppendChild(thirdInteractionElement); }
internal override void SetXML(XmlElement xml, BaseClassIfc host, HashSet<int> processed) { base.SetXML(xml, host, processed); XmlElement element = xml.OwnerDocument.CreateElement("ShapeRepresentations"); xml.AppendChild(element); foreach (IfcShapeModel s in ShapeRepresentations) element.AppendChild(s.GetXML(xml.OwnerDocument, "", this, processed)); setAttribute(xml, "Name", Name); setAttribute(xml, "Description", Description); xml.SetAttribute("ProductDefinitional", ProductDefinitional.ToString().ToLower()); if (mPartOfProductDefinitionShape > 0) xml.AppendChild(mDatabase[mPartOfProductDefinitionShape].GetXML(xml.OwnerDocument, "PartOfProductDefinitionShape", this, processed)); }
public void OutputNewPageData(Dictionary<string, string> dic, XmlElement validationRoot) { XmlDocument doc = validationRoot.OwnerDocument; string fpname, fpbody; ParseNewPagePostData (dic, out fpname, out fpbody); validationRoot.AppendChild (doc.CreateElement ("data", new string[][] { new[] { "name", "fpname" } }, new[] { doc.CreateElement ("value", null, new[]{doc.CreateTextNode (fpname)}) })); validationRoot.AppendChild (doc.CreateElement ("data", new string[][] { new[] { "name", "fpbody" } }, new[] { doc.CreateElement ("value", null, new[]{doc.CreateTextNode (fpbody)}) })); }
public static XmlNode SetTextInElement(XmlElement element, string name, string text, XmlNamespaceManager nsMgr) { if (element == null) { throw new Exception("Passed in a null node, which should never happen."); } XmlElement newChild = (XmlElement) element.SelectSingleNode("descendant::ns1:" + name, nsMgr); if (newChild == null) { newChild = (XmlElement) element.AppendChild(element.OwnerDocument.CreateElement(name, nsMgr.LookupNamespace("ns1"))); } newChild.InnerText = text; return element.AppendChild(newChild); }
public void WriteTo(XmlElement jobAndWorkerTypeElement) { //JobType Debug.Assert(jobAndWorkerTypeElement.OwnerDocument != null, "jobAndWorkerTypeElement.OwnerDocument != null"); var jobTypeElement = jobAndWorkerTypeElement.OwnerDocument.CreateElement("JobType"); JobType.WriteTo(jobTypeElement); jobAndWorkerTypeElement.AppendChild(jobTypeElement); //WorkerType Debug.Assert(jobAndWorkerTypeElement.OwnerDocument != null, "jobAndWorkerTypeElement.OwnerDocument != null"); var workerTypeElement = jobAndWorkerTypeElement.OwnerDocument.CreateElement("WorkerType"); WorkerType.WriteTo(workerTypeElement); jobAndWorkerTypeElement.AppendChild(workerTypeElement); }
internal override void SetXML(XmlElement xml, BaseClassIfc host, HashSet<int> processed) { base.SetXML(xml, host, processed); setAttribute(xml, "ObjectType", ObjectType); if (mIsTypedBy != null) xml.AppendChild(mIsTypedBy.GetXML(xml.OwnerDocument, "IsTypedBy", this, processed)); if (mIsDefinedBy.Count > 0) { XmlElement element = xml.OwnerDocument.CreateElement("IsDefinedBy"); xml.AppendChild(element); foreach (IfcRelDefinesByProperties rd in IsDefinedBy) element.AppendChild(rd.GetXML(xml.OwnerDocument, "", this, processed)); } }
protected override void AddIdGenerator(XmlDocument xmldoc, XmlElement idElement) { var generatorElement = xmldoc.CreateElement("generator"); if (IsAssigned) { generatorElement.SetAttribute("class", "assigned"); idElement.AppendChild(generatorElement); } else { generatorElement.SetAttribute("class", "identity"); idElement.AppendChild(generatorElement); } }
public string createXMLFromCustomList(List <List <KeyValuePair <string, string> > > myList, int AddressListId) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //create nodes System.Xml.XmlElement root = doc.CreateElement("addressList"); System.Xml.XmlElement addressListName = doc.CreateElement("addressListName"); _addressListName = Guid.NewGuid().ToString("N"); addressListName.InnerXml = _addressListName; root.AppendChild(addressListName); System.Xml.XmlElement addressMappingId = doc.CreateElement("addressMappingId"); addressMappingId.InnerXml = AddressListId.ToString(); root.AppendChild(addressMappingId); System.Xml.XmlElement addresses = doc.CreateElement("addresses"); root.AppendChild(addresses); System.Xml.XmlElement address = null; foreach (List <KeyValuePair <string, string> > a in myList) { foreach (KeyValuePair <string, string> aa in a) { address = doc.CreateElement("address"); System.Xml.XmlElement i = doc.CreateElement(aa.Key); i.InnerXml = aa.Value; address.AppendChild(i); } addresses.AppendChild(address); } doc.AppendChild(root); string xmlString = null; using (StringWriter stringWriter = new StringWriter()) { using (XmlWriter xmlTextWriter = XmlWriter.Create(stringWriter)) { doc.WriteTo(xmlTextWriter); xmlTextWriter.Flush(); xmlString = stringWriter.GetStringBuilder().ToString(); } } return(xmlString); }
public override bool ToXML(System.Xml.XmlElement myElement) { if (myElement != null) { this.Attributes.ToXML(myElement); base.ToXML(myElement); myElement.SetAttribute("type", StringCommon.GetNameByType(this.Type)); myElement.SetAttribute("name", this.Name); if (this.Type == ElementType.HaveNotElement) { myElement.SetAttribute("prifix", this.Prifix); myElement.SetAttribute("postfix", this.Postfix); } myElement.SetAttribute("text", this.text); foreach (ZYSelectableElementItem eleItem in this.myList) { XmlElement item = myElement.OwnerDocument.CreateElement(eleItem.GetXMLName()); myElement.AppendChild(item); eleItem.ToXML(item); } return(true); } return(false); }
/// <summary> /// 原有課程規劃表 加入科目 <subject></subject> /// </summary> /// <param name="orginXmlContent"></param> /// <param name=""></param> /// <returns></returns> public System.Xml.XmlElement AddXmlElement(System.Xml.XmlElement orginXmlContent, List <UpdateCourseInfo> InsertCourseInfo) { XmlDocument doc = orginXmlContent.OwnerDocument; foreach (UpdateCourseInfo insertCourseInfo in InsertCourseInfo) { Dictionary <int, string> CreditSemesters = insertCourseInfo.NewCourseInfo.DicCreditEachSemester; string rowIndex = Helper.GetMaxRow(orginXmlContent).ToString(); int level = 1; int startLevel = 0; foreach (int semester in CreditSemesters.Keys) { XmlElement subjectNode = doc.CreateElement("Subject"); orginXmlContent.AppendChild(subjectNode); subjectNode.SetAttribute("Category", ""); subjectNode.SetAttribute("Credit", CreditSemesters[semester]); subjectNode.SetAttribute("Domain", insertCourseInfo.NewCourseInfo.領域名稱); subjectNode.SetAttribute("Entry", Helper.GetEntryByCSVCodeDetail(insertCourseInfo.NewCourseInfo.科目屬性說明)); subjectNode.SetAttribute("GradeYear", Helper.GetGradeYear(semester).GradeYear.ToString()); // 處理一下級別 if (Helper.GetSubjectCount(orginXmlContent, insertCourseInfo.NewCourseInfo.NewSubjectName) > 0) { if (insertCourseInfo.NewCourseInfo.NewSubjectName.Contains("國語文")) { } level = Helper.GetSubjectCount(orginXmlContent, insertCourseInfo.NewCourseInfo.NewSubjectName); if (startLevel == 0) { insertCourseInfo.NewCourseInfo.StartLevel = Helper.GetSubjectCount(orginXmlContent, insertCourseInfo.NewCourseInfo.NewSubjectName); startLevel = insertCourseInfo.NewCourseInfo.StartLevel; } } subjectNode.SetAttribute("Level", level.ToString()); subjectNode.SetAttribute("FullName", insertCourseInfo.NewCourseInfo.NewSubjectName + " " + Helper.GetRomaNumber(level)); subjectNode.SetAttribute("NotIncludedInCalc", "False"); subjectNode.SetAttribute("NotIncludedInCredit", "False"); subjectNode.SetAttribute("Required", insertCourseInfo.NewCourseInfo.Required); subjectNode.SetAttribute("RequiredBy", insertCourseInfo.NewCourseInfo.RequiredBy); subjectNode.SetAttribute("Semester", Helper.GetGradeYear(semester).Semester.ToString()); subjectNode.SetAttribute("SubjectName", insertCourseInfo.NewCourseInfo.NewSubjectName); subjectNode.SetAttribute("課程代碼", insertCourseInfo.NewCourseInfo.新課程代碼); subjectNode.SetAttribute("課程類別", insertCourseInfo.NewCourseInfo.課程類別說明); subjectNode.SetAttribute("開課方式", insertCourseInfo.NewCourseInfo.開課方式); subjectNode.SetAttribute("科目屬性", insertCourseInfo.NewCourseInfo.科目屬性說明); subjectNode.SetAttribute("開課方式", insertCourseInfo.NewCourseInfo.開課方式); subjectNode.SetAttribute("領域名稱", insertCourseInfo.NewCourseInfo.領域名稱); subjectNode.SetAttribute("授課學期學分", insertCourseInfo.NewCourseInfo.授課學期學分); // 建立Grouping XmlElemet XmlElement groupNode = doc.CreateElement("Grouping"); subjectNode.AppendChild(groupNode); groupNode.SetAttribute("RowIndex", rowIndex); groupNode.SetAttribute("startLevel", insertCourseInfo.NewCourseInfo.StartLevel.ToString()); level++; } } return(orginXmlContent); }
/// <summary> /// Saves the current collection of Host Instances to disk /// </summary> /// <param name="xmlDocName">Filename (verbatim) to save data to - User AppData Path is prepended /// if the path does not start with either ?: or \\</param> public virtual void ToXml(String xmlDocName) { System.Xml.XmlDocument xmlData = new System.Xml.XmlDocument(); // Create the XML Declaration (well formed) XmlDeclaration xmlDeclaration = xmlData.CreateXmlDeclaration("1.0", "utf-8", null); xmlData.InsertBefore(xmlDeclaration, xmlData.DocumentElement); // Create the root element System.Xml.XmlElement xmlRoot = xmlData.CreateElement("Hosts"); // Loop through the collection and serialize the lot foreach (KeyValuePair <String, Base> de in this) { Base fi = (Base)de.Value; XmlDocument xmlDoc = fi.ToXml(); foreach (XmlNode xn in xmlDoc.ChildNodes) { xmlRoot.AppendChild(xmlData.ImportNode(xn, true)); } } xmlData.AppendChild(xmlRoot); // Save the XML stream to the file if ((xmlDocName.Substring(1, 1) == ":") || (xmlDocName.StartsWith("\\\\"))) { xmlData.Save(xmlDocName); } else { xmlData.Save(Preferences.PreferenceSet.Instance.AppDataPath + "\\" + xmlDocName); } }
public void setXmlInfo(System.Xml.XmlDocument To_JavaXml, System.Xml.XmlElement engBaseInfo, MDL.T_Projects project = null, System.Xml.XmlElement root = null) { List <T_Model> outList = new List <T_Model>(); outList = ProjectXML_Factory.setXmlInfo(To_JavaXml, project, "queryByItemID", engBaseInfo, "Item", " and a.ItemID='" + project.ItemID + "'"); List <string> list2 = new List <string>(); list2.AddRange(new string[] { "xmdesignOrgSidtmp", "xmreconnaissanceOrgSidtmp", "xmsupervisionOrgSidtmp" }); XmlElement X_temp = null; if (outList != null) { foreach (var item in outList) { if (list2.Contains(item.MappColumn)) { ProjectXML_Factory.FieldMethod(To_JavaXml, item, item.Column, ref X_temp, projectFactory); } else { X_temp = To_JavaXml.CreateElement(item.MappColumn); X_temp.SetAttribute("value", item.Default); } //X_temp.SetAttribute("description", item.Description==null?"":item.Description.ToString()); engBaseInfo.AppendChild(X_temp); } } }
/// <summary> Encodes a Composite in XML by looping through it's components, creating new /// children for each of them (with the appropriate names) and populating them by /// calling encode(Type, Element) using these children. Returns true if at least /// one component contains a value. /// </summary> private bool encodeComposite(Composite datatypeObject, System.Xml.XmlElement datatypeElement) { Type[] components = datatypeObject.Components; bool hasValue = false; for (int i = 0; i < components.Length; i++) { System.String name = makeElementName(datatypeObject, i + 1); System.Xml.XmlElement newNode = datatypeElement.OwnerDocument.CreateElement(name); bool componentHasValue = encode(components[i], newNode); if (componentHasValue) { try { datatypeElement.AppendChild(newNode); } catch (System.Exception e) { throw new DataTypeException("DOMException encoding Composite: ", e); } hasValue = true; } } return(hasValue); }
/// <summary> /// utility function to write the simple setParameter.xml file /// </summary> /// <param name="loggingHelper"></param> /// <param name="parameters"></param> /// <param name="outputFileName"></param> private static void WriteSetParametersToFile(Utilities.TaskLoggingHelper loggingHelper, Framework.ITaskItem[] parameters, string outputFileName, bool foptimisticParameterDefaultValue) { Xml.XmlDocument document = new System.Xml.XmlDocument(); Xml.XmlElement parametersElement = document.CreateElement("parameters"); document.AppendChild(parametersElement); if (parameters != null) { System.Collections.Generic.IList <Framework.ITaskItem> items = Utility.SortParametersTaskItems(parameters, foptimisticParameterDefaultValue, SimpleSyncParameterMetadata.Value.ToString()); // only the first value win System.Collections.Generic.Dictionary <string, Xml.XmlElement> dictionaryLookup = new System.Collections.Generic.Dictionary <string, Xml.XmlElement>(parameters.GetLength(0)); foreach (Framework.ITaskItem item in items) { string name = item.ItemSpec; if (!dictionaryLookup.ContainsKey(name)) { Xml.XmlElement parameterElement = document.CreateElement("setParameter"); parameterElement.SetAttribute("name", name); string value = item.GetMetadata("value"); parameterElement.SetAttribute("value", value); dictionaryLookup.Add(name, parameterElement); parametersElement.AppendChild(parameterElement); } } } // Save the UTF8 and Indented Utility.SaveDocument(document, outputFileName, System.Text.Encoding.UTF8); }
/// <summary> /// Convert the data filter conditions into XML /// </summary> /// <returns>XmlElement</returns> public XmlElement Serialize(XmlDocument doc) { System.Xml.XmlElement root = doc.CreateElement("dataFilters"); System.Xml.XmlAttribute type = doc.CreateAttribute("recordProcessScope"); switch (this.RecordProcessScope) { case RecordProcessingScope.Undeleted: type.Value = "undeleted"; break; case RecordProcessingScope.Deleted: type.Value = "deleted"; break; case RecordProcessingScope.Both: type.Value = "both"; break; } root.Attributes.Append(type); foreach (DataRow row in ConditionTable.Rows) { FilterCondition filterCondition = (FilterCondition)row[COLUMN_FILTER]; XmlNode xmlNode = filterCondition.Serialize(doc, row[COLUMN_FRIENDLY_JOIN].ToString().ToLowerInvariant()); root.AppendChild(xmlNode); } return(root); }
/// <summary> /// Create <fonts> node and put all fonts here by analyzing BaseTextItems in parentItem /// </summary> /// <param name="doc"></param> /// <param name="element"></param> public void Save(EditorItem parentItem, System.Xml.XmlDocument doc, System.Xml.XmlElement element) { XmlElement el = doc.CreateElement("Fonts"); List <BaseTextItems> baseTextItems = new List <BaseTextItems>(); EditorFont editorFont; GetBaseTextItems(parentItem, baseTextItems); this.fonts.Clear(); foreach (BaseTextItems textItem in baseTextItems) { // create and save each font still not created. We first check if it exists so not to save duplicates // currently font is unique if has same name and style editorFont = FindFont(textItem.Font.Name, textItem.Font.Style); if (editorFont == null) { editorFont = CreateFont(textItem.Font); editorFont.Save(doc, el); } // so we later know how to load it textItem.FontSaveId = editorFont.SaveID; } element.AppendChild(el); }
/// <summary> Populates the given Element with data from the given Segment, by inserting /// Elements corresponding to the Segment's fields, their components, etc. Returns /// true if there is at least one data value in the segment. /// </summary> public virtual bool encode(Segment segmentObject, System.Xml.XmlElement segmentElement) { bool hasValue = false; int n = segmentObject.numFields(); for (int i = 1; i <= n; i++) { System.String name = makeElementName(segmentObject, i); Type[] reps = segmentObject.getField(i); for (int j = 0; j < reps.Length; j++) { System.Xml.XmlElement newNode = segmentElement.OwnerDocument.CreateElement(name); bool componentHasValue = encode(reps[j], newNode); if (componentHasValue) { try { segmentElement.AppendChild(newNode); } catch (System.Exception e) { throw new NuGenHL7Exception("DOMException encoding Segment: ", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR, e); } hasValue = true; } } } return(hasValue); }
private XmlNode DomainObjectToXmlNode(Type type, object[] objs, string[] schema) { XmlDocument doc = new XmlDocument(); System.Xml.XmlElement rootElement = doc.CreateElement("xml"); rootElement.SetAttribute("xmlns:s", "uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"); rootElement.SetAttribute("xmlns:dt", "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"); rootElement.SetAttribute("xmlns:rs", "urn:schemas-microsoft-com:rowset"); rootElement.SetAttribute("xmlns:z", "#RowsetSchema"); rootElement.AppendChild(DomainObjectSchemaToXml(doc, type, schema)); rootElement.AppendChild(DomainObjectDataToXml(doc, objs, schema)); return(rootElement); }
void AddPatchInfo(string patchinfofilename, string nodename, string filestring) { if (filestring == null) { return; } string [] filenames = filestring.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (System.IO.File.Exists(patchinfofilename)) { System.Xml.XmlDocument xml = new XmlDocument(); xml.Load(patchinfofilename); System.Xml.XmlNode patchinfo = xml.SelectSingleNode("Patchinfo"); System.Xml.XmlElement node = (System.Xml.XmlElement)patchinfo.SelectSingleNode(nodename); if (node == null) { node = xml.CreateElement(nodename); patchinfo.AppendChild(node); } foreach (string name in filenames) { System.Xml.XmlElement file = xml.CreateElement("File"); file.SetAttribute("Name", name); node.AppendChild(file); } xml.Save(patchinfofilename); } }
public void setXmlInfo(System.Xml.XmlDocument To_JavaXml, System.Xml.XmlElement engBaseInfo, MDL.T_Projects project = null, System.Xml.XmlElement root = null) { List <T_Model> outList = new List <T_Model>(); outList = ProjectXML_Factory.setXmlInfo(To_JavaXml, project, "queryByProjectNo", engBaseInfo, "Project", " where ProjectNo='" + project.ProjectNO + "'"); List <string> list = new List <string>();//单位 list.AddRange(new string[] { "initiationApprovalOrgSid", "developmentsOrgName", "designOrgSid", "reconnaissanceOrgSid", "supervisionOrgSid", "reconnaissanceOrgBy", "subpackageOrgBy", "subpackageOrgName", "constructOrgBy", "constructOrgName", "jldw_xmzj", "constructOrgSid", "supervisionOrgName", "designOrgName", "jldw_xmfzr" }); if (outList != null) { foreach (var item in outList) { if (list.Contains(item.MappColumn)) { ProjectXML_Factory.FieldMethod(To_JavaXml, item, item.Column, ref X_temp, projectFactory); } else { X_temp = To_JavaXml.CreateElement(item.MappColumn); X_temp.SetAttribute("value", item.Default); } engBaseInfo.AppendChild(X_temp); } } }
public void WritePictureXMLFile() { GlobalDataStore.Logger.Debug("Updating Pictures.xml ..."); List <LabelX.Toolbox.LabelXItem> items = new List <LabelX.Toolbox.LabelXItem>(); DirectoryInfo PicturesRootFolderDirectoryInfo = new DirectoryInfo(PicturesRootFolder); LabelX.Toolbox.Toolbox.GetPicturesFromFolderTree(PicturesRootFolderDirectoryInfo.FullName, ref items); //items = alle ingelezen pictures. Nu gaan wegschrijven. System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlElement root = doc.CreateElement("LabelXItems"); foreach (LabelX.Toolbox.LabelXItem item in items) { System.Xml.XmlElement itemXML = doc.CreateElement("item"); itemXML.SetAttribute("name", item.Name); itemXML.SetAttribute("hash", item.Hash); root.AppendChild(itemXML); } doc.AppendChild(root); MemoryStream ms = new MemoryStream(); System.Xml.XmlTextWriter tw = new System.Xml.XmlTextWriter(ms, Encoding.UTF8); tw.Formatting = System.Xml.Formatting.Indented; doc.WriteContentTo(tw); doc.Save(PicturesRootFolder + "pictures.xml"); tw.Close(); }
protected override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); //Base implementation must be called var formStringNode = element.OwnerDocument.CreateElement("FormulaText"); formStringNode.InnerText = FormulaString; element.AppendChild(formStringNode); }
/// <summary> /// utility function to write the simple setParameter.xml file /// </summary> /// <param name="loggingHelper"></param> /// <param name="parameters"></param> /// <param name="outputFileName"></param> private static void WriteManifestsToFile(Utilities.TaskLoggingHelper loggingHelper, Framework.ITaskItem[] items, string outputFileName) { Xml.XmlDocument document = new System.Xml.XmlDocument(); Xml.XmlElement manifestElement = document.CreateElement("sitemanifest"); document.AppendChild(manifestElement); if (items != null) { foreach (Framework.ITaskItem item in items) { string name = item.ItemSpec; Xml.XmlElement providerElement = document.CreateElement(name); string path = item.GetMetadata("Path"); providerElement.SetAttribute("path", path); string additionProviderSetting = item.GetMetadata("AdditionalProviderSettings"); if (!string.IsNullOrEmpty(additionProviderSetting)) { string[] providerSettings = additionProviderSetting.Split(';'); foreach (string ps in providerSettings) { string value = item.GetMetadata(ps); if (!string.IsNullOrEmpty(value)) { providerElement.SetAttribute(ps, value); } } } manifestElement.AppendChild(providerElement); } } // Save the UTF8 and Indented SaveDocument(document, outputFileName, System.Text.Encoding.UTF8); }
public Projects() { fileNames.Add(Form1.SubformType.DAYSHOURS, "tageStunden.csv"); fileNames.Add(Form1.SubformType.SUBJECT, "faecher.csv"); fileNames.Add(Form1.SubformType.CLASSES, "klassen.csv"); fileNames.Add(Form1.SubformType.TEACHER, "lehrer.csv"); fileNames.Add(Form1.SubformType.TEACHERTOCLASS, "klasseFachLehrer.csv"); fileNames.Add(Form1.SubformType.CLASSTOSUBJECTPRESET, "klassenStundenFest.csv"); fileNames.Add(Form1.SubformType.CONFIG, "config.csv"); if (Form1.config.config_xml.DocumentElement.GetElementsByTagName("projects_base_folder").Count == 0) { System.Xml.XmlElement projects_base_folder = Form1.config.config_xml.CreateElement("projects_base_folder"); projects_base_folder.InnerXml = Form1.applicationDir + Path.DirectorySeparatorChar + "projects"; System.Xml.XmlElement root = Form1.config.config_xml.DocumentElement; root.AppendChild(projects_base_folder); Form1.config.Save_config_file(); } projectBaseFolder = Form1.config.config_xml.DocumentElement["projects_base_folder"].InnerXml; log_output = "info: project base folder is " + projectBaseFolder; Form1.logWindow.Write_to_log(ref log_output); FillProjectView(); }
public void SaveData(string id, Form1.SubformType mySubformType, List <List <string> > data) { try { string fileName = fileNames[mySubformType]; string metaXML = projectBaseFolder + Path.DirectorySeparatorChar + id + Path.DirectorySeparatorChar + "meta.xml"; if (File.Exists(metaXML)) { if (data.Count > 1) { XmlDocument meta_xml = new XmlDocument(); meta_xml.Load(metaXML); if (meta_xml.DocumentElement.GetElementsByTagName("state").Count == 0) { System.Xml.XmlElement state = meta_xml.CreateElement("state"); state.InnerXml = mySubformType.ToString(); System.Xml.XmlElement root = meta_xml.DocumentElement; root.AppendChild(state); } else { XmlNode state = meta_xml.DocumentElement.GetElementsByTagName("state")[0]; state.InnerXml = mySubformType.ToString(); } meta_xml.Save(metaXML); Form1.myself.DeactivateActivateMenuItems(mySubformType); } string writeFile = projectBaseFolder + Path.DirectorySeparatorChar + id + Path.DirectorySeparatorChar + fileName; Encoding utf8WithoutBom = new UTF8Encoding(false); StreamWriter sw = new StreamWriter(writeFile, false, utf8WithoutBom); int lastColIndex = data[0].Count; foreach (List <string> row in data) { if (row != null) { foreach (string cell in row) { string sout = cell.Trim(); sout = sout.Replace(";", "###SEMICOLON###"); sw.Write(sout); sw.Write(";"); } sw.WriteLine(); } } sw.Close(); } } catch (IOException e) { log_output = e.ToString(); Form1.logWindow.Write_to_log(ref log_output); string msg = Form1.LocRM.GetString("String133"); MessageBox.Show(msg, "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public void UpdateMetaProjectName(string newGuid, string newProjectName) { string metaXML = projectBaseFolder + Path.DirectorySeparatorChar + newGuid + Path.DirectorySeparatorChar + "meta.xml"; if (File.Exists(metaXML)) { XmlDocument meta_xml = new XmlDocument(); meta_xml.Load(metaXML); if (meta_xml.DocumentElement.GetElementsByTagName("name").Count == 0) { System.Xml.XmlElement name = meta_xml.CreateElement("name"); name.InnerXml = newProjectName; System.Xml.XmlElement root = meta_xml.DocumentElement; root.AppendChild(name); } else { XmlNode name = meta_xml.DocumentElement.GetElementsByTagName("name")[0]; name.InnerXml = newProjectName; } meta_xml.Save(metaXML); log_output = "info: project " + metaXML + " name changed"; Form1.logWindow.Write_to_log(ref log_output); } }
public virtual void Write(System.Xml.XmlElement xElement, string name, TestSerializeData obj) { var node = xElement.OwnerDocument.CreateElement(name); xElement.AppendChild(node); ReXmlSerializer.Write(xElement, "helloInt", obj.helloInt); CustomSerializer.GetSerializer <TestSerializeData>().Write(xElement, "testData", obj.testData); }
internal override void BuildNodes(System.Xml.XmlElement parent, System.Xml.XmlDocument doc) { XmlElement el = doc.CreateElement("Surface"); XmlHelper.AppendAttribute(el, doc, "name", Name); XmlHelper.AppendAttribute(el, doc, "filename", Filename); parent.AppendChild(el); }
public System.Xml.XmlElement ConvertToXml() { System.Xml.XmlElement node = Forms.frmQuickReportEditor.xmlDocument.CreateElement(XmlAttrDic.ConditionObjectList.ToString()); foreach (DictionaryEntry de in ucConditionObjectControls) { node.AppendChild((de.Value as ucConditionObject).ConvertToXml()); } return(node); }
public System.Xml.XmlElement ConvertToXml() { System.Xml.XmlElement node = Forms.frmQuickReportEditor.xmlDocument.CreateElement(XmlAttrDic.HeaderObjectList.ToString()); for (int i = 0; i < fpMain_Sheet1.Rows.Count; i++) { node.AppendChild(RowToXml(i)); } return(node); }
/// <summary> /// /// </summary> /// <param name="xmlData"></param> /// <param name="xPath"></param> /// <param name="nodeText"></param> /// <returns></returns> public static XmlElement createXmlNode(XmlDocument xmlDoc, String xPath, String nodeText) { System.Xml.XmlElement xmlEl = xmlDoc.CreateElement(xPath); System.Xml.XmlNode xmlN = xmlDoc.CreateNode(XmlNodeType.Text, xPath, String.Empty); xmlN.Value = nodeText; xmlEl.AppendChild(xmlN); return(xmlEl); }
/// <summary> /// Generates an Xml element for this rule /// </summary> /// <param name="doc">The parent Xml document</param> /// <returns>XmlNode representing this rule</returns> public override System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc) { if (assignValue.ToString().Length > 0 && string.IsNullOrEmpty(assignValue.ToString().Trim())) { assignValue = " "; } if (UseElse && elseValue != null && elseValue.ToString().Length > 0 && string.IsNullOrEmpty(elseValue.ToString().Trim())) { elseValue = " "; } string xmlString = "<friendlyRule>" + friendlyRule.Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</friendlyRule>" + "<destinationColumnName>" + destinationColumnName + "</destinationColumnName>" + "<destinationColumnType>" + destinationColumnType + "</destinationColumnType>"; if (DestinationColumnType == "System.Decimal" && assignValue is decimal) { decimal d = (decimal)assignValue; xmlString += "<assignValue>" + d.ToString(CultureInfo.InvariantCulture).Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</assignValue>"; } else { xmlString += "<assignValue>" + assignValue.ToString().Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</assignValue>"; } xmlString += "<useElse>" + UseElse + "</useElse>"; if (elseValue != null) { //xmlString = xmlString + "<elseValue>" + elseValue.ToString().Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</elseValue>"; if (DestinationColumnType == "System.Decimal" && elseValue is decimal) { decimal d = (decimal)elseValue; xmlString += "<elseValue>" + d.ToString(CultureInfo.InvariantCulture).Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</elseValue>"; } else { xmlString += "<elseValue>" + elseValue.ToString().Replace("&", "&").Replace("<", "<").Replace(">", ">") + "</elseValue>"; } } System.Xml.XmlElement element = doc.CreateElement("rule"); element.InnerXml = xmlString; element.AppendChild(DataFilters.Serialize(doc)); System.Xml.XmlAttribute order = doc.CreateAttribute("order"); System.Xml.XmlAttribute type = doc.CreateAttribute("ruleType"); type.Value = "EpiDashboard.Rules.Rule_ConditionalAssign"; element.Attributes.Append(type); return(element); }