当前位置: 首页>>代码示例>>C#>>正文


C# Reflector.CreateCommand方法代码示例

本文整理汇总了C#中Reflector.CreateCommand方法的典型用法代码示例。如果您正苦于以下问题:C# Reflector.CreateCommand方法的具体用法?C# Reflector.CreateCommand怎么用?C# Reflector.CreateCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reflector的用法示例。


在下文中一共展示了Reflector.CreateCommand方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateCommand_should_return_expected_result_when_sort_is_provided

        public void CreateCommand_should_return_expected_result_when_sort_is_provided(
            [Values("{ a : 1 }", "{ b : -1 }")]
            string json)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.Sort = BsonDocument.Parse(json);
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', sort : {json} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:13,代码来源:FindCommandOperationTests.cs

示例2: CreateCommand_should_return_expected_result_when_skip_is_provided

        public void CreateCommand_should_return_expected_result_when_skip_is_provided(
            [Values(0, 1)]
            int value)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.Skip = value;
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', skip : {value} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:13,代码来源:FindCommandOperationTests.cs

示例3: CreateCommand_should_return_expected_result_when_snapshot_is_provided

        public void CreateCommand_should_return_expected_result_when_snapshot_is_provided(
            [Values(false, true)]
            bool value)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.Snapshot = value;
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', snapshot : {(value ? "true" : "false")} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:13,代码来源:FindCommandOperationTests.cs

示例4: CreateCommand_should_return_expected_result_when_maxTime_is_provided

        public void CreateCommand_should_return_expected_result_when_maxTime_is_provided(
            [Values(1, 2)]
            int value)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.MaxTime = TimeSpan.FromSeconds(value);
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', maxTimeMS : {value * 1000} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:13,代码来源:FindCommandOperationTests.cs

示例5: CreateCommand_should_return_expected_result_when_readPreference_is_provided

        public void CreateCommand_should_return_expected_result_when_readPreference_is_provided(
            [Values(ReadPreferenceMode.PrimaryPreferred, ReadPreferenceMode.Secondary)]
            ReadPreferenceMode value)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            var readPreference = new ReadPreference(value);
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription(type: ServerType.ShardRouter);

            var result = reflector.CreateCommand(serverDescription, readPreference);

            var mode = value.ToString();
            var camelCaseMode = char.ToLower(mode[0]) + mode.Substring(1);
            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', readPreference : {{ mode : '{camelCaseMode}' }} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:15,代码来源:FindCommandOperationTests.cs

示例6: CreateCommand_should_return_expected_result

        public void CreateCommand_should_return_expected_result()
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}' }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:10,代码来源:FindCommandOperationTests.cs

示例7: CreateCommand_should_return_expected_result_when_cursor_is_tailableAwait

        public void CreateCommand_should_return_expected_result_when_cursor_is_tailableAwait(CursorType value, string awaitJson)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.CursorType = value;
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription, null);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', tailable : true{awaitJson} }}");
        }
开发者ID:vienitdev,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs

示例8: CreateCommand_should_return_expected_result_when_readConcern_is_provided

        public void CreateCommand_should_return_expected_result_when_readConcern_is_provided(
            [Values("{level: 'local'}", "{level: 'majority'}")]
            string readConcernJson)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.ReadConcern = ReadConcern.FromBsonDocument(BsonDocument.Parse(readConcernJson));
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', readConcern : {readConcernJson} }}");
        }
开发者ID:steven7gao,项目名称:mongo-csharp-driver,代码行数:13,代码来源:FindCommandOperationTests.cs

示例9: CreateCommand_should_return_expected_result_when_limit_is_provided

        public void CreateCommand_should_return_expected_result_when_limit_is_provided(int value, string json)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.Limit = value;
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription();

            var result = reflector.CreateCommand(serverDescription);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}'{json} }}");
        }
开发者ID:steven7gao,项目名称:mongo-csharp-driver,代码行数:11,代码来源:FindCommandOperationTests.cs

示例10: CreateCommand_should_return_expected_result_when_allowPartialResults_is_provided

        public void CreateCommand_should_return_expected_result_when_allowPartialResults_is_provided(
            [Values(false, true)]
            bool value)
        {
            var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            subject.AllowPartialResults = value;
            var reflector = new Reflector(subject);
            var serverDescription = CreateServerDescription(type: ServerType.ShardRouter);

            var result = reflector.CreateCommand(serverDescription);

            result.Should().Be($"{{ find : '{_collectionNamespace.CollectionName}', allowPartialResults : {(value ? "true" : "false")} }}");
        }
开发者ID:steven7gao,项目名称:mongo-csharp-driver,代码行数:13,代码来源:FindCommandOperationTests.cs

示例11: CreateCommand_should_return_expected_result_when_WriteConcern_is_set

        public void CreateCommand_should_return_expected_result_when_WriteConcern_is_set(
            [Values(null, 1, 2)]
            int? w,
            [Values(false, true)]
            bool isWriteConcernSupported)
        {
            var writeConcern = w.HasValue ? new WriteConcern(w.Value) : null;
            var subject = new MapReduceOutputToCollectionOperation(_collectionNamespace, _outputCollectionNamespace, _mapFunction, _reduceFunction, _messageEncoderSettings)
            {
                WriteConcern = writeConcern
            };
            var subjectReflector = new Reflector(subject);
            var serverVersion = Feature.CommandsThatWriteAcceptWriteConcern.SupportedOrNotSupportedVersion(isWriteConcernSupported);

            var result = subjectReflector.CreateCommand(serverVersion);

            var expectedResult = new BsonDocument
            {
                { "mapreduce", _collectionNamespace.CollectionName },
                { "map", _mapFunction },
                { "reduce", _reduceFunction },
                { "out", new BsonDocument { {"replace", _outputCollectionNamespace.CollectionName }, { "db", _databaseNamespace.DatabaseName } } },
                { "writeConcern", () => writeConcern.ToBsonDocument(), writeConcern != null && isWriteConcernSupported }
            };
            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:26,代码来源:MapReduceOutputToCollectionOperationTests.cs

示例12: CreateCommand_should_return_expected_result_when_BypassDocumentValidation_is_set

        public void CreateCommand_should_return_expected_result_when_BypassDocumentValidation_is_set(
            [Values(null, false, true)]
            bool? bypassDocumentValidation,
            [Values(false, true)]
            bool useServerVersionSupportingBypassDocumentValidation)
        {
            var subject = new MapReduceOutputToCollectionOperation(_collectionNamespace, _outputCollectionNamespace, _mapFunction, _reduceFunction, _messageEncoderSettings)
            {
                BypassDocumentValidation = bypassDocumentValidation
            };
            var subjectReflector = new Reflector(subject);
            var serverVersion = Feature.BypassDocumentValidation.SupportedOrNotSupportedVersion(useServerVersionSupportingBypassDocumentValidation);

            var result = subjectReflector.CreateCommand(serverVersion);

            var expectedResult = new BsonDocument
            {
                { "mapreduce", _collectionNamespace.CollectionName },
                { "map", _mapFunction },
                { "reduce", _reduceFunction },
                { "out", new BsonDocument { {"replace", _outputCollectionNamespace.CollectionName }, { "db", _databaseNamespace.DatabaseName } } },
                { "bypassDocumentValidation", () => bypassDocumentValidation.Value, bypassDocumentValidation.HasValue && Feature.BypassDocumentValidation.IsSupported(serverVersion) }
            };
            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:25,代码来源:MapReduceOutputToCollectionOperationTests.cs


注:本文中的Reflector.CreateCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。