private InvocationExpressionSyntax InvokeTyped(CommandBase command, CheckDescription desc) { var types = desc.MethodTypeArgumentsEvaluator(command); foreach (var type in types) { EnsureUsing(type); } if (types.Length == 1) { return(InvocationExpression(GenericName(desc.Method.Name) .WithTypeArgumentList( TypeArgumentList( SingletonSeparatedList <TypeSyntax>( IdentifierName(types[0].Name)))))); } else { var typeParams = SeparatedList <TypeSyntax>(types.Select(x => IdentifierName(x.Name))); return(InvocationExpression(GenericName(desc.Method.Name) .WithTypeArgumentList( TypeArgumentList(typeParams)))); } }
private InvocationExpressionSyntax ProduceInvoke(CommandBase command, CheckDescription desc) { EnsureUsingStatic(desc.Method); if (desc.Method.IsGenericMethodDefinition) { return(InvokeTyped(command, desc)); } return(InvokeSimple(desc)); }
private IEnumerable<ExpressionSyntax> ProduceArguments(CommandBase command, CheckDescription desc) { var args = desc.GetCheckParameters(command); foreach (var o in args) { if (o is CommandExtractCheckParameter cecp) { yield return ExtractFromCommand(command, cecp); } if (o is AssertionCheckParameter acp) { yield return MakeAssertions(command, acp); } } }
private InvocationExpressionSyntax Generate(CommandBase command, CheckDescription desc) { var result = ProduceInvoke(command, desc); var args = ProduceArguments(command, desc).ToArray(); if (args.Length > 0) { result = result.WithArgumentList(ArgumentList(SeparatedList(args.Select(Argument)))); } foreach (var descAdditionalUsing in desc.AdditionalUsings) { EnsureUsing(descAdditionalUsing); } return(result); }
private InvocationExpressionSyntax InvokeSimple(CheckDescription desc) { return(InvocationExpression(IdentifierName(desc.Method.Name))); }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((IInvoicePaymentViewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } ((InvoicePayment)ActiveDBItem).DBCommonTransactionType = CommonTransactionType; switch (PaymentViewerType) { case PaymentViewerType.MedicalInvoicePayment: if (((Invoice)Invoice) != null) { ((InvoicePayment)ActiveDBItem).InvoiceID = ((Invoice)Invoice).ID; } break; case PaymentViewerType.PatientDepositPayment: if (((Patient_cu)Patient) != null) { ((InvoicePayment)ActiveDBItem).Patient_CU_ID = ((Patient_cu)Patient).ID; } break; } ((InvoicePayment)ActiveDBItem).Date = Convert.ToDateTime(PaymentDate); ((InvoicePayment)ActiveDBItem).Amount = Convert.ToBoolean(IsRefund) ? Convert.ToDouble(PaymentAmount) * -1 : Convert.ToDouble(PaymentAmount); if (Math.Abs(((InvoicePayment)ActiveDBItem).Amount) < 0.0001) { return(false); } ((InvoicePayment)ActiveDBItem).PaymentType_P_ID = Convert.ToInt32(PaymentTypeID); if (PaymentSerial != null) { ((InvoicePayment)ActiveDBItem).PaymentSerial = PaymentSerial.ToString(); } ((InvoicePayment)ActiveDBItem).IsOnDuty = true; if (InvoicePaymentDescription != null) { ((InvoicePayment)ActiveDBItem).Description = InvoicePaymentDescription.ToString(); } if (UserID != null) { ((InvoicePayment)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID); } DB_PaymentType paymentType = (DB_PaymentType)PaymentTypeID; switch (paymentType) { case DB_PaymentType.CheckPayment: InvoicePayment_Check checkPayment = new InvoicePayment_Check(); checkPayment.Bank_CU_ID = Convert.ToInt32(BankID_CheckPayment); if (BankAccountID_CheckPayment != null) { checkPayment.BankAccoumt_CU_ID = Convert.ToInt32(BankAccountID_CheckPayment); } if (CheckIssueDate_CheckPayment != null) { checkPayment.IssueDate = Convert.ToDateTime(CheckIssueDate_CheckPayment); } if (CheckExhangeDate_CheckPayment != null) { checkPayment.ExchangeDate = Convert.ToDateTime(CheckExhangeDate_CheckPayment); } if (CheckNumber_CheckPayment != null) { checkPayment.CheckNumber = CheckNumber_CheckPayment.ToString(); } if (CheckDescription != null) { checkPayment.Description = CheckDescription.ToString(); } ((InvoicePayment)ActiveDBItem).InvoicePayment_Check = checkPayment; if (UserID != null) { (((InvoicePayment)ActiveDBItem).InvoicePayment_Check).InsertedBy = Convert.ToInt32(UserID); } break; case DB_PaymentType.VisaPayment: InvoicePayment_Visa visaPayment = new InvoicePayment_Visa(); if (BankID_VisaPayment != null) { visaPayment.Bank_CU_ID = Convert.ToInt32(BankID_VisaPayment); } if (BankAccountID_VisaPayment != null) { visaPayment.BankAccount_CU_ID = Convert.ToInt32(BankAccountID_VisaPayment); } if (VisaCardNumber_VisaPayment != null) { visaPayment.CreditCardNumber = VisaCardNumber_VisaPayment.ToString(); } if (VisaDescription != null) { visaPayment.Description = VisaDescription.ToString(); } ((InvoicePayment)ActiveDBItem).InvoicePayment_Visa = visaPayment; if (UserID != null) { (((InvoicePayment)ActiveDBItem).InvoicePayment_Visa).InsertedBy = Convert.ToInt32(UserID); } break; } return(true); }