This commit is contained in:
parent
735fd44ee1
commit
4bf3599d79
|
@ -10,7 +10,7 @@ namespace MapTo.Extensions
|
||||||
{
|
{
|
||||||
internal static SourceCode GenerateStructOrClass(this MappingModel model, string structOrClass)
|
internal static SourceCode GenerateStructOrClass(this MappingModel model, string structOrClass)
|
||||||
{
|
{
|
||||||
const bool writeDebugInfo = false;
|
const bool writeDebugInfo = true;
|
||||||
|
|
||||||
using var builder = new SourceBuilder()
|
using var builder = new SourceBuilder()
|
||||||
.WriteLine(GeneratedFilesHeader)
|
.WriteLine(GeneratedFilesHeader)
|
||||||
|
@ -88,7 +88,15 @@ namespace MapTo.Extensions
|
||||||
return builder.WriteClosingBracket();
|
return builder.WriteClosingBracket();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsMappedProperty(this System.Collections.Immutable.ImmutableArray<MappedProperty> properties, MappedProperty property) => properties.Contains(property);
|
private static bool IsMappedProperty(this System.Collections.Immutable.ImmutableArray<MappedProperty> properties, MappedProperty property) {
|
||||||
|
|
||||||
|
foreach(var prop in properties)
|
||||||
|
{
|
||||||
|
if (prop.FullyQualifiedType == property.FullyQualifiedType) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static SourceBuilder TryWriteProperties(this SourceBuilder builder, System.Collections.Immutable.ImmutableArray<MappedProperty> properties, System.Collections.Immutable.ImmutableArray<MappedProperty>? otherProperties,
|
private static SourceBuilder TryWriteProperties(this SourceBuilder builder, System.Collections.Immutable.ImmutableArray<MappedProperty> properties, System.Collections.Immutable.ImmutableArray<MappedProperty>? otherProperties,
|
||||||
string? sourceClassParameterName, string mappingContextParameterName, bool fromUpdate)
|
string? sourceClassParameterName, string mappingContextParameterName, bool fromUpdate)
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
using System;
|
||||||
|
using MapTo;
|
||||||
|
|
||||||
|
namespace BlueWest.Data
|
||||||
|
{
|
||||||
|
public enum FinanceSymbol
|
||||||
|
{
|
||||||
|
BTC_EUR,
|
||||||
|
BTC_BUSD,
|
||||||
|
BTC_USD,
|
||||||
|
BTC_USDT,
|
||||||
|
LTC_EUR,
|
||||||
|
LTC_BUSD,
|
||||||
|
LTC_USDT
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum FinanceTransactionType
|
||||||
|
{
|
||||||
|
Buy,
|
||||||
|
Sell
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial struct FinanceTransaction
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public FinanceTransactionType FinanceTransactionType { get; }
|
||||||
|
public FinanceSymbol FinanceSymbol { get; }
|
||||||
|
public double Amount { get; } // To Buy
|
||||||
|
public double Quantity { get; } // Bought
|
||||||
|
public double Fee { get; }
|
||||||
|
public DateTime DateTime { get; }
|
||||||
|
|
||||||
|
|
||||||
|
public FinanceTransaction(int id, int userId, FinanceTransactionType financeTransactionType,
|
||||||
|
FinanceSymbol financeSymbol, double amount, double quantity, double fee, DateTime dateTime)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
UserId = userId;
|
||||||
|
FinanceTransactionType = financeTransactionType;
|
||||||
|
FinanceSymbol = financeSymbol;
|
||||||
|
Amount = amount;
|
||||||
|
Quantity = quantity;
|
||||||
|
Fee = fee;
|
||||||
|
DateTime = dateTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using MapTo;
|
||||||
|
|
||||||
|
namespace BlueWest.Data
|
||||||
|
{
|
||||||
|
[MapFrom(typeof(FinanceTransaction))]
|
||||||
|
|
||||||
|
public partial struct FinanceTransactionReadDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public FinanceTransactionType FinanceTransactionType { get; }
|
||||||
|
public FinanceSymbol FinanceSymbol { get; }
|
||||||
|
public double Amount { get; } // To Buy
|
||||||
|
public double Quantity { get; } // Bought
|
||||||
|
public double Fee { get; }
|
||||||
|
public DateTime DateTime { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
using System;
|
|
||||||
using TestConsoleApp.ViewModels;
|
|
||||||
using MapTo;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace TestConsoleApp.Data.Models
|
|
||||||
{
|
|
||||||
[MapFrom(typeof(UserViewModel))]
|
|
||||||
public partial struct User
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public List<List<string>> ListOfListOfString {get; }
|
|
||||||
|
|
||||||
public List<string> StringList { get; }
|
|
||||||
public DateTimeOffset RegisteredAt { get; set; }
|
|
||||||
|
|
||||||
public User( int id, List<List<string>> listOfListOfString, List<string> stringList, DateTimeOffset registeredAt)
|
|
||||||
{
|
|
||||||
this.StringList = stringList;
|
|
||||||
this.Id = id;
|
|
||||||
ListOfListOfString = listOfListOfString;
|
|
||||||
RegisteredAt = registeredAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MapTo;
|
||||||
|
|
||||||
|
|
||||||
|
namespace BlueWest.Data
|
||||||
|
{
|
||||||
|
[MapFrom(typeof(UserUpdateDto))]
|
||||||
|
public partial struct User
|
||||||
|
{
|
||||||
|
public int Id { get; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
|
||||||
|
public string BTCAddress { get; set; }
|
||||||
|
public string LTCAddress { get; set; }
|
||||||
|
|
||||||
|
public double BTCAmount { get; set; }
|
||||||
|
public double LTCAmount { get; set; }
|
||||||
|
|
||||||
|
public List<FinanceTransaction> FinanceTransactions { get; set; }
|
||||||
|
|
||||||
|
public User(int id, string name, string address, string btcAddress, string ltcAddress, double btcAmount, double ltcAmount, List<FinanceTransaction> financeTransactions)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Name = name;
|
||||||
|
Address = address;
|
||||||
|
BTCAddress = btcAddress;
|
||||||
|
LTCAddress = ltcAddress;
|
||||||
|
BTCAmount = btcAmount;
|
||||||
|
LTCAmount = ltcAmount;
|
||||||
|
FinanceTransactions = financeTransactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddTransaction(FinanceTransaction financeTransaction)
|
||||||
|
{
|
||||||
|
FinanceTransactions.Add(financeTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BlueWest.Data
|
||||||
|
{
|
||||||
|
public class UserList
|
||||||
|
{
|
||||||
|
public List<User> Users;
|
||||||
|
|
||||||
|
public UserList(List<User> users)
|
||||||
|
{
|
||||||
|
Users = users;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int Length => Users.Count;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using MapTo;
|
||||||
|
|
||||||
|
namespace BlueWest.Data
|
||||||
|
{
|
||||||
|
[MapFrom(typeof(User))]
|
||||||
|
|
||||||
|
public partial struct UserUpdateDto
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
|
||||||
|
public string BTCAddress { get; set; }
|
||||||
|
public string LTCAddress { get; set; }
|
||||||
|
|
||||||
|
public double BTCAmount { get; set; }
|
||||||
|
public double LTCAmount { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using BlueWest.Data;
|
||||||
using MapTo;
|
using MapTo;
|
||||||
using TestConsoleApp.Data.Models;
|
using TestConsoleApp.Data.Models;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue