Пример #1
0
        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;
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        /// <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);
            }
        }
Пример #4
0
        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;
        }