コード例 #1
0
 public void SetCurrentImportContextFactory()
 {
     try
     {
         ImportContextFactoryHandler factory = new ImportContextFactoryHandler(CreateImportContext);
         JsonConvert.CurrentImportContextFactory = factory;
         Assert.AreSame(factory, JsonConvert.CurrentImportContextFactory);
         JsonConvert.CreateImportContext();
         Assert.IsTrue(_createImportContextCalled);
     }
     finally
     {
         JsonConvert.CurrentImportContextFactory = JsonConvert.DefaultImportContextFactory;
     }
 }
コード例 #2
0
 public void SetCurrentImportContextFactory()
 {
     try
     {
         var called = false;
         Func <ImportContext> factory = () => { called = true; return(null); };
         JsonConvert.CurrentImportContextFactory = factory;
         Assert.AreSame(factory, JsonConvert.CurrentImportContextFactory);
         JsonConvert.CreateImportContext();
         Assert.IsTrue(called);
     }
     finally
     {
         JsonConvert.CurrentImportContextFactory = JsonConvert.DefaultImportContextFactory;
     }
 }