示例#1
0
            public string GetSerializedLimit(object Value, SimplifiedType SimpleType)
            {
                switch (SimpleType)
                {
                case SimplifiedType.String:
                    throw new NotImplementedException();

                case SimplifiedType.Integer:
                    return(XmlConvert.ToString((Int32)Value));

                case SimplifiedType.Decimal:
                    return(XmlConvert.ToString((decimal)Value));

                case SimplifiedType.Double:
                    return(XmlConvert.ToString((double)Value));

                case SimplifiedType.Float:
                    return(XmlConvert.ToString((float)Value));

                case SimplifiedType.Duration:
                    return(XmlConvert.ToString((TimeSpan)Value));

                case SimplifiedType.Time:
                    return(XmlConvert.ToString((TimeSpan)Value));

                case SimplifiedType.DateTime:
                    return(XmlConvert.ToString((DateTime)Value, XmlDateTimeSerializationMode.Utc));

                case SimplifiedType.Base64Binary:
                    throw new NotImplementedException();
                }

                throw new NotImplementedException();
            }
示例#2
0
 public void SerializeToSimpleType(XElement TypeElement, SimplifiedType SimpleType)
 {
     if (MinExclusive != null)
     {
         TypeElement.SetAttributeValue("minexclusive",
                                       GetSerializedLimit(MinExclusive, SimpleType));
     }
     if (MaxExclusive != null)
     {
         TypeElement.SetAttributeValue("maxexclusive",
                                       GetSerializedLimit(MaxExclusive, SimpleType));
     }
     if (Length != null)
     {
         TypeElement.SetAttributeValue("length", XmlConvert.ToString(Length.Value));
     }
 }
示例#3
0
 protected ResourceDescription GetDescription(SimplifiedType SimpleType)
 {
     return(new ResourceDescription()
     {
         Description = Description,
         DisplayName = Displayname,
         Path = Path,
         SimpleType = SimpleType,
         SupportsRead = SupportsRead,
         SupportsWrite = SupportsWrite,
         Restrictions = new ResourceDescription.Restriction()
         {
             MinExclusive = InnerMinExclusive,
             MaxExclusive = InnerMaxExclusive,
             Length = Length
         }
     });
 }
示例#4
0
        public static string GetSerializedValue(this SimplifiedType a)
        {
            switch (a)
            {
            case SimplifiedType.String:
                return("string");

            case SimplifiedType.Integer:
                return("integer");

            case SimplifiedType.Boolean:
                return("boolean");

            case SimplifiedType.Decimal:
                return("decimal");

            case SimplifiedType.Double:
                return("double");

            case SimplifiedType.Float:
                return("float");

            case SimplifiedType.Duration:
                return("duration");

            case SimplifiedType.Time:
                return("time");

            case SimplifiedType.DateTime:
                return("dateTime");

            case SimplifiedType.Base64Binary:
                return("base64Binary");

            default:
                throw new Exception("Simplified type has invalid value: " + a.ToString());
            }
        }
示例#5
0
        public ResourceDescription(XElement Element)
        {
            this.Path = Element.Attribute("path").Value;
            if (Element.Attribute("unit") != null)
            {
                this.Unit = Element.Attribute("unit").Value;
            }
            if (Element.Attribute("description") != null)
            {
                this.Description = Element.Attribute("description").Value;
            }

            XElement TypeDesc = Element.Element(LWTSD.Namespace + "type");

            this.SimpleType = SimplifiedTypeMethods.LoadFromString(
                TypeDesc.Attribute("base").Value);
            this.Restrictions = new Restriction(TypeDesc);

            XElement Supports = Element.Element(LWTSD.Namespace + "supports");

            if (Supports.Attribute("read") != null)
            {
                SupportsRead = XmlConvert.ToBoolean(Supports.Attribute("read").Value);
            }
            if (Supports.Attribute("write") != null)
            {
                SupportsWrite = XmlConvert.ToBoolean(Supports.Attribute("write").Value);
            }
            foreach (XElement It in Supports.Elements())
            {
                if (It.Name.LocalName != "filter")
                {
                    continue;
                }
                this.SupportedFilters.Add(It.Attribute("name").Value);
            }
        }