Ejemplo n.º 1
0
    static void Main()
    {
        var input = Console.ReadLine().Split(new []{" "}, StringSplitOptions.RemoveEmptyEntries);
        var numbers = input.Select(int.Parse).ToList();
        while (true)
        {
            var command = Console.ReadLine();
            if ("end".Equals(command))
            {
                break;
            }

            if ("print".Equals(command))
            {
                Console.WriteLine(String.Join(" ", numbers));
            }
            else
            {
                for (int counter = 0; counter < numbers.Count; counter++)
                {
                    numbers[counter] = CreateOperation(command)(numbers[counter]);
                }
            }
        }
    }
        public override double Calculate()
        {
            double r_res = right.Calculate();
            double res   = CreateOperation.EvaluateOperation(r_res, op);

            return(res);
        }
 //Evaluate the whole operation
 public override double[,] Calculate()
 {
     double[,] l_res = left.Calculate();
     double[,] r_res = right.Calculate();
     double[,] res   = CreateOperation.EvaluateOperation(l_res, r_res, op);
     return(res);
 }
Ejemplo n.º 4
0
        public object Create(object toCreate)
        {
            RepositoryService svc       = GetService(toCreate);
            CreateOperation   operation = CreateOperation.For(toCreate);

            return(svc.Create(operation));
        }
Ejemplo n.º 5
0
        public object Create(CreateOperation value)
        {
            Type   type;
            object instance;

            ResolveTypeAndInstance(value, out type, out instance);
            return(Repository.Create(type, instance));
        }
Ejemplo n.º 6
0
        public void CreateOperationForSetsKeys()
        {
            AssemblyQualifiedTypeDescriptor typeDescriptor = new AssemblyQualifiedTypeDescriptor();
            CreateOperation createOperation = CreateOperation.For(typeDescriptor);

            Expect.IsGreaterThan(createOperation.Properties.Count, 0, "Property count should have been greater than 0");
            Expect.IsFalse(createOperation.Properties.Any(p => string.IsNullOrEmpty(p.InstanceIdentifier)));
            createOperation.Properties.All(p => p.InstanceIdentifier.Equals(typeDescriptor.Key().ToString())).IsTrue("The keys set did not match the expected value");
        }
        public async Task SetAsync(CreateOperation operation)
        {
            using (var context = new WalletManagerContext(_dbContextOptionsBuilder.Options))
            {
                var entity = MapToOperationEntity(operation);
                context.Operations.Add(entity);

                await context.SaveChangesAsync();
            }
        }
 private static OperationEntity MapToOperationEntity(CreateOperation operation)
 {
     return(new OperationEntity()
     {
         BlockchainAssetId = operation.Key.BlockchainAssetId,
         BlockchianId = operation.Key.BlockchainId,
         BalanceChange = operation.BalanceChange.ToString(),
         BlockNumber = operation.Block,
         WalletAddress = operation.Key.WalletAddress.ToLower(CultureInfo.InvariantCulture),
         OriginalWalletAddress = operation.Key.WalletAddress
     });
 }
        /// <summary>
        /// Given the collection of available update scripts (which were added before either by explicitly calling
        /// <see cref="AddUpdateScript"/> or by calling <see cref="AddDirectory"/>), this methods updates the sub schema
        /// of this class in the database to the current version.
        /// </summary>
        /// <remarks>
        /// The update is an iterative process. In each step, an update script will be applied which matches the current
        /// subschema version.
        /// If the subschema isn't present in the DB before this method gets called (i.e. its current version isn't present),
        /// the first step will be to apply the "Create" script (i.e. the script with an empty "from" version).
        /// If the subschema currently is at version A.B, potential update scripts are those with a
        /// "from" version of "A.*" or "A.B". "A.*" will be preferrably used. The DB update will take place with the script
        /// which was found (if any) and the next update step starts. If no more matching update script is found,
        /// the update terminates.
        /// </remarks>
        /// <param name="newVersionMajor">Returns the subschema major version after the execution of this method.</param>
        /// <param name="newVersionMinor">Returns the subschema minor version after the execution of this method.</param>
        /// <returns><c>true</c>, if the requested ,
        /// else <c>false</c>.</returns>
        public bool UpdateSubSchema(out int newVersionMajor, out int newVersionMinor)
        {
            IDatabaseManager databaseManager = ServiceRegistration.Get <IDatabaseManager>();
            int curVersionMajor = 0;
            int curVersionMinor = 0;

            try
            {
                // Create schema
                if (!databaseManager.GetSubSchemaVersion(_subSchemaName, out curVersionMajor, out curVersionMinor))
                {
                    CreateOperation createOperation = GetCreateOperation();
                    if (createOperation == null)
                    {
                        return(false); // No schema could be created
                    }
                    databaseManager.UpdateSubSchema(_subSchemaName, null, null,
                                                    createOperation.CreateScriptFilePath, createOperation.ToVersionMajor, createOperation.ToVersionMinor);
                    curVersionMajor = createOperation.ToVersionMajor;
                    curVersionMinor = createOperation.ToVersionMinor;
                }
                while (true)
                {
                    UpdateOperation nextOperation = GetUpdateOperation(curVersionMajor, curVersionMinor);
                    if (nextOperation == null)
                    {
                        break;
                    }
                    // Avoid busy loops on wrong input data
                    if (nextOperation.ToVersionMajor < curVersionMajor ||
                        (nextOperation.ToVersionMajor == curVersionMajor && nextOperation.ToVersionMinor < curVersionMinor))
                    {
                        throw new ArgumentException(string.Format("Update script '{0}' seems to decrease the schema version",
                                                                  nextOperation.UpdateScriptFilePath));
                    }
                    databaseManager.UpdateSubSchema(_subSchemaName, curVersionMajor, curVersionMinor,
                                                    nextOperation.UpdateScriptFilePath, nextOperation.ToVersionMajor, nextOperation.ToVersionMinor);
                    curVersionMajor = nextOperation.ToVersionMajor;
                    curVersionMinor = nextOperation.ToVersionMinor;
                }
                ServiceRegistration.Get <ILogger>().Info("DatabaseSubSchemaManager: Subschema '{0}' present in version {1}.{2}",
                                                         _subSchemaName, curVersionMajor, curVersionMinor);
                return(true);
            }
            finally
            {
                newVersionMajor = curVersionMajor;
                newVersionMinor = curVersionMinor;
            }
        }
