private void CraateInsertDirectDespositCommand(Employee employee, DirectMethod directMethod) { string sql = "insert into DirectDepositAccount " + "values (@Bank, @Account, @EmpId)"; insertPaymentMethodCommand = new SqlCommand(sql); insertPaymentMethodCommand.Parameters.AddWithValue("@Bank", directMethod.Bank); insertPaymentMethodCommand.Parameters.AddWithValue("@Account", directMethod.Account); insertPaymentMethodCommand.Parameters.AddWithValue("@EmpId", employee.EmpId); }
/// <summary> /// Adds the method defined by direct native method. /// </summary> /// <param name="methodPath">The method path.</param> /// <param name="source">The source.</param> /// <param name="description">The description of method signature.</param> /// <returns>TestingAssembly.</returns> public TestingAssembly AddMethod(string methodPath, DirectMethod source, MethodDescription description) { var methodInfo = buildDescription(description, methodPath); var method = new DirectGenerator(source); addMethod(method, methodInfo, description.Implemented); return(this); }
/// <summary> /// Push call on stack of <see cref="Machine"/> that is invoked /// after all async methods are finished. /// </summary> /// <param name="callback">The callback called after async methods are finished.</param> protected void ContinuationCall(DirectMethod callback) { var callGenerator = new DirectedGenerator((e) => { e.DirectInvoke((c) => Invoke(c, callback) ); }); Context.DynamicCall("DirectAsyncCall", callGenerator, This); }
public DirectResult SolveSystem(ISystemEquations systemEquations, DirectMethod methods) { switch (methods) { case DirectMethod.Tridiag: return new TridiagonalMethod((TridiagonalSystemEquations)systemEquations).Solve(); case DirectMethod.Gauss: return new Gauss((DefaultSystemEquations)systemEquations).Solve(); default: return null; } }
/// <summary> /// Creates adapter for given method. /// </summary> /// <param name="method">The method.</param> internal void AdapterFor(MethodInfo method) { var paramsInfo = getParametersInfo(method); var methodTypeArguments = getTypeArguments(method); var returnInfo = getReturnType(method); var isAbstract = method.IsAbstract || _declaringDefinition.IsInterface; BuildedMethodInfo = new TypeMethodInfo( _declaringDefinition.TypeInfo, _methodName, returnInfo, paramsInfo, method.IsStatic, methodTypeArguments, isAbstract); Adapter = generateAdapter(method); }
/// <summary> /// Invokes the specified method in given context. /// </summary> /// <param name="context">The context.</param> /// <param name="methodToInvoke">The method to invoke.</param> internal void Invoke(AnalyzingContext context, DirectMethod methodToInvoke) { Context = context; Edits = context.Edits; try { This = CurrentArguments[0]; methodToInvoke(context); } finally { This = null; Context = null; Edits = null; } }
public void AddEmployeeTest_SaveDirectDepositMethod_InTransactional() { //Null values won't go in the database. DirectMethod method = new DirectMethod(null, null); employee.Method = method; try { database.AddEmployee(employee); Assert.Fail("An exception needs to occur " + "for this test to work"); } catch (SqlException) { } DataTable table = LoadTable("Employee"); Assert.AreEqual(0, table.Rows.Count); }
public void TestChangeDirectMethodTransaction() { int employeeId = 16; AddEmployTransaction aet = new AddSalariedEmployee(employeeId, "Bob", "Home", 1000.0); aet.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Method.Should().BeOfType <HoldMethod>(); ChangeDirectMethodTransaction cdmt = new ChangeDirectMethodTransaction(employeeId, "ctbc", "1234"); cdmt.Execute(); e = PayrollRepository.GetEmployee(employeeId); e.Method.Should().BeOfType <DirectMethod>(); DirectMethod dm = e.Method as DirectMethod; dm.Bank.Should().Be("ctbc"); dm.Account.Should().Be("1234"); }
public void TestChangeDirectTransaction() { int empId = 2; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25); t.Execute(); ChangeDirectTransaction mt = new ChangeDirectTransaction(empId, "b_test", "a_test"); mt.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.IsNotNull(e); PaymentMethod pm = e.Method; Assert.IsNotNull(pm); Assert.IsTrue(pm is DirectMethod); DirectMethod dm = pm as DirectMethod; Assert.AreEqual("b_test", dm.Bank); Assert.AreEqual("a_test", dm.Account); }
public void ExecuteTest() { int empId = 29; string bank = "MisBank"; string account = "3329"; AddEmployeeTransaction addSalEmp = new AddSalariedEmployee(empId, "kara", "samubola", 3000, database); addSalEmp.Execute(); ChangeMethodTranscation changeDirectTrans = new ChangeDirectTransaction(empId, bank, account, database); changeDirectTrans.Execute(); Employee emp = database.GetEmployee(empId); Assert.IsNotNull(emp); Assert.IsTrue(emp.Method is DirectMethod); DirectMethod directMethod = emp.Method as DirectMethod; Assert.IsNotNull(directMethod); Assert.AreEqual(directMethod.Bank, bank); Assert.AreEqual(directMethod.Account, account); }
/// <summary> /// Register call handler that will be called instead of methods on registered <see cref="Instance" />. /// </summary> /// <param name="registeredInstance">Instance that is registered.</param> /// <param name="handler">Method that will be called.</param> public void RegisterCallHandler(Instance registeredInstance, DirectMethod handler) { _manager.RegisterCallHandler(registeredInstance, handler); }
/// <summary> /// Emit direct invocation of given native method. /// </summary> /// <param name="method">The method.</param> public override void DirectInvoke(DirectMethod method) { emitInstruction(new DirectInvoke(method)); }
/// <summary> /// Register call handler that will be called instead of methods on registered <see cref="Instance" />. /// </summary> /// <param name="registeredInstance">Instance that is registered.</param> /// <param name="handler">Method that will be called.</param> internal void RegisterCallHandler(Instance registeredInstance, DirectMethod handler) { var generator = new DirectGenerator(handler); Loader.RegisterInjectedGenerator(registeredInstance, generator); }
/// <summary> /// Initialize method generator for methods defined in runtime type definitions. /// </summary> /// <param name="method">Method represented by this generator.</param> /// <param name="methodInfo">Info of represented method.</param> /// <param name="implementTypes">Types that are implemented by given method.</param> internal RuntimeMethodGenerator(DirectMethod method, TypeMethodInfo methodInfo, IEnumerable <Type> implementTypes) { MethodInfo = methodInfo; ImplementTypes = implementTypes; _method = method; }
/// <summary> /// Initializes a new instance of the <see cref="DirectGenerator"/> class. /// </summary> /// <param name="directMethod">The method that will be generated.</param> public DirectGenerator(DirectMethod directMethod) { _method = directMethod; }
/// <summary> /// Emit direct invokation of given native method. /// </summary> /// <param name="method">The method.</param> public abstract void DirectInvoke(DirectMethod method);
/// <summary> /// Invokes the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="method">The method.</param> /// <param name="adapter">The adapter.</param> /// <param name="definition">The definition.</param> private static void invoke(AnalyzingContext context, TypeMethodInfo method, DirectMethod adapter, RuntimeTypeDefinition definition) { definition.Invoke(context, adapter); }
public IEnumerable<DirectResult> SolveSystems( IEnumerable<ISystemEquations> systemEquations, DirectMethod directMethod) { return systemEquations.Select(systemEquation => SolveSystem(systemEquation, directMethod)); }
/// <summary> /// Registers the call handler. /// </summary> /// <param name="registeredInstance">The registered instance.</param> /// <param name="registeredMethod">The registered method.</param> internal void RegisterCallHandler(Instance registeredInstance, DirectMethod registeredMethod) { _services.RegisterCallHandler(registeredInstance, registeredMethod); }
/// <summary> /// Adds the binary predicate. /// </summary> /// <param name="methodName">Name of the operator method.</param> /// <param name="directOperator">The direct operator.</param> private void addBinaryPredicate(string methodName, DirectMethod directOperator) { var method = binaryInfo(methodName, TypeDescriptor.Create <bool>()); AddMethod(directOperator, method); }
/// <summary> /// Initializes a new instance of the <see cref="DirectInvoke" /> class. /// </summary> /// <param name="method">The method.</param> public DirectInvoke(DirectMethod method) { _method = method; }