コード例 #1
0
        public void TransformBatchContentWithEnvironmentTagAndPartition()
        {
            var setup = Given(
                input => input
                .Message(EnvelopeFactory.Create <Envelope>().AsStream())
                .Message(MessageBodyFactory.Create <Batch.Content>(MessageBody.Samples.LoadString("Message.BatchContentWithEnvironmentTagAndPartition.xml")).AsStream()))
                        .Transform
                        .OutputsXml(
                output => output
                .ConformingTo <Envelope>()
                .ConformingTo <Batch.Release>()
                .WithStrictConformanceLevel());
            var result = setup.Validate();

            result.NamespaceManager.AddNamespace("env", SchemaMetadata.For <Envelope>().TargetNamespace);
            result.NamespaceManager.AddNamespace("tns", SchemaMetadata.For <Batch.Release>().TargetNamespace);

            result.SelectSingleNode("/*") !.LocalName.Should().Be("Envelope");
            result.Select("/env:Envelope/tns:ReleaseBatch").Cast <object>().Should().HaveCount(3);
            result.Select("/env:Envelope/*").Cast <object>().Should().HaveCount(3);

            var part = result.SelectSingleNode("/env:Envelope/tns:ReleaseBatch[3]");

            part !.SelectSingleNode("tns:EnvelopeSpecName") !.Value.Should().Be(SchemaMetadata.For <Batch.Release>().DocumentSpec.DocSpecName);
            part !.SelectSingleNode("tns:EnvironmentTag") !.Value.Should().Be("graffiti");
            part !.SelectSingleNode("tns:Partition") !.Value.Should().Be("A");
        }
コード例 #2
0
        public static AddCommand Create <TEntity>(IRedisearchSerializer serializer, TEntity entity, double score, string language)
            where TEntity : RedisearchSerializable <TEntity>, new()
        {
            var schemaMetadata = SchemaMetadata <TEntity> .GetSchemaMetadata();

            var indexName = schemaMetadata.IndexName;
            var entityId  = string.Concat(schemaMetadata.DocumentIdPrefix, schemaMetadata.PrimaryKey.GetPrimaryKeyFromEntity(entity));

            if (string.IsNullOrEmpty(language))
            {
                language = schemaMetadata.Language;
            }

            var parameters = new List <object>
            {
                indexName,
                entityId,
                score,
                RedisearchIndexCache.GetBoxedLiteral("LANGUAGE"),
                RedisearchIndexCache.GetBoxedLiteral(language),
                RedisearchIndexCache.GetBoxedLiteral("FIELDS")
            };

            foreach (var fieldPairs in serializer.Serialize(entity))
            {
                parameters.Add(fieldPairs.Key);
                parameters.Add(fieldPairs.Value);
            }

            return(new AddCommand(parameters));
        }
コード例 #3
0
        public void ReplacesMessageOriginalDataStreamWithTransformResult()
        {
            PipelineContextMock
            .Setup(m => m.GetDocumentSpecByType("http://schemas.microsoft.com/Edi/EdifactServiceSchema#UNB"))
            .Returns(SchemaMetadata.For <EdifactServiceSchema.UNB>().DocumentSpec);

            var sut = new XsltRunner {
                Encoding = Encoding.UTF8,
                MapType  = typeof(IdentityTransform)
            };

            using (var dataStream = new MemoryStream(Encoding.UTF8.GetBytes("<UNB xmlns='http://schemas.microsoft.com/Edi/EdifactServiceSchema'></UNB>")))
                using (var transformedStream = dataStream.Transform().Apply(sut.MapType))
                    using (var transformStreamMockInjectionScope = new TransformStreamMockInjectionScope())
                    {
                        MessageMock.Object.BodyPart.Data = dataStream;

                        transformStreamMockInjectionScope.Mock
                        .Setup(ts => ts.ExtendWith(MessageMock.Object.Context))
                        .Returns(transformStreamMockInjectionScope.Mock.Object);
                        transformStreamMockInjectionScope.Mock
                        .Setup(ts => ts.Apply(sut.MapType, sut.Encoding))
                        .Returns(transformedStream)
                        .Verifiable();

                        sut.Execute(PipelineContextMock.Object, MessageMock.Object);

                        transformStreamMockInjectionScope.Mock.VerifyAll();

                        MessageMock.Object.BodyPart.Data.Should().BeOfType <MarkableForwardOnlyEventingReadStream>();
                        Reflector.GetField((MarkableForwardOnlyEventingReadStream)MessageMock.Object.BodyPart.Data, "m_data").Should().BeSameAs(transformedStream);
                    }
        }
        public void GetAnnotationsByName()
        {
            var annotations = SchemaMetadata.For <RootedSchema>().GetAnnotations();

            annotations.Should().NotBeEmpty();
            annotations.SingleOrDefault(e => e.Name.LocalName == "Properties").Should().NotBeNull();
        }
