コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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;
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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");
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 /// <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);
 }
コード例 #12
0
ファイル: CallEmitter.cs プロジェクト: m9ra/MEFEditor_v2.0
 /// <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));
 }
コード例 #13
0
        /// <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);
        }
コード例 #14
0
 /// <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;
 }
コード例 #15
0
 /// <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;
 }
コード例 #16
0
 /// <summary>
 /// Emit direct invokation of given native method.
 /// </summary>
 /// <param name="method">The method.</param>
 public abstract void DirectInvoke(DirectMethod method);
コード例 #17
0
 /// <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);
 }
コード例 #18
0
 public IEnumerable<DirectResult> SolveSystems(
     IEnumerable<ISystemEquations> systemEquations,
     DirectMethod directMethod)
 {
     return systemEquations.Select(systemEquation => SolveSystem(systemEquation, directMethod));
 }
コード例 #19
0
 /// <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);
 }
コード例 #20
0
ファイル: MathDirectType.cs プロジェクト: m9ra/MEFEditor_v2.0
        /// <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);
        }
コード例 #21
0
ファイル: DirectInvoke.cs プロジェクト: m9ra/MEFEditor_v2.0
 /// <summary>
 /// Initializes a new instance of the <see cref="DirectInvoke" /> class.
 /// </summary>
 /// <param name="method">The method.</param>
 public DirectInvoke(DirectMethod method)
 {
     _method = method;
 }