private static void MapDomResourceToApiAttributes(ISetAttributes apiSetAttributes, DomReadWriteResource domResource) { Contract.Requires(apiSetAttributes != null); Contract.Requires(domResource != null); var domAttributesNode = domResource.GetNode <DomNodeType, DomAttributes>(DomNodeType.Attributes); if (domAttributesNode == null) { return; } var domAttributeCollection = domAttributesNode.Nodes() .Cast <DomAttribute>() .ToList(); if (!domAttributeCollection.Any()) { return; } var apiObject = CreateApiObjectFromDomAttributeCollection(domAttributeCollection); apiSetAttributes.Attributes = apiObject; }
private static void SetAttributeOnObject(ISchemaElement schemaElement, string name, string value) { ISetAttributes setAttributes = schemaElement as ISetAttributes; if (setAttributes == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, WixHarvesterStrings.EXP_ISchemaElementDoesnotImplementISetAttribute, schemaElement.GetType().FullName)); } else { setAttributes.SetAttribute(name, value); } }
/// <summary> /// Sets an attribute on an ISchemaElement. /// </summary> /// <param name="schemaElement">Schema element to set attribute on.</param> /// <param name="name">Name of the attribute to set.</param> /// <param name="value">Value to set on the attribute.</param> private static void SetAttributeOnObject(ISchemaElement schemaElement, string name, string value) { ISetAttributes setAttributes = schemaElement as ISetAttributes; if (setAttributes == null) { throw new InvalidOperationException(String.Concat("ISchemaElement with name ", schemaElement.GetType().FullName.ToString(), " does not implement ISetAttributes.")); } else { setAttributes.SetAttribute(name, value); } }
protected static void ReadAttributes(JToken jParentToken, JsonSerializer serializer, ISetAttributes setAttributes) { Contract.Requires(jParentToken != null); Contract.Requires(serializer != null); Contract.Requires(setAttributes != null); var attributesJToken = jParentToken.SelectToken(Keywords.Attributes); if (attributesJToken == null) { return; } var attributesJObject = (JObject)attributesJToken; var attributes = ReadApiObject(attributesJObject, serializer); setAttributes.Attributes = attributes; }