コード例 #5
0
        internal TransformMetaData FindFirstMapMatch(string message)
        {
            string[]          mapsArray = _mapName.Split(new char[] { '|' }, StringSplitOptions.None);
            TransformMetaData mapMatch  = null;

            for (int i = 0; i < mapsArray.Length; i++)
            {
                try
                {
                    Type mapType = Type.GetType(mapsArray[i], true);

                    TransformMetaData map = TransformMetaData.For(mapType);

                    SchemaMetadata sourceSchema = map.SourceSchemas[0];

                    if (sourceSchema.SchemaName == message)
                    {
                        mapMatch = map;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(string.Format("Error while trying to load MapType specification: {0}", mapsArray[i]), ex);
                }
            }

            return(mapMatch);
        }
コード例 #6
0
ファイル: TransformService.cs プロジェクト: radtek/DevOps
        private static Stream TransformStream(Stream stream, string mapName, bool validate, ref string messageType, ref string targetDocumentSpecName)
        {
            Type type = Type.GetType(mapName);

            if (null == type)
            {
                throw new Exception("Invalid MapType" + mapName);
            }

            TransformMetaData transformMetaData    = TransformMetaData.For(type);
            SchemaMetadata    sourceSchemaMetadata = transformMetaData.SourceSchemas[0];
            string            schemaName           = sourceSchemaMetadata.SchemaName;
            SchemaMetadata    targetSchemaMetadata = transformMetaData.TargetSchemas[0];

            if (validate && string.Compare(messageType, schemaName, false, CultureInfo.CurrentCulture) != 0)
            {
                throw new Exception("Source Document Mismatch. MessageType: " + messageType + " Schema Name: " + schemaName);
            }

            messageType            = targetSchemaMetadata.SchemaName;
            targetDocumentSpecName = targetSchemaMetadata.SchemaBase.GetType().AssemblyQualifiedName;

            XmlReader reader = XmlReader.Create(stream);

            XPathDocument input     = new XPathDocument(reader);
            ITransform    transform = transformMetaData.Transform;
            Stream        outStream = new MemoryStream();

            transform.Transform(input, transformMetaData.ArgumentList, outStream, new XmlUrlResolver());
            outStream.Flush();
            outStream.Seek(0L, SeekOrigin.Begin);
            return(outStream);
        }
コード例 #7
0
        public void ConjunctionIsDistributedOverDisjunctionOfFiltersAndDistributionIsCommutative()
        {
            const string senderNameToken = "BizTalkFactory.Batching";
            const int    retryCountToken = 3;
            var          filter          = new Filter(
                () => BtsProperties.MessageType == SchemaMetadata.For <Any>().MessageType &&
                (BizTalkFactoryProperties.MapTypeName == senderNameToken || BtsProperties.ActualRetryCount > retryCountToken)
                );

            filter.ToString().Should().Be(
                string.Format(
                    "<Filter>"
                    + "<Group><Statement Property=\"{0}\" Operator=\"{1}\" Value=\"{2}\" /><Statement Property=\"{3}\" Operator=\"{4}\" Value=\"{5}\" /></Group>"
                    + "<Group><Statement Property=\"{0}\" Operator=\"{1}\" Value=\"{2}\" /><Statement Property=\"{6}\" Operator=\"{7}\" Value=\"{8}\" /></Group>"
                    + "</Filter>",
                    BtsProperties.MessageType.Type.FullName,
                    (int)FilterOperator.Equals,
                    SchemaMetadata.For <Any>().MessageType,
                    BizTalkFactoryProperties.MapTypeName.Type.FullName,
                    (int)FilterOperator.Equals,
                    senderNameToken,
                    BtsProperties.ActualRetryCount.Type.FullName,
                    (int)FilterOperator.GreaterThan,
                    retryCountToken));
        }
     public ReleaseSendPort()
     {
         Name         = SendPortName.Towards("Batch").About("Release").FormattedAs.Xml;
         State        = ServiceState.Started;
         SendPipeline = new SendPipeline <XmlTransmit>(
             pipeline => {
             pipeline.Encoder <MicroPipelineComponent>(
                 pc => {
                 pc.Components = new IMicroComponent[] {
                     new ContextBuilder {
                         BuilderType = typeof(ReleaseProcessResolver)
                     },
                     new ActivityTracker(),
                     new XsltRunner {
                         MapType = typeof(ReleaseToQueueControlledRelease)
                     }
                 };
             });
         });
         Transport.Adapter = new WcfSqlAdapter.Outbound(
             a => {
             a.Address = new() {
                 InitialCatalog = "BizTalkFactoryTransientStateDb",
                 Server         = Platform.Settings.ProcessingDatabaseServer,
                 InstanceName   = Platform.Settings.ProcessingDatabaseInstance
             };
             a.IsolationLevel = IsolationLevel.ReadCommitted;
             a.StaticAction   = "TypedProcedure/dbo/usp_batch_QueueControlledRelease";
         });
         Transport.Host        = Platform.Settings.HostResolutionPolicy;
         Transport.RetryPolicy = RetryPolicy.ShortRunning;
         Filter = new(() => BtsProperties.MessageType == SchemaMetadata.For <Batch.Release>().MessageType);
     }
 }
