public explicit_preCH(TTuple types_in, VBoxTU _dataSrc) { _types = types_in; this._dataSrc = _dataSrc; // since this is bijective, there is no point in deferring creation _CH = Instantiate(types_in, dataSrc); }
} // usage relies on preCH -> CH (by object instance) to be a pure function. that is, assign underlying field at most once, if any public static TypedCH Instantiate(TTuple ttuple, VBoxTU dataSrc) { Type closedType; if (ttuple.isMulti) { closedType = typeof(TypedMultiCH <>).MakeGenericType(new [] { ttuple.PayT }); } else { closedType = typeof(TypedSingleCH <>).MakeGenericType(new [] { ttuple.PayT }); } var instance = (TypedCH)Activator.CreateInstance(closedType); instance.GetType().GetProperty("pred_SrcVBXTU").SetValue(instance, dataSrc, new SObject[0]); // guess return(instance); }
void init() { _types = TypeCalcEdges(); _CH = Instantiate(_types, dataSrc); // <- das isses }