Esempio n. 1
0
        public SLiteralNode(dynamic value, string lang, Uri type, SGraph graph)
        {
            this.Language = lang;
            this.dataType = type;
            this.g        = graph;
            if (lang != null)
            {
                if (dataType == null)
                {
                    dataType = XmlSchema.XMLSchemaLangString;
                }
                if (dataType != XmlSchema.XMLSchemaLangString)
                {
                    throw new Exception();
                }
                LiteralType = LiteralTypeEnum.langString;
            }
            if (value == null)
            {
                throw new Exception();
            }
            if (value is string)
            {
                if (type == null)
                {
                    this.value  = value;
                    LiteralType = LiteralTypeEnum.@string;
                }
                else if (type.AbsoluteUri == XmlSchema.XMLSchemaInteger.AbsoluteUri)
                {
                    LiteralType = LiteralTypeEnum.@int;
                    this.value  = int.Parse(value);
                }
                else if (type.AbsoluteUri == XmlSchema.XMLSchemaFloat.AbsoluteUri)
                {
                    LiteralType = LiteralTypeEnum.@float;
                    this.value  = float.Parse(value);
                }
                else if (type.AbsoluteUri == XmlSchema.XMLSchemaDouble.AbsoluteUri)
                {
                    LiteralType = LiteralTypeEnum.@double;
                    this.value  = double.Parse(value);
                }
                else if (type.AbsoluteUri == XmlSchema.XMLSchemaDate.AbsoluteUri)
                {
                    LiteralType = LiteralTypeEnum.@date;
                    this.value  = DateTime.Parse(value);
                }
                else if (type.AbsoluteUri == XmlSchema.XMLSchemaDateTime.AbsoluteUri)
                {
                    LiteralType = LiteralTypeEnum.@dateTime;
                    this.value  = DateTime.Parse(value);
                }
                else if (type.AbsoluteUri == XmlSchema.XMLSchemaBool.AbsoluteUri)
                {
                    LiteralType = LiteralTypeEnum.boolean;
                    this.value  = bool.Parse(value);
                }

                return;
            }
            this.value = value;
        }
Esempio n. 2
0
        public SLiteralNode(object @object, SGraph graph)
        {
            this.g = graph;
            var objectPresent = ((object[])@object);

            LiteralType = (LiteralTypeEnum)(int)objectPresent[0];
            switch (LiteralType)
            {
            case LiteralTypeEnum.@int:
                value    = (int)objectPresent[1];
                dataType = XmlSchema.XMLSchemaInteger;
                break;

            case LiteralTypeEnum.@float:
                value    = (float)objectPresent[1];
                dataType = XmlSchema.XMLSchemaFloat;
                break;

            case LiteralTypeEnum.@double:
                value    = (double)objectPresent[1];
                dataType = XmlSchema.XMLSchemaDouble;
                break;

            case LiteralTypeEnum.boolean:
                value    = (bool)objectPresent[1];
                dataType = XmlSchema.XMLSchemaBool;
                break;

            case LiteralTypeEnum.date:
                value    = (DateTime.FromBinary((long)objectPresent[1]));
                dataType = XmlSchema.XMLSchemaDate;
                break;

            case LiteralTypeEnum.dateTime:
                value    = (DateTime.FromBinary((long)objectPresent[1]));
                dataType = XmlSchema.XMLSchemaDateTime;
                break;

            case LiteralTypeEnum.@langString:
                objectPresent = (object[])objectPresent[1];
                value         = (string)objectPresent[0];
                Language      = (string)objectPresent[1];
                dataType      = XmlSchema.XMLSchemaLangString;
                break;

            case LiteralTypeEnum.@string:
                value    = (string)objectPresent[1];
                dataType = XmlSchema.XMLSchemaString;
                break;

            case LiteralTypeEnum.otherType:
                objectPresent = (object[])objectPresent[1];
                value         = (string)objectPresent[0];
                dataType      = new Uri((string)objectPresent[1]);
                break;

            case LiteralTypeEnum.nil:
            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 3
0
 public SUriNode(int code, SGraph sGraph)
 {
     // TODO: Complete member initialization
     this.code  = code;
     this.graph = sGraph;
 }
Esempio n. 4
0
 internal SLiteralNode(long code, SGraph g)
 {
     this.g     = g;
     this.ocode = code;
 }
Esempio n. 5
0
 public SUriNode(string uriOrQName, SGraph sGraph)
 {
     code       = uriOrQName.GetHashCode();
     this.graph = sGraph;
 }