Ejemplo n.º 1
0
        internal SchemaMetadata(Type type)
        {
            if (!type.IsSchema())
            {
                throw new ArgumentException("Type is not a SchemaBase derived Type instance.", "type");
            }
            _type = type;

            // ?? use SchemaMetadata.For(type).BodyXPath
            BodyXPath = Attribute.GetCustomAttributes(type, typeof(BodyXPathAttribute))
                        .Cast <BodyXPathAttribute>()
                        .SingleOrDefault()
                        .IfNotNull(xpa => xpa.BodyXPath);

            var sa = Attribute.GetCustomAttributes(type, typeof(SchemaAttribute))
                     .Cast <SchemaAttribute>()
                     .SingleOrDefault();

            if (sa == null)
            {
                var schema = (SchemaBase)Activator.CreateInstance(type);
                TargetNamespace = schema.Schema.TargetNamespace;
            }
            else
            {
                // ?? use SchemaMetadata.For(type).SchemaName
                MessageType = PartTypeMetadata.ComposeMessageType(sa.TargetNamespace, sa.RootElement);
                // ?? use SchemaMetadata.For(type).RootElementName
                RootElementName = sa.RootElement;
                // ?? use SchemaMetadata.For(type).TargetNamespace
                TargetNamespace = sa.TargetNamespace;
            }
        }
Ejemplo n.º 2
0
        public static string GetMessageType(this System.ServiceModel.Channels.Message message)
        {
            var body = new XmlDocument();

            body.Load(message.GetReaderAtBodyContents());
            var root = body.DocumentElement;

            return(root.IfNotNull(r => PartTypeMetadata.ComposeMessageType(r.NamespaceURI, r.LocalName)));
        }
Ejemplo n.º 3
0
        public static string GetMessageType(this Message message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            var body = new XmlDocument();

            body.Load(message.GetReaderAtBodyContents());
            var root = body.DocumentElement;

            return(root.IfNotNull(r => PartTypeMetadata.ComposeMessageType(r.NamespaceURI, r.LocalName)));
        }