コード例 #9
0
		public override IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage message)
		{
			var markableForwardOnlyEventingReadStream = message.BodyPart.WrapOriginalDataStream(
				originalStream => originalStream.AsMarkable(),
				pipelineContext.ResourceTracker);

			var batchDescriptor = markableForwardOnlyEventingReadStream.ProbeBatchContent().BatchDescriptor;
			if (batchDescriptor == null || batchDescriptor.EnvelopeSpecName.IsNullOrEmpty())
				throw new InvalidOperationException($"No EnvelopeSpecName has been found in {nameof(Batch.Content)} message and no envelope can be applied.");
			var envelopeSchema = Type.GetType(batchDescriptor.EnvelopeSpecName, true);
			message.Promote(BatchProperties.EnvelopePartition, batchDescriptor.Partition);

			markableForwardOnlyEventingReadStream.StopMarking();

			if (_logger.IsInfoEnabled) _logger.DebugFormat("Applying '{0}' envelope to message.", envelopeSchema.AssemblyQualifiedName);
			var envelope = EnvelopeFactory.Create(envelopeSchema);
			// can't use .AsStream() that relies on StringStream, which is Unicode/UTF-16, over envelope.OuterXml as CompositeXmlStream assumes UTF-8
			var envelopeStream = new MemoryStream(Encoding.UTF8.GetBytes(envelope.OuterXml));
			message.BodyPart.WrapOriginalDataStream(
				originalStream => new CompositeXmlStream(new[] { envelopeStream, originalStream }),
				pipelineContext.ResourceTracker);

			SchemaMetadata.For(envelopeSchema).Annotations.Find<EnvelopeMapAnnotation>().EnvelopeMapType.IfNotNull(m => MapType = m);
			return base.Execute(pipelineContext, message);
		}
        public void SetupResponseExpectationAgainstSpecificMessageType()
        {
            _soapStub.As <ISolicitResponse>()
            .Setup(s => s.Request(SchemaMetadata.For <btf2_services_header>().DocumentSpec))
            .Returns(new StringStream("<response />"));

            var client = SoapClient <IMessageService> .For(_soapStubHost.Endpoint);

            try
            {
                var response = client.Invoke(
                    System.ServiceModel.Channels.Message.CreateMessage(
                        MessageVersion.Soap11,
                        "urn:services.stateless.be:unit:work:request",
                        XmlReader.Create(new StringReader(MessageBodyFactory.Create <btf2_services_header>().OuterXml))));

                var reader = response !.GetReaderAtBodyContents();
                reader.MoveToContent();
                var outerXml = reader.ReadOuterXml();
                outerXml.Should().Be("<response />");

                client.Close();
            }
            catch (Exception)
            {
                client.Abort();
                throw;
            }
        }
