Ejemplo n.º 1
0
 public void Init(NetContractDescription description, IMessageFactory messageFactory, IOperationExecutor target, ActorKey?actor = null)
 {
     _description    = description;
     _messageFactory = messageFactory;
     _target         = target;
     Actor           = actor;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the <see cref="ApiController"/> instance with the specified controllerContext.
        /// </summary>
        /// <remarks>
        /// Resolves the api, query settings, validation settings, operation executor from
        /// the Request container associated with the HttpRequestMessage.
        /// </remarks>
        /// <param name="controllerContext">
        /// The <see cref="HttpControllerContext"/> object that is used for the initialization.
        /// </param>
        protected override void Initialize(HttpControllerContext controllerContext)
        {
            base.Initialize(controllerContext);

            if (api != null && querySettings != null && validationSettings != null && operationExecutor != null)
            {
                return;
            }

            // TODO: JWS Either properly inject RestierController into the DI Container.
            // or provide sensible defaults for these dependencies to reduce DI dependency.
#pragma warning disable CA1062 // Validate arguments of public methods
            var provider = controllerContext.Request.GetRequestContainer();
#pragma warning restore CA1062 // Validate arguments of public methods

            if (api == null)
            {
                api = provider.GetService(typeof(ApiBase)) as ApiBase;
            }
            if (querySettings == null)
            {
                querySettings = provider.GetService(typeof(ODataQuerySettings)) as ODataQuerySettings;
            }
            if (validationSettings == null)
            {
                validationSettings = provider.GetService(typeof(ODataValidationSettings)) as ODataValidationSettings;
            }
            if (operationExecutor == null)
            {
                operationExecutor = provider.GetService(typeof(IOperationExecutor)) as IOperationExecutor;
            }
        }
Ejemplo n.º 3
0
 // constructors
 public MongoDatabaseImpl(DatabaseNamespace databaseNamespace, MongoDatabaseSettings settings, ICluster cluster, IOperationExecutor operationExecutor)
 {
     _databaseNamespace = Ensure.IsNotNull(databaseNamespace, "databaseNamespace");
     _settings          = Ensure.IsNotNull(settings, "settings");
     _cluster           = Ensure.IsNotNull(cluster, "cluster");
     _operationExecutor = Ensure.IsNotNull(operationExecutor, "operationExecutor");
 }
Ejemplo n.º 4
0
 private bool CheckOperation(string op1, string op2, IOperationExecutor operationExecutor)
 {
     _ex1 = Expression.Create(op1, operationExecutor);
     if (!_ex1.HasValue) return false;
     _ex2 = Expression.Create(op2, operationExecutor);
     return (_ex2.HasValue);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the MongoClient class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 public MongoClient(MongoClientSettings settings)
 {
     _settings          = Ensure.IsNotNull(settings, nameof(settings)).FrozenCopy();
     _cluster           = ClusterRegistry.Instance.GetOrCreateCluster(_settings.ToClusterKey());
     _operationExecutor = new OperationExecutor(this);
     _serverSessionPool = new ServerSessionPool(this);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new instance or returns an existing instance of MongoServer. Only one instance
        /// is created for each combination of server settings.
        /// </summary>
        /// <param name="connectionString">Server settings in the form of a connection string.</param>
        /// <param name="operationExecutor">The operation executor.</param>
        /// <returns>
        /// A new or existing instance of MongoServer.
        /// </returns>
        internal static MongoServer Create(string connectionString, IOperationExecutor operationExecutor)
        {
            var url            = MongoUrl.Create(connectionString);
            var serverSettings = MongoServerSettings.FromUrl(url);

            return(Create(serverSettings, operationExecutor));
        }
        internal MongoDatabase(MongoServer server, string name, MongoDatabaseSettings settings, IOperationExecutor operationExecutor)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            string message;

            if (!server.IsDatabaseNameValid(name, out message))
            {
                throw new ArgumentOutOfRangeException("name", message);
            }

            settings = settings.Clone();
            settings.ApplyDefaultValues(server.Settings);
            settings.Freeze();

            _server            = server;
            _namespace         = new DatabaseNamespace(name);
            _settings          = settings;
            _operationExecutor = operationExecutor;
        }
        public void Run(IOperationExecutor executor)
        {
            if (!_force)
            {
                var result   = executor.GetContextInfo(_context);
                var reporter = _json
                    ? (Action <IDictionary>)ReportJsonDatabaseDiscovered
                    : ReportDatabaseDiscovered;

                reporter.Invoke(result);
                if (result == null)
                {
                    return;
                }
            }

            if (_dryRun)
            {
                return;
            }

            if (!_force)
            {
                Reporter.Output("Are you sure you want to proceed? (y/N)".MaybeColor(s => s.Bold()));
                var readedKey = Console.ReadLine().Trim();
                var confirmed = (readedKey == "y") || (readedKey == "Y");
                if (!confirmed)
                {
                    Reporter.Output("Cancelled");
                    return;
                }
            }

            executor.DropDatabase(_context);
        }
Ejemplo n.º 9
0
        public IContainer GetContainer()
        {
            var container = new TinyIoCContainer();

            container.Register <ICrmServiceProvider, CrmServiceProvider>().AsMultiInstance();
            container.Register <ICrmMetaDataProvider, InMemoryCachedCrmMetaDataProvider>().AsMultiInstance();

            container.Register <ISchemaCollectionsProvider, SchemaCollectionsProvider>();                        // singleton instance.

            container.Register <IDynamicsAttributeTypeProvider, DynamicsAttributeTypeProvider>();                // singleton instance.
            container.Register <ICrmMetadataNamingConventionProvider, CrmAdoCrmMetadataNamingProvider>();        // singleton instance.
            container.Register <ISchemaTableProvider, SchemaTableProvider>();                                    // singleton instance.
            container.Register <ICrmClientCredentialsProvider, CrmClientCredentialsProvider>();                  // singleton instance.
            container.Register <ICrmConnectionProvider, ExplicitConnectionStringProviderWithFallbackToConfig>(); // singleton instance.

            IOperationExecutor commandExecutor = CrmOperationExecutor.Instance;

            container.Register <IOperationExecutor>(commandExecutor); // singleton instance.

            container.Register <ICrmOperationProvider, SqlGenerationCrmOperationProvider>().AsMultiInstance();;

            container.Register <ICrmOrganisationManager, CrmOrganisationManager>();
            container.Register <IEntityMetadataRepository, EntityMetadataRepository>();

            // When CrmDbCommands are resolved, use the contructor that specifies a null connection, but provide rest of dependencies from container.
            // Issue raised: https://github.com/grumpydev/TinyIoC/issues/70
            //container.Register<CrmDbCommand>().UsingConstructor(() => new CrmDbCommand(null as CrmDbConnection, container.Resolve<IOrgCommandExecutor>(), container.Resolve<IOrganisationCommandProvider>()));
            //var resolve = container.Resolve<CrmDbCommand>();

            return(container);
        }
Ejemplo n.º 10
0
 public Scaffolder(GeneratorContext generatorContext,
                   IOperationBuilder operationBuilder, IOperationExecutor operationExecutor, IConfigurationResolver configurationResolver)
 {
     _generatorContext      = generatorContext;
     _operationBuilder      = operationBuilder;
     _operationExecutor     = operationExecutor;
     _configurationResolver = configurationResolver;
 }
Ejemplo n.º 11
0
 public IOperation Recognize(string expression, IOperationExecutor operationExecutor)
 {
     if (expression == _constString)
         return
             _unaryOperationPrvider.GetOperation(Expression.Create(_constValue.ToString(CultureInfo.InvariantCulture),
                                                                   operationExecutor));
     throw new NotSupportedException(expression);
 }
 // constructors
 public MongoDatabaseImpl(IMongoClient client, DatabaseNamespace databaseNamespace, MongoDatabaseSettings settings, ICluster cluster, IOperationExecutor operationExecutor)
 {
     _client            = Ensure.IsNotNull(client, nameof(client));
     _databaseNamespace = Ensure.IsNotNull(databaseNamespace, nameof(databaseNamespace));
     _settings          = Ensure.IsNotNull(settings, nameof(settings)).Freeze();
     _cluster           = Ensure.IsNotNull(cluster, nameof(cluster));
     _operationExecutor = Ensure.IsNotNull(operationExecutor, nameof(operationExecutor));
 }
Ejemplo n.º 13
0
        // constructors
        public MongoCollectionImpl(CollectionNamespace collectionNamespace, MongoCollectionSettings settings, ICluster cluster, IOperationExecutor operationExecutor)
        {
            _collectionNamespace = Ensure.IsNotNull(collectionNamespace, "collectionNamespace");
            _settings            = Ensure.IsNotNull(settings, "settings");
            _cluster             = Ensure.IsNotNull(cluster, "cluster");
            _operationExecutor   = Ensure.IsNotNull(operationExecutor, "operationExecutor");

            _serializer = _settings.SerializerRegistry.GetSerializer <T>();
        }
Ejemplo n.º 14
0
        private void EnsureInitialized()
        {
            var container = HttpContext.Request.GetRequestContainer();

            api                = container.GetRequiredService <ApiBase>();
            querySettings      = container.GetRequiredService <ODataQuerySettings>();
            validationSettings = container.GetRequiredService <ODataValidationSettings>();
            operationExecutor  = container.GetRequiredService <IOperationExecutor>();
        }
Ejemplo n.º 15
0
        public int Index(string expression, IOperationExecutor operationExecutor)
        {
            if (CheckOperation(expression))
            {
                return 0;
            }

            return -1;
        }
        public void Run(IOperationExecutor executor)
        {
            var filesCreated = executor.ScaffoldContext(_provider, _connection, _outputDir, _context, _schemas, _tables, _dataAnnotations, _force);

            if (_json)
            {
                ReportJsonResults(filesCreated);
            }
        }
Ejemplo n.º 17
0
        public void Run(IOperationExecutor executor)
        {
            var deletedFiles = executor.RemoveMigration(_context, _force);

            if (_json)
            {
                ReportJsonResults(deletedFiles);
            }
        }
Ejemplo n.º 18
0
        internal MongoServer(MongoServerSettings settings, IOperationExecutor operationExecutor)
        {
            _settings          = settings.FrozenCopy();
            _operationExecutor = operationExecutor;
            _sequentialId      = Interlocked.Increment(ref __nextSequentialId);
            // Console.WriteLine("MongoServer[{0}]: {1}", sequentialId, settings);

            _cluster = ClusterRegistry.Instance.GetOrCreateCluster(_settings.ToClusterKey());
            StartTrackingServerInstances();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RestierController"/> class.
        /// </summary>
        /// <param name="querySettings">OData Query settings for queries.</param>
        /// <param name="validationSettings">OData validation settings for validation.</param>
        /// <param name="operationExecutor">An Operation Executer to execute operations.</param>
        public RestierController(ODataQuerySettings querySettings, ODataValidationSettings validationSettings, IOperationExecutor operationExecutor)
        {
            Ensure.NotNull(querySettings, nameof(querySettings));
            Ensure.NotNull(validationSettings, nameof(validationSettings));
            Ensure.NotNull(operationExecutor, nameof(operationExecutor));

            this.querySettings      = querySettings;
            this.validationSettings = validationSettings;
            this.operationExecutor  = operationExecutor;
        }
 public IOperation Recognize(string expression, IOperationExecutor operationExecutor)
 {
     if (Index(expression, operationExecutor) == 0)
     {
         var nExp = expression.Substring(1, expression.Length - 2);
         var bo = _unaryOperationProvider.GetOperation(Expression.Create(nExp, operationExecutor));
         return bo;
     }
     return null;
 }
Ejemplo n.º 21
0
        internal TableResult Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();
            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);

            IOperationExecutor <TableResult, TableOperation> operationExecutor = GetExecutor(client);

            return(operationExecutor.Execute(this, client, table, modifiedOptions, operationContext));
        }
Ejemplo n.º 22
0
        internal ICancellableAsyncResult BeginExecute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);

            IOperationExecutor <TableResult, TableOperation> operationExecutor = GetExecutor(client);

            return(operationExecutor.BeginExecute(this, client, table, modifiedOptions, operationContext, callback, state));
        }
