2using System.Collections.Generic;
35 throw new NotSupportedException(
"An resource instance must be " +
36 "supplied to determine what its default target currency would be.");
38 return asLayerView.target_currency ??
39 GetDefaultFromLayer(asLayerView.layer, asLayerView.analysis_profile);
41 return ov.analysis_profile.GetValue()?.exchange_rate_profile.GetValue()
42 .exchange_rate_table.GetValue().base_currency;
44 throw new NotSupportedException(
"Unexpected APIResourceView type: " +
45 resource.GetType().NiceTypeName() +
". Could not determine the " +
46 "default target currency.");
48 IEnumerable<string> currencies;
50 if (pv.portfolio !=
null)
51 currencies = pv.portfolio.GetValue().layers
52 .Select(layer => GetDefaultFromLayer(layer.GetValue(), pv.analysis_profile));
54 else if (pv.layer_views !=
null && pv.layer_views.Any())
57 throw new NotSupportedException(
"PortfolioView is invalid.");
59 return currencies.GroupBy(ccy => ccy)
60 .Select(group =>
new { ccy = group.Key, count = group.Count() })
61 .OrderByDescending(group => group.count)
62 .Select(group => group.ccy).First();
71 private static string GetDefaultFromLayer(
ILayer layer,
75 throw new NotSupportedException(
"The layer reference that determines " +
76 "the default target currency is null.");
78 return aggregateQuotaShare.aggregate_limit.currency;
79 if (layer is
AggXL aggXL)
80 return aggXL.aggregate_limit.currency;
81 if (layer is
CatXL catXL)
82 return catXL.limit.currency;
84 return quotaShare.event_limit.currency;
86 return surplusShare.retained_line.currency;
88 return industryLossWarranty.payout.currency;
89 if (layer is
Nested nested)
92 return sinkValue is
ILayer asLayer ? GetDefaultFromLayer(asLayer, analysis_profile) :
97 IAPIResource sourceValue = valueAllocator.source.GetValue();
98 return sourceValue is
ILayer asLayer ? GetDefaultFromLayer(asLayer, analysis_profile) :
103 IAPIResource sinkValue = backAllocatedLayer.sink.GetValue();
104 return sinkValue is
ILayer asLayer ? GetDefaultFromLayer(asLayer, analysis_profile) :
108 return analysis_profile.
GetValue().exchange_rate_profile.GetValue()
109 .exchange_rate_table.GetValue().base_currency;
111 return fixedRateCurrency.out_currency;
113 return noClaimsBonus.payout_amount.currency;
114 throw new NotSupportedException(
"Unexpected layer type: " + layer.GetType() +
115 ". Could not determine the default target currency.");
Attribute used to define the default value assigned to the target_currency property by the server whe...
static string GetDefaultTargetCurrency(IAPIResource resource)
Determine what the default target currency will be based on the resource type and properties.
TargetCurrencyDefault()
Attribute which can determine the server-generated default target currency assigned to a IAPIResource...
override object GetDefaultValue(object owner)
Returns the expected default value for the property based on the owner.
Indicates that the property, if left null, will have a default value generated and filled in by the s...
Representation of an Aggregate Catastrophe Excess of Loss layer.
Representation of a Quota Share contract that is limited in annual payouts.
Acts as a replacement for IAPIResourceView.back_allocations. Computes the proportion of some sink str...
Representation of a Catastrophe Excess of Loss (CatXL) layer.
A "delayed payment" payment pattern models claims being paid in instalments at fixed delays after the...
Filter is like a layer whose 'terms' are to filter events out of the loss sources....
A "delayed payment" payment pattern models claims being paid in instalments at specific dates followi...
A structure that can be used to change the currency of a loss stream from one currency to another at ...
Representation of an Industry Loss Warranty, which is a layer that triggers a payout (currently expre...
The LossRank layer allows one to select a subset of occurrences in a trial year based on the relative...
Allows one or more source layers or layer_views to be attached as loss sources to some other layer de...
The No Claims Bonus applies a payout to trials which contain no losses. (i.e. when there are no occur...
Representation of a Quota Share contract.
Representation of a Surplus Share contract.
Surfaces the value-allocator specialty structure (which is treated as a "layer definition" by the API...
Representation of a set of Optimization Parameters.
Represents the Analysis of a Portfolio.
Interface for Base class used by all resources.
Represents the Analysis of a Layer.
Abstract representation of a layer.
Base interface for all reference entities.
T GetValue(IEnumerable< Parameter > requestParameters=null, int? timeout=null, bool updateCache=false)
Gets the resource that this reference refers to by requesting it from the server.