public static unsafe Data GetData() { var dataNative = default(DataNative *); try { dataNative = DataNative.New(); return(dataNative->ToManaged()); } finally { DataNative.Free(dataNative); } }
public static unsafe Data ToManaged(this DataNative data) { var parameters = new List <double>(); var objectives = new List <double>(); var managedData = new Data { Objective = data.objective, Objectives = objectives, Parameters = parameters }; for (int i = 0; i < data.parameterCount; ++i) { parameters.Add(data.paramters[i]); } for (int i = 0; i < data.objectiveCount; ++i) { objectives.Add(data.objectives[i]); } return(managedData); }