Ejemplo n.º 23
0
        // private methods
        private MongoDatabaseImpl CreateSubject(IOperationExecutor operationExecutor)
        {
            var settings = new MongoDatabaseSettings();

            settings.ApplyDefaultValues(new MongoClientSettings());
            return(new MongoDatabaseImpl(
                       new Mock <IMongoClient>().Object,
                       new DatabaseNamespace("foo"),
                       settings,
                       new Mock <ICluster>().Object,
                       _operationExecutor));
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the MongoClient class.
 /// In .NET Standard, authenticating via SCRAM-SHA-256 may not work with non-ASCII passwords because SaslPrep is
 /// not fully implemented due to the lack of a string normalization function in .NET Standard 1.5.
 /// Normalizing the password into Unicode Normalization Form KC beforehand MAY help.
 /// SCRAM-SHA-1 is the recommended alternative for now.
 /// </summary>
 /// <param name="settings">The settings.</param>
 public MongoClient(MongoClientSettings settings)
 {
     _settings          = Ensure.IsNotNull(settings, nameof(settings)).FrozenCopy();
     _cluster           = ClusterRegistry.Instance.GetOrCreateCluster(_settings.ToClusterKey());
     _operationExecutor = new OperationExecutor(this);
     if (settings.AutoEncryptionOptions != null)
     {
         _libMongoCryptController = new AutoEncryptionLibMongoCryptController(
             this,
             _cluster.CryptClient,
             settings.AutoEncryptionOptions);
     }
 }
        public void Run(IOperationExecutor executor)
        {
            var types = executor.GetContextTypes();

            if (_json)
            {
                ReportJsonResults(types);
            }
            else
            {
                ReportResults(types);
            }
        }
Ejemplo n.º 26
0
        public void Run(IOperationExecutor executor)
        {
            var files = executor.AddMigration(_name, _outputDir, _context);

            if (_json)
            {
                ReportJson(files);
            }
            else
            {
                Reporter.Output("Done. To undo this action, use 'dotnet ef migrations remove'");
            }
        }
        public void Run(IOperationExecutor executor)
        {
            var migrations = executor.GetMigrations(_context);

            if (_json)
            {
                ReportJsonResults(migrations);
            }
            else
            {
                ReportResults(migrations);
            }
        }
Ejemplo n.º 28
0
        public App(IOperationExecutor executor, IStringWriter writer)
        {
            if (executor == null)
            {
                throw new ArgumentNullException(nameof(executor));
            }
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            _executor = executor;
            _writer   = writer;
        }
Ejemplo n.º 29
0
        // constructors
        public MongoCollectionImpl(CollectionNamespace collectionNamespace, MongoCollectionSettings settings, ICluster cluster, IOperationExecutor operationExecutor)
        {
            _collectionNamespace = Ensure.IsNotNull(collectionNamespace, "collectionNamespace");
            _settings            = Ensure.IsNotNull(settings, "settings").Freeze();
            _cluster             = Ensure.IsNotNull(cluster, "cluster");
            _operationExecutor   = Ensure.IsNotNull(operationExecutor, "operationExecutor");

            _serializer             = _settings.SerializerRegistry.GetSerializer <TDocument>();
            _messageEncoderSettings = new MessageEncoderSettings
            {
                { MessageEncoderSettingsName.GuidRepresentation, _settings.GuidRepresentation },
                { MessageEncoderSettingsName.ReadEncoding, _settings.ReadEncoding ?? Utf8Encodings.Strict },
                { MessageEncoderSettingsName.WriteEncoding, _settings.WriteEncoding ?? Utf8Encodings.Strict }
            };
        }
Ejemplo n.º 30
0
        // constructors
        public MongoDatabaseImpl(IMongoClient client, DatabaseNamespace databaseNamespace, MongoDatabaseSettings settings, ICluster cluster, IOperationExecutor operationExecutor)
        {
            _client            = Ensure.IsNotNull(client, nameof(client));
            _databaseNamespace = Ensure.IsNotNull(databaseNamespace, nameof(databaseNamespace));
            _settings          = Ensure.IsNotNull(settings, nameof(settings)).Freeze();
            _cluster           = Ensure.IsNotNull(cluster, nameof(cluster));
            _operationExecutor = Ensure.IsNotNull(operationExecutor, nameof(operationExecutor));

            _messageEncoderSettings = new MessageEncoderSettings
            {
                { MessageEncoderSettingsName.GuidRepresentation, _settings.GuidRepresentation },
                { MessageEncoderSettingsName.ReadEncoding, _settings.ReadEncoding ?? Utf8Encodings.Strict },
                { MessageEncoderSettingsName.WriteEncoding, _settings.WriteEncoding ?? Utf8Encodings.Strict }
            };
        }
        private MongoDatabaseImpl CreateSubject(IOperationExecutor operationExecutor)
        {
            var mockClient  = new Mock <IMongoClient>();
            var mockCluster = new Mock <ICluster>();

            mockClient.SetupGet(m => m.Cluster).Returns(mockCluster.Object);
            var settings = new MongoDatabaseSettings();

            settings.ApplyDefaultValues(new MongoClientSettings());
            return(new MongoDatabaseImpl(
                       mockClient.Object,
                       new DatabaseNamespace("foo"),
                       settings,
                       new Mock <ICluster>().Object,
                       operationExecutor ?? _operationExecutor));
        }
Ejemplo n.º 32
0
        private MongoCollectionImpl(IMongoDatabase database, CollectionNamespace collectionNamespace, MongoCollectionSettings settings, ICluster cluster, IOperationExecutor operationExecutor, IBsonSerializer <TDocument> documentSerializer)
        {
            _database            = Ensure.IsNotNull(database, nameof(database));
            _collectionNamespace = Ensure.IsNotNull(collectionNamespace, nameof(collectionNamespace));
            _settings            = Ensure.IsNotNull(settings, nameof(settings)).Freeze();
            _cluster             = Ensure.IsNotNull(cluster, nameof(cluster));
            _operationExecutor   = Ensure.IsNotNull(operationExecutor, nameof(operationExecutor));
            _documentSerializer  = Ensure.IsNotNull(documentSerializer, nameof(documentSerializer));

            _messageEncoderSettings = new MessageEncoderSettings
            {
                { MessageEncoderSettingsName.GuidRepresentation, _settings.GuidRepresentation },
                { MessageEncoderSettingsName.ReadEncoding, _settings.ReadEncoding ?? Utf8Encodings.Strict },
                { MessageEncoderSettingsName.WriteEncoding, _settings.WriteEncoding ?? Utf8Encodings.Strict }
            };
        }
        public NetProxy CreateProxy(uint contractId, IMessageFactory messageFactory, IOperationExecutor executor, ActorKey?actorKey = null)
        {
            NetProxy proxy;
            NetContractDescription desc;

            if (_descByTypeId.TryGetValue(contractId, out desc))
            {
                proxy = (NetProxy)FormatterServices.GetUninitializedObject(desc.ProxyType);
                proxy.Init(desc, messageFactory, executor, actorKey);
            }
            else
            {
                throw new Exception("Unregistered entity typeId - " + contractId);
            }

            return(proxy);
        }
Ejemplo n.º 34
0
        protected override int Execute()
        {
            InitExecutorMap();

            logger = GetLogger();
            Hashtable args = GetArguments();

            bool isOk = ValidParams(args);

            if (!isOk)
            {
                return(1);
            }

            string oprName = args["opr"].ToString();

            foreach (string pattern in executorMap.Keys)
            {
                Match match = Regex.Match(oprName, pattern);
                if (!match.Success)
                {
                    continue;
                }

                string fqdn = (string)executorMap[pattern];
                string json = "";

                Assembly           asm = Assembly.GetExecutingAssembly();
                IOperationExecutor obj = (IOperationExecutor)asm.CreateInstance(fqdn);
                obj.SetLogger(logger);

                if (fqdn.EndsWith("GetListExecutor"))
                {
                    json = obj.ExecuteGetListOperation(oprName, args);
                }
                else
                {
                    json = obj.ExecuteOperation(oprName, args);
                }

                Console.WriteLine(json);
            }

            return(0);
        }
Ejemplo n.º 35
0
        public IOperation Recognize(string expression, IOperationExecutor operationExecutor)
        {
            var si = Index(expression, operationExecutor);
            var check = false;

            if (si >= 0)
            {
                var sop1 = expression.Substring(0, si);
                var sop2 = expression.Substring(si + 1, expression.Length - si - 1);

                check = CheckOperation(sop1, sop2, operationExecutor);
                if (check)
                {
                    return _binaryOperationProvider.GetOperation(_ex1, _ex2);
                }
            }
            throw new NotSupportedException(expression);
        }
Ejemplo n.º 36
0
        public CrmDbCommand(CrmDbConnection connection, IOperationExecutor crmCommandExecutor, ICrmOperationProvider organisationCommandProvider)
        {
            if (crmCommandExecutor == null)
            {
                throw new ArgumentNullException("crmCommandExecutor");
            }

            if (organisationCommandProvider == null)
            {
                throw new ArgumentNullException("organisationCommandProvider");
            }

            _DbConnection = connection;
            _CrmCommandExecutor = crmCommandExecutor;
            _OrganisationCommandProvider = organisationCommandProvider;
            _CommandType = CommandType.Text;
            _ParameterCollection = new CrmParameterCollection();
        }
Ejemplo n.º 37
0
        public int Index(string expression, IOperationExecutor operationExecutor)
        {
            var maxIndex = -1;
            for (var i = 0; i < expression.Length; i++)
            {
                var ind = expression.IndexOf(_operationSymbol, i);
                if (ind > maxIndex && (ind + _operationSymbol.Length) <= (expression.Length-1))
                {
                    var sop1 = expression.Substring(0, ind);
                    var sop2 = expression.Substring(ind + _operationSymbol.Length, expression.Length - ind -_operationSymbol.Length);

                    if (CheckOperation(sop1, sop2, operationExecutor))
                    {
                        maxIndex = ind;
                    }
                }
            }
            return maxIndex;
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Expression"/> class.
 /// </summary>
 /// <param name="expression">
 /// The expression.
 /// </param>
 /// <param name="operationExecutor">
 /// The operation executor.
 /// </param>
 private Expression(string expression, IOperationExecutor operationExecutor)
 {
     this.expression = expression;
       this.operationExecutor = operationExecutor;
 }
Ejemplo n.º 39
0
 public int Index(string expression, IOperationExecutor operationExecutor)
 {
     return expression == _constString ? 0 : -1;
 }
Ejemplo n.º 40
0
 private Expression(string expression, IOperationExecutor operationExecutor)
 {
     _expression = expression;
     _operationExecutor = operationExecutor;
 }
 public int Index(string expression, IOperationExecutor operationExecutor)
 {
     var rx = new Regex(@"^\(.*\)$");
     return rx.IsMatch(expression) ? 0 : -1;
 }
Ejemplo n.º 42
0
 public static Expression Create(string expression, IOperationExecutor operationExecutor)
 {
     return new Expression(expression, operationExecutor);
 }
Ejemplo n.º 43
0
 public CrmDbCommand(CrmDbConnection connection, IOperationExecutor crmCommandExecutor)
     : this(connection, crmCommandExecutor, new SqlGenerationCrmOperationProvider())
 {
 }
Ejemplo n.º 44
0
 public int Index(string expression, IOperationExecutor operationExecutor)
 {
     var rx = new Regex(@"^" +_functionName+ @"\(.*\)$");
     var result =  rx.IsMatch(expression) ? 0 : -1;
     return result;
 }
 // private methods
 private MongoDatabaseImpl CreateSubject(IOperationExecutor operationExecutor)
 {
     var settings = new MongoDatabaseSettings();
     settings.ApplyDefaultValues(new MongoClientSettings());
     return new MongoDatabaseImpl(
         new Mock<IMongoClient>().Object,
         new DatabaseNamespace("foo"),
         settings,
         new Mock<ICluster>().Object,
         _operationExecutor);
 }
Ejemplo n.º 46
0
        /// <summary>
        /// The check operation.
        /// </summary>
        /// <param name="op1">
        /// The op 1.
        /// </param>
        /// <param name="op2">
        /// The op 2.
        /// </param>
        /// <param name="operationExecutor">
        /// The operation executor.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool CheckOperation(string op1, string op2, IOperationExecutor operationExecutor)
        {
            this.ex1 = Expression.Create(op1, operationExecutor);
              if (!this.ex1.HasValue)
              {
            return false;
              }

              this.ex2 = Expression.Create(op2, operationExecutor);
              return this.ex2.HasValue;
        }
Ejemplo n.º 47
0
        /// <summary>
        /// The recognize.
        /// </summary>
        /// <param name="expression">
        /// The expression.
        /// </param>
        /// <param name="operationExecutor">
        /// The operation executor.
        /// </param>
        /// <returns>
        /// The <see cref="IOperation"/>.
        /// </returns>
        public IOperation Recognize(string expression, IOperationExecutor operationExecutor)
        {
            if (this.Index(expression, operationExecutor) == 0)
              {
            var len = this.functionName.Length;
            var nexp = expression.Substring(1 + len, expression.Length - 2 - len);
            var bo = this.unaryOperationProvider.GetOperation(Expression.Create(nexp, operationExecutor));
            return bo;
              }

              return null;
        }
 public void Init(NetContractDescription description, IMessageFactory messageFactory, IOperationExecutor target, ActorKey? actor = null)
 {
     _description = description;
     _messageFactory = messageFactory;
     _target = target;
     Actor = actor;
 }
Ejemplo n.º 49
0
 /// <summary>
 /// Initializes a new instance of the MongoClient class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 public MongoClient(MongoClientSettings settings)
 {
     _settings = Ensure.IsNotNull(settings, nameof(settings)).FrozenCopy();
     _cluster = ClusterRegistry.Instance.GetOrCreateCluster(_settings.ToClusterKey());
     _operationExecutor = new OperationExecutor();
 }
 internal MongoClient(IOperationExecutor operationExecutor)
     : this()
 {
     _operationExecutor = operationExecutor;
 }
 /// <summary>
 /// Initializes a new instance of the MongoClient class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 public MongoClient(MongoClientSettings settings)
 {
     _settings = settings.FrozenCopy();
     _cluster = ClusterRegistry.Instance.GetOrCreateCluster(_settings.ToClusterKey());
     _operationExecutor = new OperationExecutor();
 }
Ejemplo n.º 52
0
 /// <summary>
 /// The create.
 /// </summary>
 /// <param name="expression">
 /// The expression.
 /// </param>
 /// <param name="operationExecutor">
 /// The operation executor.
 /// </param>
 /// <returns>
 /// The <see cref="Expression"/>.
 /// </returns>
 public static Expression Create(string expression, IOperationExecutor operationExecutor)
 {
     expression = expression.Replace(" ", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty);
       return new Expression(expression, operationExecutor);
 }
Ejemplo n.º 53
0
        /// <summary>
        /// The recognize.
        /// </summary>
        /// <param name="expression">
        /// The expression.
        /// </param>
        /// <param name="operationExecutor">
        /// The operation executor.
        /// </param>
        /// <returns>
        /// The <see cref="IOperation"/>.
        /// </returns>
        public IOperation Recognize(string expression, IOperationExecutor operationExecutor)
        {
            if (this.Index(expression, operationExecutor) == 0)
              {
            var len = this.functionName.Length;
            var exp = expression.Substring(len + 1, expression.Length - len - 2);
            var spos = this.FindFirstCorrectIndexOf(exp, ',') + len + 1;
            var nexp1 = expression.Substring(1 + len, spos - 1 - len);
            var nexp2 = expression.Substring(spos + 1, expression.Length - 1 - spos - 1);
            var bo = this.operationProvider.GetOperation(
              Expression.Create(nexp1, operationExecutor), Expression.Create(nexp2, operationExecutor));
            return bo;
              }

              return null;
        }
Ejemplo n.º 54
0
 internal MongoClient(ICluster cluster)
 {
     _settings = new MongoClientSettings();
     _cluster = Ensure.IsNotNull(cluster, "cluster");
     _operationExecutor = new OperationExecutor();
 }
Ejemplo n.º 55
0
 /// <summary>
 /// The index.
 /// </summary>
 /// <param name="expression">
 /// The expression.
 /// </param>
 /// <param name="operationExecutor">
 /// The operation executor.
 /// </param>
 /// <returns>
 /// The <see cref="int"/>.
 /// </returns>
 public int Index(string expression, IOperationExecutor operationExecutor)
 {
     var rx = new Regex(@"^" + this.functionName + @"\(.*,.*\)$");
       var result = rx.IsMatch(expression) && BracketChecker.CheckCorrectBrackets(expression) ? 0 : -1;
       return result;
 }
Ejemplo n.º 56
0
 public IOperation Recognize(string expression, IOperationExecutor operationExecutor)
 {
     var exp = Expression.Create(expression, operationExecutor);
     return _operationProvider.GetOperation(exp);
 }
 /// <summary>
 /// The index.
 /// </summary>
 /// <param name="expression">
 /// The expression.
 /// </param>
 /// <param name="operationExecutor">
 /// The operation executor.
 /// </param>
 /// <returns>
 /// The <see cref="int"/>.
 /// </returns>
 public int Index(string expression, IOperationExecutor operationExecutor)
 {
     var rx = new Regex(@"^\(.*\)$");
       return rx.IsMatch(expression) && BracketChecker.CheckCorrectBrackets(expression) ? 0 : -1;
 }
Ejemplo n.º 58
0
 internal MongoClient(IOperationExecutor operationExecutor, MongoClientSettings settings)
     : this(settings)
 {
     _operationExecutor = operationExecutor;
 }
Ejemplo n.º 59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Expression"/> class.
 /// </summary>
 /// <param name="expression">
 /// The expression.
 /// </param>
 /// <param name="operationExecutor">
 /// The operation executor.
 /// </param>
 private Expression(string expression, IOperationExecutor operationExecutor)
 {
     this.expression = expression;
       this.operationExecutor = operationExecutor;
       this.Id = Guid.NewGuid().ToString();
 }