public void WriteLink(XmlElement parent, Link link) { var element = parent.AddElement("link").WithAtt("href", link.Url); link.Title.IfNotNull(x => element.WithAtt("title", x)); link.Rel.IfNotNull(x => element.WithAtt("rel", x)); link.ContentType.IfNotNull(x => element.WithAtt("type", x)); }
public void Write(XmlElement classElement, IMappingModelVisitor visitor) { XmlElement filterElement = classElement.AddElement("filter"); filterElement.SetAttribute("name", Name); if (!string.IsNullOrEmpty(Condition)) { filterElement.SetAttribute("condition", Condition); } }
void HandleContact(XmlElement contactsXml, Contact contact) { var contactXml = contactsXml.AddElement("Contact"); contactXml.SetAttribute("href", string.Format("{0}/contacts/{1}", this.baseUri, contact.ContactId)); contactXml.AddElement("Name", contact.Name); contactXml.AddElement("Address", contact.Address); contactXml.AddElement("City", contact.City); contactXml.AddElement("State", contact.State); contactXml.AddElement("Zip", contact.Zip); contactXml.AddElement("Email", contact.Email); HandleTwitter(contactXml, contact); }
void HandleQueries(XmlElement root) { var queriesXml = root.AddElement("Queries"); var twitterContactsXml = queriesXml.AddElement("Query"); twitterContactsXml.SetAttribute("name", "query-twitter-contacts"); twitterContactsXml.SetAttribute("href", string.Format("{0}/contacts/twitter", this.baseUri)); var searchXml = queriesXml.AddElement("Query"); searchXml.SetAttribute("name", "query-search"); searchXml.SetAttribute("href", string.Format("{0}/contacts/search", this.baseUri)); searchXml.AddElement("Field", "Name"); }
private static void ParseProcessorDefinitions([NotNull] XmlNodeList processorNodes, [NotNull] List<ProcessorDefinition> processorDefinitions, XmlElement parentNode) { Assert.ArgumentNotNull(processorNodes, "processorNodes"); Assert.ArgumentNotNull(processorDefinitions, "processorDefinitions"); foreach (XmlElement processorElement in processorNodes.OfType<XmlElement>()) { ProcessorDefinition definition = ParseProcessorDefinition(processorElement); var definitionNode = parentNode.AddElement("processor"); definitionNode.SetAttribute("type", definition.Type.FullName); definitionNode.SetAttribute("title", definition.Title); definitionNode.SetAttribute("process", definition.ProcessAlways ? "always" : "once"); definitionNode.SetAttribute("param", definition.Param); // add nested processor definitions ParseProcessorDefinitions(processorElement.ChildNodes, definition.NestedProcessorDefinitions, definitionNode); processorDefinitions.Add(definition); } }
private void AddTemplateVariants(XmlElement template) { XmlDocument ownerDocument = template.OwnerDocument; XmlElement templateVariants = template.AddElement("TEMPLATEVARIANTS"); foreach (ITemplateVariant curTemplateVariant in TemplateVariants) { XmlElement templateVariant = templateVariants.AddElement("TEMPLATEVARIANT"); templateVariant.AddAttribute("name", curTemplateVariant.Name); // ReSharper disable PossibleNullReferenceException XmlText textNode = ownerDocument.CreateTextNode(curTemplateVariant.Data); // ReSharper restore PossibleNullReferenceException templateVariant.AppendChild(textNode); } }
private void AddTemplateDescriptions(IProject project, XmlElement template) { XmlElement templateDescriptions = template.AddElement("TEMPLATEDESCRIPTIONS"); foreach (ILanguageVariant languageVariant in project.LanguageVariants) { XmlElement templateDescription = templateDescriptions.AddElement("TEMPLATEDESCRIPTION"); templateDescription.AddAttribute("dialoglanguageid", languageVariant.Abbreviation); templateDescription.AddAttribute("name", Name); if (!string.IsNullOrEmpty(DescriptionInCurrentDisplayLanguage)) { templateDescription.AddAttribute("description", DescriptionInCurrentDisplayLanguage); } } }
private void AddProjectVariants(IProject project, XmlElement template) { XmlElement projectVariants = template.AddElement("PROJECTVARIANTS"); projectVariants.AddAttribute("action", "assign"); foreach (IProjectVariant curVariant in Project.ProjectVariants) { XmlElement projectVariant = projectVariants.AddElement("PROJECTVARIANT"); IProjectVariant otherVariant; if (!project.ProjectVariants.TryGetByName(curVariant.Name, out otherVariant)) { throw new SmartAPIException(Session.ServerLogin, string.Format("Could not find project variant {0} in project {1}", curVariant.Name, project.Name)); } projectVariant.AddAttribute("guid", otherVariant.Guid.ToRQLString()); } }
public void Write(XmlElement classElement, IMappingVisitor visitor) { var versionElement = classElement .AddElement("version") .WithProperties(properties); if (neverGenerated) { versionElement.WithAtt("generated", "never"); } if (Property.PropertyType == typeof(DateTime)) { versionElement.WithAtt("type", "timestamp"); } }
public void Write(XmlElement classElement, IMappingVisitor visitor) { XmlElement element = classElement.AddElement("id") .WithAtt("name", property.Name) .WithAtt("type", TypeMapping.GetTypeString(property.PropertyType)); if (unsavedValue != null) element.WithAtt("unsaved-value", unsavedValue.ToString()); elementAttributes.ForEachPair((name, value) => element.WithAtt(name, value)); XmlElement generatorElement = element.AddElement("generator").WithAtt("class", GeneratorClass); generatorParameters.ForEachPair( (name, innerXml) => generatorElement.AddElement("param").WithAtt("name", name).InnerXml = innerXml); }
void HandleTwitter(XmlElement contactXml, Contact contact) { if (contact.Twitter != null) { var twitterXml = contactXml.AddElement("Twitter"); twitterXml.SetAttribute("user", "gblock"); // SB logged-in user var tweetsXml = twitterXml.AddElement("Tweets"); tweetsXml.SetAttribute("href", string.Format("{0}/contacts/{1}/tweets", this.baseUri, contact.ContactId)); var dmXml = twitterXml.AddElement("DM"); var field = dmXml.AddElement("Field", "Message"); dmXml.SetAttribute("href", string.Format("{0}/contacts/{1}/dm", this.baseUri, contact.ContactId)); ; var mentionXml = twitterXml.AddElement("Mention"); field = mentionXml.AddElement("Field", "Message"); mentionXml.SetAttribute("href", string.Format("{0}/contacts/{1}/mention", this.baseUri, contact.ContactId)); } }
public void Write(XmlElement classElement, IMappingVisitor visitor) { if (!IsDirty) return; var cacheElement = classElement.AddElement("cache") .WithAtt("usage", usage); if (!string.IsNullOrEmpty(region)) cacheElement.WithAtt("region", region); cacheElement.WithProperties(attributes); }