コード例 #11
0
        public void XsltFromContextHasPrecedenceOverConfiguredOne()
        {
            PipelineContextMock
            .Setup(m => m.GetDocumentSpecByType("http://schemas.microsoft.com/Edi/EdifactServiceSchema#UNB"))
            .Returns(SchemaMetadata.For <EdifactServiceSchema.UNB>().DocumentSpec);

            var sut = new XsltRunner {
                Encoding = Encoding.UTF8,
                MapType  = typeof(TransformBase)
            };

            using (var dataStream = new MemoryStream(Encoding.UTF8.GetBytes("<UNB xmlns='http://schemas.microsoft.com/Edi/EdifactServiceSchema'></UNB>")))
                using (var transformedStream = dataStream.Transform().Apply(typeof(IdentityTransform)))
                    using (var transformStreamMockInjectionScope = new TransformStreamMockInjectionScope())
                    {
                        MessageMock.Object.BodyPart.Data = dataStream;
                        MessageMock
                        .Setup(m => m.GetProperty(BizTalkFactoryProperties.MapTypeName))
                        .Returns(typeof(IdentityTransform).AssemblyQualifiedName);

                        var transformStreamMock = transformStreamMockInjectionScope.Mock;
                        transformStreamMock
                        .Setup(ts => ts.ExtendWith(MessageMock.Object.Context))
                        .Returns(transformStreamMock.Object);
                        transformStreamMock
                        .Setup(ts => ts.Apply(typeof(IdentityTransform), sut.Encoding))
                        .Returns(transformedStream)
                        .Verifiable();

                        sut.Execute(PipelineContextMock.Object, MessageMock.Object);

                        transformStreamMock.Verify(ts => ts.Apply(sut.MapType, sut.Encoding), Times.Never());
                        transformStreamMock.VerifyAll();
                    }
        }
コード例 #12
0
        public void BatchContentIsTransformedToSpecificEnvelope()
        {
            string expectedEnvelopeContent;
            var    envelopeStream = new StringStream(EnvelopeFactory.Create <Envelope>().OuterXml);
            var    batchContentStream = MessageBodyFactory.Create <Batch.Content>(MessageBody.Samples.LoadString("Message.BatchContent.xml")).AsStream();
            var    transformedStream = new[] { envelopeStream, batchContentStream }.Transform().Apply(typeof(BatchContentToAnyEnvelope), new UTF8Encoding(false));

            using (var expectedReader = XmlReader.Create(transformedStream, new XmlReaderSettings {
                CloseInput = true
            }))
            {
                expectedReader.Read();
                expectedEnvelopeContent = expectedReader.ReadOuterXml();
            }

            using (var stream = MessageBody.Samples.Load("Message.BatchContent.xml"))
            {
                MessageMock.Object.BodyPart.Data = stream;
                PipelineContextMock
                .Setup(pc => pc.GetDocumentSpecByType(SchemaMetadata.For <Envelope>().MessageType))
                .Returns(SchemaMetadata.For <Envelope>().DocumentSpec);

                var sut = new EnvelopeBuilder();
                sut.Execute(PipelineContextMock.Object, MessageMock.Object);
                using (var actualReader = XmlReader.Create(MessageMock.Object.BodyPart.Data, new XmlReaderSettings {
                    CloseInput = true, IgnoreWhitespace = true
                }))
                {
                    actualReader.Read();
                    var actualEnvelopeContent = actualReader.ReadOuterXml();
                    actualEnvelopeContent.Should().Be(expectedEnvelopeContent);
                }
            }
        }
コード例 #13
0
 public void Invalid_index_name_should_throw()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         SchemaMetadata <InvalidIndexNameTest> .GetSchemaMetadata();
     });
 }
