如何基于使用f#中的类型定义的对象生成新的不可变对象?

时间:2016-06-17 15:24:53

标签: f#

我有这个代码不能正常工作

ImageButton save = (ImageButton) findViewById(R.id.save);
save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String state = Environment.getExternalStorageState();
                if (!Environment.MEDIA_MOUNTED.equals(state)) {
                    Toast.makeText(PDFGoster.this,"You cannot do that.",Toast.LENGTH_LONG).show();
                }

                File pdfDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), 
                        "MyList");
                if (!pdfDir.exists()){
                    pdfDir.mkdir();
                }

                LayoutInflater inflater = (LayoutInflater) PDFGoster.this.getSystemService(LAYOUT_INFLATER_SERVICE);
                RelativeLayout root = (RelativeLayout) inflater.inflate(R.layout.pdf, null);
                root.setDrawingCacheEnabled(true);
                Bitmap screen= getBitmapFromView(PDFGoster.this.getWindow().findViewById(R.id.tabla_cuerpo));
                File pdfFile = new File(pdfDir, "MyList.pdf");

                try {
                    Document document = new Document();

                    PdfWriter.getInstance(document, new FileOutputStream(pdfFile));
                    document.open();
                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    screen.compress(Bitmap.CompressFormat.PNG, 100, stream);
                    byte[] byteArray = stream.toByteArray();
                    addImage(document,byteArray);
                    document.close();
                }
                catch (Exception e){
                    e.printStackTrace();
                }

                Intent intent = new Intent("android.intent.action.OPEN_DOCUMENT");
                Uri uri = Uri.fromFile(new File(pdfDir,  "MyList"));
                intent.setDataAndType(uri, "application/pdf");
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

                Toast.makeText(PDFGoster.this, "List successfully created", Toast.LENGTH_LONG).show();
                startActivity(intent);
            }
        });

我收到错误 SELECT * FROM ( TABLE_QUERY(YourDataset, 'LEFT(table_id, 4) = "abc_" AND LENGTH(table_id) = 14 AND CONCAT(SUBSTR(table_id,11,4),'-',SUBSTR(table_id,5,2), -",SUBSTR(table_id,8,2)) BETWEEN "2016-01-01" AND "2016-03-12"') )

1 个答案:

答案 0 :(得分:4)

您定义的对象是标准.NET class,而不是record。如果您想使用with语法,则应将其定义为:

type Option  = {XsdLocation : string; XmlDirectory : string}

let a1 = {XsdLocation = "xsd"; XmlDirectory = "xml"}
let a2 = {a1 with XsdLocation = "xsd2"}

PS:我还建议为您的类型选择Option以外的名称,因为Option是内置类型。