Clearsilver.CSTContext.registerFileLoad C# (CSharp) Method

registerFileLoad() public method

public registerFileLoad ( loadFileDelegate fn ) : void
fn loadFileDelegate
return void
        public unsafe void registerFileLoad(loadFileDelegate fn)
        {
            if (fn != null) {
               // set the fileload handler
               cur_delegate = fn;
               thunk_delegate = new CSFILELOAD(csFileLoad);

               cs_register_fileload(csp, null, thunk_delegate);
               } else {
               // clear the fileload handler
               cs_register_fileload(csp, null, null);
               cur_delegate = null;
               thunk_delegate = null;
               }
        }

Usage Example

Example #1
0
    public static int Main(string[] argv)
    {
        Hdf h = new Hdf();

          h.setValue("foo.1","1");
          h.setValue("foo.2","2");

          h.registerFileLoad(new Hdf.loadFileDelegate(loadFileHandler));

          h.readFile("test.hdf");

          Console.WriteLine("foo.2 = {0}", h.getValue("foo.2","def"));

          CSTContext cs = new CSTContext(h);

          Console.WriteLine("parsing file");
          h.setValue("hdf.loadpaths.0", ".");
          cs.registerFileLoad(new CSTContext.loadFileDelegate(loadFileHandler));
          try {
          cs.parseFile("test.cst");
          } catch (NeoException e) {
          Console.WriteLine("error: {0}", e.reason);
          Console.WriteLine("tb: {0}", e.full_traceback);
          }

          // cs.parseString(" foo.1 = <?cs var:foo.1 ?> ");
          // cs.parseString("this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ .");

          Console.WriteLine("render file");
          Console.WriteLine(cs.render());
          return 0;
    }