コード例 #14
0
        public void MessageIsTransformedToEnvelopeViaEnvelopeSpecNameAnnotation()
        {
            using (var stream = MessageBody.Samples.Load("Message.BatchContentWithEnvelopeSpecName.xml"))
                using (var transformedStream = new StringStream("<root xmlns='urn:ns'></root>"))
                    using (var transformStreamMockInjectionScope = new TransformStreamMockInjectionScope())
                    {
                        MessageMock.Object.BodyPart.Data = stream;
                        PipelineContextMock
                        .Setup(pc => pc.GetDocumentSpecByType("urn:ns#root"))
                        .Returns(SchemaMetadata.For <Any>().DocumentSpec);

                        transformStreamMockInjectionScope.Mock
                        .Setup(ts => ts.ExtendWith(MessageMock.Object.Context))
                        .Returns(transformStreamMockInjectionScope.Mock.Object);
                        transformStreamMockInjectionScope.Mock
                        .Setup(ts => ts.Apply(typeof(IdentityTransform), new UTF8Encoding(false)))
                        .Returns(transformedStream)
                        .Verifiable();

                        var sut = new EnvelopeBuilder();
                        sut.Execute(PipelineContextMock.Object, MessageMock.Object);

                        transformStreamMockInjectionScope.Mock.VerifyAll();
                    }
        }
        public void BuildPropertyExtractorCollectionGivesPrecedenceToSchemaExtractorsOverPipelineExtractors()
        {
            // has to be called before ContextPropertyAnnotationMockInjectionScope overrides SchemaMetadata.For<>() factory method
            var schemaMetadata = SchemaMetadata.For <Any>();

            using (var inputStream = new MemoryStream(Encoding.UTF8.GetBytes("<root xmlns='urn:ns'></root>")))
                using (var contextPropertyAnnotationMockInjectionScope = new PropertyExtractorAnnotationMockInjectionScope())
                {
                    contextPropertyAnnotationMockInjectionScope.Extractors = new(
                        new XPathExtractor(BizTalkFactoryProperties.OutboundTransportLocation.QName, "/letter/*/to", ExtractionMode.Demote),
                        new XPathExtractor(BtsProperties.Operation.QName, "/letter/*/salutations"));

                    PipelineContextMock.Setup(pc => pc.GetDocumentSpecByType("urn:ns#root")).Returns(schemaMetadata.DocumentSpec);
                    MessageMock.Object.BodyPart.Data = inputStream;
                    MessageMock.Setup(m => m.GetProperty(BtsProperties.MessageType)).Returns("urn:ns#root");

                    var sut = new ContextPropertyExtractor {
                        Extractors = new[] {
                            new XPathExtractor(BizTalkFactoryProperties.OutboundTransportLocation.QName, "/letter/*/from", ExtractionMode.Promote),
                            new XPathExtractor(BtsProperties.OutboundTransportLocation.QName, "/letter/*/paragraph")
                        }
                    };
                    var extractors = sut.BuildPropertyExtractorCollection(PipelineContextMock.Object, MessageMock.Object);

                    extractors.Should().BeEquivalentTo(
                        new[] {
                        new XPathExtractor(BizTalkFactoryProperties.OutboundTransportLocation.QName, "/letter/*/to", ExtractionMode.Demote),
                        new XPathExtractor(BtsProperties.Operation.QName, "/letter/*/salutations"),
                        new XPathExtractor(BtsProperties.OutboundTransportLocation.QName, "/letter/*/paragraph")
                    });
                }
        }
コード例 #16
0
        protected void DropCreatedIndex <TEntity>()
            where TEntity : RedisearchSerializable <TEntity>, new()
        {
            var indexName = SchemaMetadata <TEntity>
                            .GetSchemaMetadata().IndexName;

            Assert.That((string)Connection.GetDatabase().Execute("FT.DROP", indexName), Is.EqualTo("OK"));
        }
コード例 #17
0
                public void Default_id_should_be_overridable()
                {
                    var schemaMetadata = SchemaMetadata <OverriddenIdPropertyTest> .GetSchemaMetadata();

                    Assert.That(schemaMetadata.PrimaryKey.EntityClrType, Is.EqualTo(typeof(OverriddenIdPropertyTest)));
                    Assert.That(schemaMetadata.PrimaryKey.PropertyName, Is.EqualTo("InterestingId"));
                    Assert.That(schemaMetadata.PrimaryKey.PropertyClrType, Is.EqualTo(typeof(DateTime)));
                }
