C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
LayerViews.cs
Go to the documentation of this file.
1using System;
3
4// ReSharper disable once CheckNamespace (Static Class Replaces Namespace)
5namespace AnalyzeRe
6{
8 public static class LayerViews
9 {
11 public static readonly string CLASS_COLLECTION_NAME = "layer_views";
12
13 private static readonly Type GenericLayerViewContainer = typeof(LayerView<>);
14
15 #region Static Factory Functions
23 public static ILayerView<T> Create<T>(T layer,
24 IReference<AnalysisProfile> analysisProfile,
25 string targetCurrency = null)
26 where T : ILayer
27 {
28 Type layer_type = layer.GetType();
29 if (typeof(T) == layer_type)
30 {
31 return new LayerView<T>
32 {
33 layer = layer,
34 analysis_profile = analysisProfile,
35 target_currency = targetCurrency
36 };
37 }
38 // If the compile time type used to invoke this method is weak, we still
39 // want to create a strongly typed generic container, so we need to create one
40 // using reflection.
41 Type subType = GenericLayerViewContainer.MakeGenericTypeFast(layer_type);
42 return (ILayerView<T>)Activator.CreateInstance(subType,
43 new object[] { Convert.ChangeType(layer, layer_type), analysisProfile, targetCurrency });
44 }
45
53 public static ILayerView<T> Create<T>(T layer,
54 AnalysisProfile analysisProfile,
55 string targetCurrency = null)
56 where T : ILayer
57 => Create(layer, analysisProfile?.ToReference(), targetCurrency);
58 #endregion Static Factory Functions
59 }
60}
A configuration of resources used to simulate a layer or portfolio.
Represents the Analysis of a Layer.
LayerView factory class.
Definition LayerViews.cs:9
static ILayerView< T > Create< T >(T layer, IReference< AnalysisProfile > analysisProfile, string targetCurrency=null)
Create a new generically typed LayerView.
Definition LayerViews.cs:23
static readonly string CLASS_COLLECTION_NAME
The collection endpoint at which resources of this type reside on the server.
Definition LayerViews.cs:11
Represents the Analysis of a Layer.
Abstract representation of a layer.
Definition ILayer.cs:7
Base interface for all reference entities.