예제 #1
0
        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
            case "filter":
                _filter = (BsonDocument)value;
                return(true);

            case "replacement":
                _replacement = (BsonDocument)value;
                return(true);

            case "upsert":
                _options.IsUpsert = value.ToBoolean();
                return(true);

            case "collation":
                _options.Collation = Collation.FromBsonDocument(value.AsBsonDocument);
                return(true);

            case "hint":
                _options.Hint = value;
                return(true);
            }

            return(false);
        }
예제 #2
0
        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
            case "filter":
                _filter = (BsonDocument)value;
                return(true);

            case "projection":
                _options.Projection = (BsonDocument)value;
                return(true);

            case "sort":
                _options.Sort = (BsonDocument)value;
                return(true);

            case "collation":
                _options.Collation = Collation.FromBsonDocument(value.AsBsonDocument);
                return(true);

            case "hint":
                _options.Hint = value;
                return(true);
            }

            return(false);
        }
예제 #3
0
        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
            case "filter":
                _filter = (BsonDocument)value;
                return(true);

            case "update":
                _update = value;
                return(true);

            case "upsert":
                _options.IsUpsert = value.ToBoolean();
                return(true);

            case "collation":
                _options.Collation = Collation.FromBsonDocument(value.AsBsonDocument);
                return(true);

            case "arrayFilters":
                var arrayFilters = new List <ArrayFilterDefinition>();
                foreach (BsonDocument arrayFilterDocument in value.AsBsonArray)
                {
                    var arrayFilter = new BsonDocumentArrayFilterDefinition <BsonDocument>(arrayFilterDocument);
                    arrayFilters.Add(arrayFilter);
                }
                _options.ArrayFilters = arrayFilters;
                return(true);
            }

            return(false);
        }
        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
            case "filter":
                _filter = (BsonDocument)value;
                return(true);

            case "replacement":
                _replacement = (BsonDocument)value;
                return(true);

            case "projection":
                _options.Projection = (BsonDocument)value;
                return(true);

            case "sort":
                _options.Sort = (BsonDocument)value;
                return(true);

            case "upsert":
                _options.IsUpsert = value.ToBoolean();
                return(true);

            case "returnDocument":
                _options.ReturnDocument = (ReturnDocument)Enum.Parse(typeof(ReturnDocument), value.ToString());
                return(true);

            case "collation":
                _options.Collation = Collation.FromBsonDocument(value.AsBsonDocument);
                return(true);
            }

            return(false);
        }
        // public methods
        public override void Initialize(BsonDocument operation)
        {
            VerifyFields(operation, "name", "arguments");

            foreach (var argument in operation["arguments"].AsBsonDocument)
            {
                switch (argument.Name)
                {
                case "filter":
                    _filter = argument.Value.AsBsonDocument;
                    break;

                case "projection":
                    _options.Projection = argument.Value.AsBsonDocument;
                    break;

                case "sort":
                    _options.Sort = argument.Value.AsBsonDocument;
                    break;

                case "collation":
                    _options.Collation = Collation.FromBsonDocument(argument.Value.AsBsonDocument);
                    break;

                default:
                    throw new ArgumentException($"Unexpected argument: {argument.Name}.");
                }
            }
        }
예제 #6
0
        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
            case "filter":
                _filter = (BsonDocument)value;
                return(true);

            case "sort":
                _options.Sort = value.ToBsonDocument();
                return(true);

            case "limit":
                _options.Limit = value.ToInt32();
                return(true);

            case "skip":
                _options.Skip = value.ToInt32();
                return(true);

            case "batchSize":
                _options.BatchSize = value.ToInt32();
                return(true);

            case "collation":
                _options.Collation = Collation.FromBsonDocument(value.AsBsonDocument);
                return(true);
            }

            return(false);
        }
예제 #7
0
        private void ParseDeleteArguments(
            BsonDocument value,
            out FilterDefinition <BsonDocument> filter,
            out Collation collation,
            out BsonValue hint)
        {
            filter    = null;
            collation = null;
            hint      = null;

            foreach (BsonElement argument in value["arguments"].AsBsonDocument)
            {
                switch (argument.Name)
                {
                case "collation":
                    collation = Collation.FromBsonDocument(argument.Value.AsBsonDocument);
                    break;

                case "filter":
                    filter = ParseFilter(argument.Value.AsBsonDocument);
                    break;

                case "hint":
                    hint = argument.Value;
                    break;

                default:
                    throw new FormatException($"Unexpected argument: {argument.Name}.");
                }
            }
        }
예제 #8
0
        // public methods
        public override void Initialize(BsonDocument operation)
        {
            VerifyFields(operation, "name", "arguments");

            foreach (var argument in operation["arguments"].AsBsonDocument)
            {
                switch (argument.Name)
                {
                case "filter":
                    _filter = argument.Value.AsBsonDocument;
                    break;

                case "update":
                    _update = argument.Value.AsBsonDocument;
                    break;

                case "projection":
                    _options.Projection = argument.Value.AsBsonDocument;
                    break;

                case "sort":
                    _options.Sort = argument.Value.AsBsonDocument;
                    break;

                case "upsert":
                    _options.IsUpsert = argument.Value.ToBoolean();
                    break;

                case "returnDocument":
                    _options.ReturnDocument = (ReturnDocument)Enum.Parse(typeof(ReturnDocument), argument.Value.AsString);
                    break;

                case "collation":
                    _options.Collation = Collation.FromBsonDocument(argument.Value.AsBsonDocument);
                    break;

                case "arrayFilters":
                    var arrayFilters = new List <ArrayFilterDefinition>();
                    foreach (var arrayFilter in argument.Value.AsBsonArray)
                    {
                        var arrayFilterDefinition = new BsonDocumentArrayFilterDefinition <BsonDocument>(arrayFilter.AsBsonDocument);
                        arrayFilters.Add(arrayFilterDefinition);
                    }
                    _options.ArrayFilters = arrayFilters;
                    break;

                case "hint":
                    _options.Hint = argument.Value;
                    break;

                default:
                    throw new ArgumentException($"Unexpected argument: {argument.Name}.");
                }
            }
        }