Ejemplo n.º 10
0
        public async Task <IOperationResult> Create(CreateOperation <BlogPost> model)
        {
            try
            {
                _repository.Add(model.Entity);
                await _repository.SaveChangesAsync();

                return(OperationResult.Success);
            }
            catch (Exception ex)
            {
                return(OperationResult.Failed(ex.Message));
            }
        }
Ejemplo n.º 11
0
        public void Create_User_Throws()
        {
            // Arrange
            var user = new User(Guid.NewGuid().ToString())
            {
                FirstName = "Integration5",
                LastName  = "Test5",
                Email     = "*****@*****.**",
            };
            var operation = new CreateOperation <User>(adminId, user);
            // Act
            var result = _accountGrain.Create(operation).GetAwaiter().GetResult();

            // Assert
            Assert.True(result.Succeeded == false && result.Message != null);
        }
Ejemplo n.º 12
0
        public async Task GivenValidDataOperationShouldBeCreated()
        {
            var command = new CreateOperation
            {
                AccountID     = Guid.NewGuid(),
                CategoryID    = Guid.NewGuid(),
                Name          = "three",
                Value         = 10m,
                OperationType = OperationTypeEnum.Expense
            };
            var payload  = Payload(command);
            var response = await Client.PostAsync("operation", payload);

            response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.Created);
            response.Headers.Location.ToString().ShouldBeEquivalentTo($"operation/{command.Name}");

            var operation = await GetOperationAsync(command.Name);

            operation.Name.ShouldBeEquivalentTo(command.Name);
        }
Ejemplo n.º 13
0
        public async Task <IOperationResult> Create(CreateOperation <User> model)
        {
            try
            {
                if (_repository.Any <User>(x =>
                                           x.Email == model.Entity.Email || x.IdentityUserId == model.Entity.IdentityUserId))
                {
                    throw new Exception("User with the same properties already exists.");
                }

                _repository.Add(model.Entity);
                await _repository.SaveChangesAsync();

                return(OperationResult.Success);
            }
            catch (Exception ex)
            {
                return(OperationResult.Failed(ex.Message));
            }
        }
Ejemplo n.º 14
0
        public async Task <IOperationResult> Create(CreateOperation <User> model)
        {
            try
            {
                if (await _context.Set <User>().AnyAsync(x =>
                                                         x.Email == model.Entity.Email || x.IdentityUserId == model.Entity.IdentityUserId))
                {
                    throw new Exception("User with the same properties already exists.");
                }

                _context.Add(model.Entity);
                await _context.SaveChangesAsync();

                return(OperationResult.Success);
            }
            catch (Exception ex)
            {
                _logger?.LogError(ex);
                return(OperationResult.Failed(ex.Message));
            }
        }