コード例 #18
0
        /// <summary>
        /// Merge the user configuration with the default metadatas from the servers.
        /// </summary>
        /// <param name="schemaMetadata">Metadatas to generate queries for.</param>
        /// <param name="dbSettings">User configuration.</param>
        /// <param name="variables">The compiled cascade variables</param>
        private static void MergeFkModifierSchema(SchemaMetadata schemaMetadata, DbSettings dbSettings, HashSet <SchemaVar> variables)
        {
            foreach (var dbSettingsTable in dbSettings.Tables)
            {
                var table = schemaMetadata.FirstOrDefault(t => t.Name.Equals(dbSettingsTable.Name, StringComparison.CurrentCultureIgnoreCase));
                if (table == null)
                {
                    continue;
                }

                //On affecte les changements de la configuration

                //On supprime les clefs
                foreach (var colConfig in dbSettingsTable.ForeignKeys.ForeignKeyRemove.Columns)
                {
                    for (var j = 0; j < table.ForeignKeys.Count; j++)
                    {
                        var fk = table.ForeignKeys[j];

                        for (var i = 0; i < fk.Columns.Count; i++)
                        {
                            if (!fk.Columns[i].NameFrom.Equals(colConfig.Name, StringComparison.OrdinalIgnoreCase))
                            {
                                continue;
                            }
                            fk.Columns.RemoveAt(i);
                            i--;

                            if (fk.Columns.Count != 0)
                            {
                                continue;
                            }
                            table.ForeignKeys.RemoveAt(j);
                            j--;
                        }
                    }
                }

                //On ajoute les clefs
                foreach (var fkModifier in dbSettingsTable.ForeignKeys.ForeignKeyAdd)
                {
                    var destinationVar = variables.First(v => v.Id == fkModifier.DestinationSchema);

                    var newFk = new ForeignKey
                    {
                        ServerIdTo = destinationVar.Server,
                        DatabaseTo = destinationVar.Database,
                        SchemaTo   = destinationVar.Schema,
                        TableTo    = fkModifier.DestinationTable,
                        Columns    = (from fk in fkModifier.Columns select new ForeignKeyColumn {
                            NameFrom = fk.Source, NameTo = fk.Destination
                        }).ToList()
                    };

                    table.ForeignKeys.Add(newFk);
                }
            }
        }
コード例 #19
0
                public void GetPrimaryKeyFromProperty_should_throw_when_the_property_type_is_different()
                {
                    var schemaMetadata = SchemaMetadata <GetPrimaryKeyFromEntityTests> .GetSchemaMetadata();

                    Assert.Throws <ArgumentException>(() =>
                    {
                        schemaMetadata.PrimaryKey.GetPrimaryKeyFromProperty(Guid.Empty);
                    });
                }
コード例 #20
0
            public void Serialized_properties_should_include_all_get_set_properties_by_default()
            {
                var schemaMetadata = SchemaMetadata <SerializedPropertiesTest> .GetSchemaMetadata();

                var serializedProperties = schemaMetadata.Properties.Where(p => !p.IsIgnored).Select(p => p.PropertyName);

                Assert.That(serializedProperties,
                            Is.EquivalentTo(new[] { "Id", "Property1" }));
            }
 public BankSendPort()
 {
     Name                  = SendPortName.Towards(Party.Bank).About(Subject.CreditNote).FormattedAs.Edi;
     SendPipeline          = new SendPipeline <XmlTransmit>();
     Transport.Adapter     = new FileAdapter.Outbound(a => { a.DestinationFolder = @"c:\file\drops"; });
     Transport.Host        = Host.SENDING_HOST;
     Transport.RetryPolicy = RetryPolicy.LongRunning;
     Filter                = new(() => BtsProperties.MessageType == SchemaMetadata.For <Any>().MessageType);
 }
コード例 #22
0
            /// <summary>
            /// Provides the <see cref="XmlSchema"/> to the <paramref name="schemaSet"/> and the <see cref="XmlSchemaType"/>
            /// that controls the serialization of the type.
            /// </summary>
            /// <param name="schemaSet">
            /// The <see cref="XmlSchemaSet"/> that will be populated with the <see cref="XmlSchema"/>.
            /// </param>
            /// <returns>
            /// The <see cref="XmlSchemaType"/> that defines its data type.
            /// </returns>
            /// <remarks>
            /// This is a scaffolding method that is meant to be called from within the derived classes' static method
            /// identified by the <see cref="XmlSchemaProviderAttribute"/>.
            /// </remarks>
            XmlSchemaType IXmlSchemaProvider.ProvideSchema(XmlSchemaSet schemaSet)
            {
                schemaSet.Merge(((IXmlSchemaProvider)this).Schema);
                schemaSet.Compile();
                var schemaMetadata = new SchemaMetadata <TSchemaBase>();
                var element        = (XmlSchemaElement)schemaSet.GlobalElements[new XmlQualifiedName(schemaMetadata.RootElementName, schemaMetadata.TargetNamespace)];

                return(element.ElementSchemaType);
            }