예제 #9
0
        private void ParseUpdateArguments(
            BsonDocument value,
            out FilterDefinition <BsonDocument> filter,
            out UpdateDefinition <BsonDocument> update,
            out List <ArrayFilterDefinition> arrayFilters,
            out Collation collation,
            out BsonValue hint,
            out bool isUpsert)
        {
            arrayFilters = null;
            filter       = null;
            update       = null;
            collation    = null;
            hint         = null;
            isUpsert     = false;

            foreach (BsonElement argument in value["arguments"].AsBsonDocument)
            {
                switch (argument.Name)
                {
                case "arrayFilters":
                    arrayFilters = ParseArrayFilters(argument.Value.AsBsonArray);
                    break;

                case "collation":
                    collation = Collation.FromBsonDocument(argument.Value.AsBsonDocument);
                    break;

                case "filter":
                    filter = ParseFilter(argument.Value.AsBsonDocument);
                    break;

                case "hint":
                    hint = argument.Value;
                    break;

                case "update":
                    update = ParseUpdate(argument.Value.AsBsonDocument);
                    break;

                case "upsert":
                    isUpsert = argument.Value.ToBoolean();
                    break;

                default:
                    throw new FormatException($"Unexpected argument: {argument.Name}.");
                }
            }
        }
        // public methods
        public override void Initialize(BsonDocument operation)
        {
            VerifyFields(operation, "name", "arguments");

            foreach (var argument in operation["arguments"].AsBsonDocument)
            {
                switch (argument.Name)
                {
                case "filter":
                    _filter = argument.Value.AsBsonDocument;
                    break;

                case "replacement":
                    _replacement = argument.Value.AsBsonDocument;
                    break;

                case "projection":
                    _options.Projection = argument.Value.AsBsonDocument;
                    break;

                case "sort":
                    _options.Sort = argument.Value.AsBsonDocument;
                    break;

                case "upsert":
                    _options.IsUpsert = argument.Value.ToBoolean();
                    break;

                case "returnDocument":
                    _options.ReturnDocument = (ReturnDocument)Enum.Parse(typeof(ReturnDocument), argument.Value.AsString);
                    break;

                case "collation":
                    _options.Collation = Collation.FromBsonDocument(argument.Value.AsBsonDocument);
                    break;

                case "hint":
                    _options.Hint = argument.Value;
                    break;

                default:
                    throw new ArgumentException($"Unexpected argument: {argument.Name}.");
                }
            }
        }
        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
            case "fieldName":
                _fieldName = value.ToString();
                return(true);

            case "filter":
                _filter = (BsonDocument)value;
                return(true);

            case "collation":
                _options.Collation = Collation.FromBsonDocument(value.AsBsonDocument);
                return(true);
            }

            return(false);
        }
예제 #12
0
        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
            case "pipeline":
                _stages = ((BsonArray)value).Cast <BsonDocument>().ToList();
                return(true);

            case "batchSize":
                _options.BatchSize = (int)value;
                return(true);

            case "collation":
                _options.Collation = Collation.FromBsonDocument(value.AsBsonDocument);
                return(true);
            }

            return(false);
        }
예제 #13
0
        private void ParseReplaceArguments(
            BsonDocument value,
            out FilterDefinition <BsonDocument> filter,
            out BsonDocument replacement,
            out Collation collation,
            out BsonValue hint,
            out bool isUpsert)
        {
            filter      = null;
            replacement = null;
            collation   = null;
            hint        = null;
            isUpsert    = false;

            foreach (BsonElement argument in value["arguments"].AsBsonDocument)
            {
                switch (argument.Name)
                {
                case "collation":
                    collation = Collation.FromBsonDocument(argument.Value.AsBsonDocument);
                    break;

                case "filter":
                    filter = ParseFilter(argument.Value.AsBsonDocument);
                    break;

                case "hint":
                    hint = argument.Value;
                    break;

                case "replacement":
                    replacement = argument.Value.AsBsonDocument;
                    break;

                case "upsert":
                    isUpsert = argument.Value.ToBoolean();
                    break;

                default:
                    throw new FormatException($"Unexpected argument: {argument.Name}.");
                }
            }
        }
예제 #14
0
        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
                case "filter":
                    _filter = (BsonDocument)value;
                    return true;
                case "skip":
                    _options.Skip = value.ToInt64();
                    return true;
                case "limit":
                    _options.Limit = value.ToInt64();
                    return true;
                case "collation":
                    _options.Collation = Collation.FromBsonDocument(value.AsBsonDocument);
                    return true;
            }

            return false;
        }