Ejemplo n.º 1
0
        /// <summary>
        /// Sets the common <see cref="AttributeValue"/>
        /// </summary>
        /// <param name="elementWithAttributes">The <see cref="SpecElementWithAttributes"/> to modify</param>
        /// <param name="thing">The associated <see cref="ICategorizableThing"/></param>
        private void SetCommonAttributeValues(SpecElementWithAttributes elementWithAttributes, ICategorizableThing thing)
        {
            var shortNameType = (AttributeDefinitionString)elementWithAttributes.SpecType.SpecAttributes.Single(x => x.DatatypeDefinition == this.TextDatatypeDefinition && x.LongName == ShortNameAttributeDefName);
            var nameType      = (AttributeDefinitionString)elementWithAttributes.SpecType.SpecAttributes.Single(x => x.DatatypeDefinition == this.TextDatatypeDefinition && x.LongName == NameAttributeDefName);
            var categoryType  = (AttributeDefinitionString)elementWithAttributes.SpecType.SpecAttributes.Single(x => x.DatatypeDefinition == this.TextDatatypeDefinition && x.LongName == CategoryAttributeDefName);

            var castthing = (Thing)thing;

            // Add shortname
            var shortname = new AttributeValueString
            {
                TheValue   = castthing.UserFriendlyShortName ?? string.Empty,
                Definition = shortNameType
            };

            elementWithAttributes.Values.Add(shortname);

            // Add name
            var name = new AttributeValueString
            {
                TheValue   = castthing.UserFriendlyName ?? string.Empty,
                Definition = nameType
            };

            elementWithAttributes.Values.Add(name);

            // Add Category
            var category = new AttributeValueString
            {
                TheValue   = thing.Category.Any() ? string.Join(", ", thing.Category.Select(x => x.ShortName)) : emptyContent,
                Definition = categoryType
            };

            elementWithAttributes.Values.Add(category);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Queries the <see cref="ExternalObject"/> from a <see cref="SpecElementWithAttributes"/>
        /// </summary>
        /// <param name="specElementWithAttributes">
        /// The <see cref="SpecElementWithAttributes"/> to query the <see cref="ExternalObject"/>s from
        /// </param>
        /// <returns>
        /// an <see cref="IEnumerable{ExternalObject}"/>
        /// </returns>
        public static IEnumerable <ExternalObject> QueryExternalObjects(this SpecElementWithAttributes specElementWithAttributes)
        {
            var result = new List <ExternalObject>();

            foreach (var attributeValue in specElementWithAttributes.Values.OfType <AttributeValueXHTML>())
            {
                result.AddRange(attributeValue.ExternalObjects);
            }

            return(result);
        }
        /// <summary>
        /// Create <see cref="AttributeValue"/> For <see cref="SpecElementWithAttributes"/>
        /// </summary>
        /// <param name="specElementWithAttributes">
        /// The <see cref="SpecElementWithAttributes"/> to which <see cref="AttributeValue"/>s need to be added.
        /// </param>
        /// <param name="specType">
        /// The <see cref="SpecType"/> of the <see cref="specElementWithAttributes"/>
        /// </param>
        private void CreateValuesForSpecElementWithAttributes(SpecElementWithAttributes specElementWithAttributes, SpecType specType)
        {
            var attributeValueBoolean = new AttributeValueBoolean();

            attributeValueBoolean.Definition = (AttributeDefinitionBoolean)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionBoolean));
            attributeValueBoolean.TheValue   = true;
            specElementWithAttributes.Values.Add(attributeValueBoolean);

            var attributeValueDate = new AttributeValueDate();

            attributeValueDate.Definition = (AttributeDefinitionDate)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionDate));
            attributeValueDate.TheValue   = XmlConvert.ToDateTime("2015-12-01", XmlDateTimeSerializationMode.Utc);
            specElementWithAttributes.Values.Add(attributeValueDate);

            var attributeValueEnumeration = new AttributeValueEnumeration();

            attributeValueEnumeration.Definition = (AttributeDefinitionEnumeration)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionEnumeration));
            var enumValue = attributeValueEnumeration.Definition.Type.SpecifiedValues.FirstOrDefault();

            attributeValueEnumeration.Values.Add(enumValue);
            specElementWithAttributes.Values.Add(attributeValueEnumeration);

            var attributeValueInteger = new AttributeValueInteger();

            attributeValueInteger.Definition = (AttributeDefinitionInteger)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionInteger));
            attributeValueInteger.TheValue   = 1;
            specElementWithAttributes.Values.Add(attributeValueInteger);

            var attributeValueReal = new AttributeValueReal();

            attributeValueReal.Definition = (AttributeDefinitionReal)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionReal));
            attributeValueReal.TheValue   = 100;
            specElementWithAttributes.Values.Add(attributeValueReal);

            var attributeValueString = new AttributeValueString();

            attributeValueString.Definition = (AttributeDefinitionString)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionString));
            attributeValueString.TheValue   = "a string value";
            specElementWithAttributes.Values.Add(attributeValueString);

            var attributeValueXhtml = new AttributeValueXHTML();

            attributeValueXhtml.Definition = (AttributeDefinitionXHTML)specType.SpecAttributes.SingleOrDefault(x => x.GetType() == typeof(AttributeDefinitionXHTML));
            attributeValueXhtml.TheValue   = this.xhtmlcontent;
            specElementWithAttributes.Values.Add(attributeValueXhtml);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Queries the base64 payloads of the <see cref="SpecElementWithAttributes"/>
        /// </summary>
        /// <param name="specElementWithAttributes">
        /// The <see cref="SpecElementWithAttributes"/> to query the base64 payloads from from
        /// </param>
        /// <param name="reqIfLoaderService">
        /// The <see cref="IReqIFLoaderService"/> that is used to query the payload from the associated reqifz file-stream
        /// </param>
        /// <returns>
        /// an <see cref="IEnumerable{String}"/> that contains base64 encoded strings
        /// </returns>
        public static async Task <IEnumerable <Tuple <ExternalObject, string> > > QueryBase64Payloads(this SpecElementWithAttributes specElementWithAttributes, IReqIFLoaderService reqIfLoaderService)
        {
            var result = new List <Tuple <ExternalObject, string> >();

            var cts = new CancellationTokenSource();

            foreach (var specObjectValue in specElementWithAttributes.Values.OfType <AttributeValueXHTML>())
            {
                foreach (var externalObject in specObjectValue.ExternalObjects)
                {
                    var payload = await reqIfLoaderService.QueryData(externalObject, cts.Token);

                    result.Add(new Tuple <ExternalObject, string>(externalObject, payload));
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AttributeValueSimple"/> class.
 /// </summary>
 /// <param name="specElAt">
 /// The owning <see cref="SpecElementWithAttributes"/>
 /// </param>
 internal AttributeValueSimple(SpecElementWithAttributes specElAt)
     : base(specElAt)
 {
 }