Esempio 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;
            }
        }
Esempio 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)));
        }
Esempio 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)));
        }