Ejemplo n.º 15
0
        public void Verify_History_OnCreate()
        {
            // Arrange
            var user = new User(Guid.NewGuid().ToString())
            {
                FirstName = "Integration5",
                LastName  = "Test5",
                Email     = "*****@*****.**",
            };
            var operation = new CreateOperation <User>(adminId, user);

            // Act
            var result = _accountGrain.Create(operation).GetAwaiter().GetResult();

            // Assert
            Assert.True(result.Succeeded);


            var addedUser = _accountGrain.Find(user.Id).GetAwaiter().GetResult();

            var userEntityHistory = addedUser?.EntityHistory;

            Assert.True(userEntityHistory != null && userEntityHistory.Any());
        }
 /// <summary>
 /// Manually sets the creation script for the subschema of this subschema manager.
 /// </summary>
 /// <param name="createScriptFilePath">File path to the create script to set.</param>
 /// <param name="toVersionMajor">Major target version number of the specified create script.</param>
 /// <param name="toVersionMinor">Minor target version number of the specified create script.</param>
 public void SetCreateScript(string createScriptFilePath, int toVersionMajor, int toVersionMinor)
 {
     _createOperation = new CreateOperation(createScriptFilePath, toVersionMajor, toVersionMinor);
 }
 /// <summary>
 /// Manually sets the creation script for the subschema of this subschema manager.
 /// </summary>
 /// <param name="createScriptFilePath">File path to the create script to set.</param>
 /// <param name="toVersionMajor">Major target version number of the specified create script.</param>
 /// <param name="toVersionMinor">Minor target version number of the specified create script.</param>
 public void SetCreateScript(string createScriptFilePath, int toVersionMajor, int toVersionMinor)
 {
   _createOperation = new CreateOperation(createScriptFilePath, toVersionMajor, toVersionMinor);
 }
Ejemplo n.º 18
0
        public async Task <IActionResult> Post([FromBody] CreateOperation command)
        {
            await DispatchAsync(command);

            return(Created($"operation/{command.Name}", null));
        }
Ejemplo n.º 19
0
 public async Task <IOperationResult> Create(CreateOperation <FeedItem> model)
 {
     return(await CreateEntity(model.Entity, model.UserId));
 }
Ejemplo n.º 20
0
 public virtual object Create(CreateOperation value)
 {
     ResolveTypeAndInstance(value, out Type type, out object instance);
     return(Repository.Create(type, instance));
 }
Ejemplo n.º 21
0
        private static void InitOperationFactory(out CreateOperation[] createOperations)
        {
            createOperations = new CreateOperation[(int)EXamlOperationType.MAX];

            createOperations[(int)EXamlOperationType.GatherAssembly] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GatherAssembly(globalDataList, opInfo);
                globalDataList.PreLoadOperations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GatherType] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GatherType(globalDataList, opInfo);
                globalDataList.PreLoadOperations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GatherProperty] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GatherProperty(globalDataList, opInfo);
                globalDataList.PreLoadOperations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GatherEvent] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GatherEvent(globalDataList, opInfo);
                globalDataList.PreLoadOperations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GatherMethod] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GatherMethod(globalDataList, opInfo);
                globalDataList.PreLoadOperations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GatherBindableProperty] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GatherBindableProperties(globalDataList, opInfo);
                globalDataList.PreLoadOperations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.CreateObject] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new CreateObject(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.CreateArrayObject] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new CreateArrayObject(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.CreateDataTemplate] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new CreateDataTemplate(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GetStaticObject] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GetStaticObject(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GetTypeObject] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GetTypeObject(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GetObjectConvertedFromString] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GetObjectConvertedFromString(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GetEnumObject] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GetEnumObject(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GetObjectByProperty] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new GetObjectByProperty(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.SetProperty] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new SetProperty(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.SetBindableProperty] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new SetBindableProperty(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.SetBinding] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new SetBinding(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.SetDynamicResource] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new SetDynamicResource(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.AddEvent] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new AddEvent(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.AddObject] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new AddObject(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.AddToCollectionObject] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new AddToCollectionObject(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.AddToCollectionProperty] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new AddToCollectionProperty(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.AddToResourceDictionary] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new AddToResourceDictionary(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.RegisterXName] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                var operation = new RegisterXName(globalDataList, opInfo);
                globalDataList.Operations.Add(operation);
            };

            createOperations[(int)EXamlOperationType.GetLongString] = (GlobalDataList globalDataList, List <object> opInfo) =>
            {
                globalDataList.LongStrings = opInfo[0] as string;
            };
        }
Ejemplo n.º 22
0
 public async Task CreateOperationAsync(CreateOperation operation)
 {
     await PostRequestAsync(ApiRoutes.Operations, operation);
 }