I have a TransactionData2ClassAction
subclass which looks something like this:
public class TransactionData2ClassAction : Entity
{
public int TransactionId => Get<int>();
public int FundId => Get<int>();
public string PortfolioCode => Get<string>();
public string SecuritySymbol => Get<string>();
public string SecurityTypeCode => Get<string>();
public DateTime TradeDate => Get<DateTime>();
public DateTime? SettleDate => Get<DateTime?>();
public decimal Quantity => Get<decimal>();
public decimal Amount => Get<decimal>();
public decimal SecFee => Get<decimal>();
public string BrokerCode => Get<string>();
public short TaxLotNumber => Get<short>();
public string TransactionCode => Get<string>();
public decimal CommissionAmount => Get<decimal>();
public int TestProperty { get; }
}
The Entity
base class looks something like this:
public class Entity : INotifyPropertyChanged, IDataErrorInfo
{
protected T Get<T>([CallerMemberName] string aColumnName = null, DataRowVersion? aDataRowVersion = null)
{
// Details.
}
protected string Get(CompressionEncryptionOptions aOption, [CallerMemberName] string aColumnName = null)
{
// Details.
}
}
My questions is how do I return properties who's getters use either of the Entity
base class Get
methods?
For example, the result would return all properties except TestProperty
.
I have this so far:
public static PropertyInfo[] GetTransactionData2FieldsFromEntityUsingProperties(Type aEntityType)
{
if (!aEntityType.IsSubclassOf(typeof(Entity)))
throw new InvalidOperationException("Wrong type.");
return aEntityType.GetProperties().Where(aProperty => aProperty.CanRead && aProperty.GetAccessors().Any(aMethodInfo => aMethodInfo.IsAssembly || aMethodInfo.IsPublic)).ToArray();
}
Aucun commentaire:
Enregistrer un commentaire