コード例 #1
0
        private void ParseHexBinary(XsdtType x)
        {
            SoapHexBinary hb = SoapHexBinary.Parse(x.ValuePart);

            x.NetValue = hb.Value;
            x.NetType  = x.NetValue.GetType();
        }
コード例 #2
0
        private void ParseQName(XsdtType x)
        {
            SoapQName u = SoapQName.Parse(x.ValuePart);

            x.NetValue = u;
            x.NetType  = x.NetValue.GetType();
        }
コード例 #3
0
        private void ParseUri(XsdtType x)
        {
            SoapAnyUri u = SoapAnyUri.Parse(x.ValuePart);

            x.NetValue = new Uri(u.Value);
            x.NetType  = x.NetValue.GetType();
        }
コード例 #4
0
        private void ParseNotation(XsdtType x)
        {
            SoapNotation u = SoapNotation.Parse(x.ValuePart);

            x.NetValue = u;
            x.NetType  = x.NetValue.GetType();
        }
コード例 #5
0
        public object Parse(INode n, String ns)
        {
            XsdtType t = new XsdtType();

            t.XsdtNamespacePrefix = ns;
            Parse(n, t);
            return(t.NetValue);
        }
コード例 #6
0
 private void ParseDuration(XsdtType x)
 {
     x.NetValue = SoapDuration.Parse(x.ValuePart);
     x.NetType  = x.NetValue.GetType();
 }
コード例 #7
0
 private void ParseDateTime(XsdtType x)
 {
     x.NetValue = SoapDateTime.Parse(x.ValuePart);
     x.NetType  = x.NetValue.GetType();
 }
コード例 #8
0
 private void ParseYearMonth(XsdtType x)
 {
     x.NetValue = SoapYearMonth.Parse(x.ValuePart).Value;
     x.NetType  = x.NetValue.GetType();
 }
コード例 #9
0
 private void ParseYear(XsdtType x)
 {
     x.NetValue = SoapYear.Parse(x.ValuePart);
     x.NetType  = x.NetValue.GetType();
 }
コード例 #10
0
 private void ParseMonthDay(XsdtType x)
 {
     x.NetValue = SoapMonthDay.Parse(x.ValuePart);
     x.NetType  = x.NetValue.GetType();
 }
コード例 #11
0
 private void ParseObject(XsdtType x)
 {
     x.NetValue = x.ValuePart;
     x.NetType  = typeof(string);
 }
コード例 #12
0
        private void ConvertValueToNet(XsdtType x)
        {
            if (x.NetType == null)
            {
                throw new LinqToRdfException("unable to convert when no .net type was found");
            }

            switch (x.XsdtTypeName)
            {
            case XsdtPrimitiveDataType.XsdtString:
                x.NetValue = x.ValuePart;
                x.NetType  = x.NetValue.GetType();
                break;

            case XsdtPrimitiveDataType.XsdtBoolean:
            case XsdtPrimitiveDataType.XsdtShort:
            case XsdtPrimitiveDataType.XsdtInt:
            case XsdtPrimitiveDataType.XsdtLong:
            case XsdtPrimitiveDataType.XsdtFloat:
            case XsdtPrimitiveDataType.XsdtDouble:
            case XsdtPrimitiveDataType.XsdtDecimal:
                x.NetValue = Convert.ChangeType(x.ValuePart, x.NetType);
                break;

            case XsdtPrimitiveDataType.XsdtDuration:
                ParseDuration(x);
                break;

            case XsdtPrimitiveDataType.XsdtDateTime:
                ParseDateTime(x);
                break;

            case XsdtPrimitiveDataType.XsdtTime:
                ParseTime(x);
                break;

            case XsdtPrimitiveDataType.XsdtDate:
                ParseDate(x);
                break;

            case XsdtPrimitiveDataType.XsdtGYearMonth:
                ParseYearMonth(x);
                break;

            case XsdtPrimitiveDataType.XsdtGYear:
                ParseYear(x);
                break;

            case XsdtPrimitiveDataType.XsdtGMonthDay:
                ParseMonthDay(x);
                break;

            case XsdtPrimitiveDataType.XsdtGDay:
                ParseDay(x);
                break;

            case XsdtPrimitiveDataType.XsdtGMonth:
                ParseMonth(x);
                break;

            case XsdtPrimitiveDataType.XsdtHexBinary:
                ParseHexBinary(x);
                break;

            case XsdtPrimitiveDataType.XsdtBase64Binary:
                ParseBase64Binary(x);
                break;

            case XsdtPrimitiveDataType.XsdtAnyUri:
                ParseUri(x);
                break;

            case XsdtPrimitiveDataType.XsdtQName:
                ParseQName(x);
                break;

            case XsdtPrimitiveDataType.XsdtNotation:
                ParseNotation(x);
                break;

            case XsdtPrimitiveDataType.XsdtUnknown:
                ParseObject(x);
                break;

            default:
                break;
            }
        }
コード例 #13
0
        internal void Parse(INode n, XsdtType x)
        {
            switch (n.NodeType)
            {
            case NodeType.Uri:
                x.NetType      = typeof(Uri);
                x.ValuePart    = n.ToString();
                x.XsdtTypeName = XsdtPrimitiveDataType.XsdtAnyUri;
                ConvertValueToNet(x);
                break;

            case NodeType.Literal:
                ILiteralNode lit = (ILiteralNode)n;

                x.XsdtTypeName = XsdtPrimitiveDataType.XsdtUnknown;
                x.ValuePart    = lit.Value;

                if (lit.DataType != null)
                {
                    if (lit.DataType.ToString().StartsWith(NamespaceMapper.XMLSCHEMA))
                    {
                        x.TypePart = lit.DataType.ToString().Substring(NamespaceMapper.XMLSCHEMA.Length);
                    }
                    else
                    {
                        x.TypePart = "string";
                    }
                }
                else
                {
                    if (TurtleSpecsHelper.IsValidPlainLiteral(lit.Value))
                    {
                        if (TurtleSpecsHelper.IsValidInteger(lit.Value))
                        {
                            x.TypePart = "integer";
                        }
                        else if (TurtleSpecsHelper.IsValidDecimal(lit.Value))
                        {
                            x.TypePart = "decimal";
                        }
                        else if (TurtleSpecsHelper.IsValidDouble(lit.Value))
                        {
                            x.TypePart = "double";
                        }
                        else
                        {
                            x.TypePart = "boolean";
                        }
                    }
                    else
                    {
                        x.TypePart = "string";
                    }
                }

                foreach (int i in Enum.GetValues(typeof(XsdtPrimitiveDataType)))
                {
                    var           result = (XsdtPrimitiveDataType)i;
                    XsdtAttribute attr   = GetXsdtAttrFor(result);
                    if (attr.TypeUri == x.TypePart)
                    {
                        x.XsdtTypeName = result;
                    }
                }

                if (TypeLookup.ContainsKey(x.XsdtTypeName))
                {
                    x.NetType = TypeLookup[x.XsdtTypeName];
                }
                else
                {
                    throw new LinqToRdfException("XsdtTypeConverter does not know how to convert the XML Schema Datatype " + x.TypePart);
                }

                ConvertValueToNet(x);
                break;

            default:
                throw new LinqToRdfException("XsdtTypeConverter can only convert URI and Literal Nodes");
            }
        }