public static IArithmeticsController GetArithmeticsController(this IMatrixData matrixData) { var matrixDataType = matrixData.GetType(); if (matrixDataType == typeof(UnsafeRGBMatrixData)) { return(new UnsafeRGBMatrixDataArithmetics()); } if (matrixDataType == typeof(IntegerNumberMatrixData)) { return(new IntegerNumberMatrixDataArithmetics()); } if (matrixDataType == typeof(FloatNumberMatrixData)) { return(new FloatNumberMatrixDataArithmetics()); } throw new NotImplementedException(); }