コード例 #23
0
 private SchemaMetadata[] _resolveSchemas(string[] schemaRefs)
 {
     SchemaMetadata[] schemaMetadataArray = new SchemaMetadata[schemaRefs.Length];
     for (int index = 0; index < schemaMetadataArray.Length; ++index)
     {
         schemaMetadataArray[index] = this._resolveSchema(schemaRefs[index]);
     }
     return(schemaMetadataArray);
 }
 public void BatchDescriptor()
 {
     using (var stream = MessageBody.Samples.Load("Message.BatchContent.xml").AsMarkable())
     {
         var batchDescriptor = stream.ProbeBatchContent().BatchDescriptor;
         batchDescriptor.EnvelopeSpecName.Should().Be(SchemaMetadata.For <Envelope>().DocumentSpec.DocSpecStrongName);
         batchDescriptor.Partition.Should().BeNull();
     }
 }
コード例 #25
0
        public void MessageTypeBasedFilter()
        {
            var filter = new Filter(() => BtsProperties.MessageType == SchemaMetadata.For <Any>().MessageType);

            filter.ToString().Should().Be(
                "<Filter><Group>"
                + $"<Statement Property=\"{BtsProperties.MessageType.Type.FullName}\" Operator=\"{(int) FilterOperator.Equals}\" Value=\"{SchemaMetadata.For<Any>().MessageType}\" />"
                + "</Group></Filter>");
        }
コード例 #26
0
 public static XmlDocument CreateMessage(Type schema)
 {
     if (!schema.IsSchema())
     {
         throw new ArgumentException(
                   $"{schema.FullName} does not derive from {typeof(SchemaBase).FullName}.",
                   nameof(schema));
     }
     return(CreateMessage(SchemaMetadata.For(schema).DocumentSpec));
 }
コード例 #27
0
        /// <summary>
        /// Returns the <see cref="ISchemaMetadata"/> associated to the XML schema of messages of a given <see
        /// cref="DocumentSpec"/> type.
        /// </summary>
        /// <param name="pipelineContext">
        /// The pipeline context from which the <see cref="DocumentSpec"/> can be queried.
        /// </param>
        /// <param name="docType">
        /// The <see cref="DocumentSpec"/> type of the messages for which the <see cref="ISchemaMetadata"/> are to be returned.
        /// </param>
        /// <returns>
        /// The <see cref="ISchemaMetadata"/> associated to the XML Schema.
        /// </returns>
        public static ISchemaMetadata GetSchemaMetadataByType(this IPipelineContext pipelineContext, string docType)
        {
            if (pipelineContext == null)
            {
                throw new ArgumentNullException(nameof(pipelineContext));
            }
            var docSpec    = pipelineContext.GetDocumentSpecByType(docType);
            var schemaType = Type.GetType(docSpec.DocSpecStrongName, true);

            return(SchemaMetadata.For(schemaType));
        }
コード例 #28
0
                public void GetPrimaryKeyFromEntity_should_return_the_id_value_as_a_RedisValue()
                {
                    var schemaMetadata = SchemaMetadata <GetPrimaryKeyFromEntityTests> .GetSchemaMetadata();

                    var entity = new GetPrimaryKeyFromEntityTests
                    {
                        Id = 42
                    };

                    Assert.That(schemaMetadata.PrimaryKey.GetPrimaryKeyFromEntity(entity), Is.EqualTo((RedisValue)42));
                }
コード例 #29
0
        public void NAryConjunction()
        {
            var filter = new Filter(
                () => BtsProperties.ActualRetryCount > 3 &&
                BtsProperties.MessageType == SchemaMetadata.For <Any>().MessageType &&
                BtsProperties.SendPortName == "Dummy port name" &&
                BtsProperties.IsRequestResponse != true
                );

            Invoking(() => filter.ToString()).Should().NotThrow();
        }
コード例 #30
0
        public void InvokeSucceeds()
        {
            _soapStub.As <ISolicitResponse>()
            .Setup(s => s.Request(SchemaMetadata.For <btf2_services_header>().DocumentSpec))
            .Returns(new StringStream("<response />"));

            using (var response = SoapClient.Invoke(_soapStubHost.Endpoint, new StringStream(MessageBodyFactory.Create <btf2_services_header>().OuterXml)))
            {
                new StreamReader(response).ReadToEnd().Should().Be("<response />");
            }
        }