예제 #1
0
        private static bool TryGetDefinedPrefix(IXmlNode node, string namespaceUri, out string prefix)
        {
            var definedPrefix = node.LookupPrefix(namespaceUri);

            return(string.IsNullOrEmpty(definedPrefix)
                                ? Try.Failure(out prefix)
                                : Try.Success(out prefix, definedPrefix));
        }
예제 #2
0
        private bool TryGetXmlMetadata(Type clrType, out XmlMetadata metadata)
        {
            var kind = XmlTypeSerializer.For(clrType).Kind;

            return(kind == XmlTypeKind.Complex && clrType.GetTypeInfo().IsInterface
                                ? Try.Success(out metadata, GetXmlMetadata(clrType))
                                : Try.Failure(out metadata));
        }
예제 #3
0
        private bool IsMatch()
        {
            IXmlKnownType knownType;

            return(knownTypes.TryGet(this, out knownType)
                                ? Try.Success(out type, knownType.ClrType)
                                : Try.Failure(out type));
        }
예제 #4
0
 private static bool ParseName(Tokenizer source, out string name)
 {
     if (source.Token != Token.Name)
     {
         return(Try.Failure(out name));
     }
     name = source.Text;
     source.Consume();
     return(true);
 }
예제 #5
0
 private bool TryGetPreferredPrefix(IXmlNode node, string namespaceUri, out string prefix)
 {
     prefix = this.LookupPrefix(namespaceUri);
     if (string.IsNullOrEmpty(prefix))
     {
         return(Try.Failure(out prefix));                // No preferred prefix
     }
     namespaceUri = node.LookupNamespaceUri(prefix);
     return(string.IsNullOrEmpty(namespaceUri)
                         ? true                      // Can use preferred prefix
                         : Try.Failure(out prefix)); // Preferred prefix already in use
 }
예제 #6
0
        private bool TryGetAccessor(string key, PropertyDescriptor property, bool requireVolatile, out XmlAccessor accessor)
        {
            accessor = property.HasAccessor()
                                ? property.GetAccessor()
                                : CreateAccessor(key, property);

            if (accessor.IsIgnored)
            {
                return(Try.Failure(out accessor));
            }
            if (requireVolatile && !accessor.IsVolatile)
            {
                return(Try.Failure(out accessor));
            }
            return(true);
        }
예제 #7
0
        private static bool ParseValue(Tokenizer source, out XPathExpression value)
        {
            var start = source.Index;

            var parsed =
                Consume(source, Token.StringLiteral) ||
                (Consume(source, Token.VariableStart) && ParseQualifiedName(source, null));

            if (!parsed)
            {
                return(Try.Failure(out value));
            }

            var xpath = source.GetConsumedText(start);

            value = XPathExpression.Compile(xpath);
            return(true);
        }
        public bool TryGet(XmlName xsiType, out IXmlIncludedType includedType)
        {
            if (xsiType == XmlName.Empty || xsiType == this.XsiType)
            {
                return(Try.Success(out includedType, this));
            }

            if (!includedTypes.TryGet(xsiType, out includedType))
            {
                return(false);
            }

            if (!ClrType.IsAssignableFrom(includedType.ClrType))
            {
                return(Try.Failure(out includedType));
            }

            return(true);
        }
예제 #9
0
 public bool TryGet(Type clrType, out IXmlKnownType knownType)
 {
     return(IsMatch(clrType)
                                 ? Try.Success(out knownType, this)
                                 : Try.Failure(out knownType));
 }
예제 #10
0
 public bool TryGet(IXmlIdentity xmlName, out IXmlKnownType knownType)
 {
     return(IsMatch(xmlName)
                                 ? Try.Success(out knownType, this)
                                 : Try.Failure(out knownType));
 }
예제 #11
0
 public bool TryGet(Type clrType, out IXmlIncludedType includedType)
 {
     return(clrType == this.clrType
                         ? Try.Success(out includedType, this)
                         : Try.Failure(out includedType));
 }
예제 #12
0
 public bool TryGet(XmlName xsiType, out IXmlIncludedType includedType)
 {
     return(xsiType == XmlName.Empty || xsiType == this.XsiType
                         ? Try.Success(out includedType, this)
                         : Try.Failure(out includedType));
 }