コード例 #1
0
        internal SLiteralNode(string sdata, SGraph g)
        {
            this.g = g;
            // Последняя двойная кавычка
            int lastqu = sdata.LastIndexOf('\"');

            if (lastqu != -1)
            {
                // Значение данных
                sdata = sdata.Substring(1, lastqu - 1);
            }

            // Языковый специализатор:
            int    dog  = sdata.LastIndexOf('@');
            string lang = "";

            if (dog == lastqu + 1)
            {
                lang = sdata.Substring(dog + 1, sdata.Length - dog - 1);
            }

            string datatype = "";
            int    pp       = sdata.IndexOf("^^");

            if (pp == lastqu + 1)
            {
                //  Тип данных
                string qname = sdata.Substring(pp + 2);
                //  тип данных может быть "префиксным" или полным

                datatype = g.GetEntityString(qname);
                dataType = new Uri(datatype);
            }

            long off = g.AddLiteral(ToObjects(sdata, dataType, lang));

            this.ocode = off;
        }
コード例 #2
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;
        }
コード例 #3
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();
            }
        }
コード例 #4
0
 internal SLiteralNode(long code, SGraph g)
 {
     this.g     = g;
     this.ocode = code;
 }
コード例 #5
0
ファイル: SBlankNode.cs プロジェクト: agmarchuk/PolarDemo
 public SBlankNode(long code, SGraph graph)
 {
     ocode  = code;
     this.g = graph;
 }
コード例 #6
0
ファイル: SBlankNode.cs プロジェクト: agmarchuk/PolarDemo
 public SBlankNode(string name, SGraph graph)
 {
     this.Name = name;
     this.g    = graph as SGraph;
     ocode     = graph.namespaceMaper.coding.GetCode(name);
 }
コード例 #7
0
 public SUriNode(int code, SGraph sGraph)
 {
     // TODO: Complete member initialization
     this.code  = code;
     this.graph = sGraph;
 }