private void AddContainerViews() { FrameLayout v = new FrameLayout(Context); ViewCollection.Add(v); AddView(v); }
public void GetOrAdd_IgnoresCachedValueIfFileIsIdentical_ButViewStartWasDeletedSinceCacheWasCreated() { // Arrange var expectedType = typeof(RuntimeCompileDifferent); var lastModified = DateTime.UtcNow; var fileSystem = new TestFileSystem(); var viewCollection = new ViewCollection(); var precompiledView = viewCollection.FileInfos[0]; precompiledView.RelativePath = "Views\\Index.cshtml"; var viewFileInfo = new TestFileInfo { Content = new PreCompile().Content, LastModified = precompiledView.LastModified, PhysicalPath = precompiledView.RelativePath }; fileSystem.AddFile(viewFileInfo.PhysicalPath, viewFileInfo); var viewStartFileInfo = new TestFileInfo { PhysicalPath = "Views\\_ViewStart.cshtml", Content = "viewstart-content", LastModified = lastModified }; var viewStart = new RazorFileInfo { FullTypeName = typeof(RuntimeCompileIdentical).FullName, RelativePath = viewStartFileInfo.PhysicalPath, LastModified = viewStartFileInfo.LastModified, Hash = RazorFileHash.GetHash(viewStartFileInfo), Length = viewStartFileInfo.Length }; fileSystem.AddFile(viewStartFileInfo.PhysicalPath, viewStartFileInfo); viewCollection.Add(viewStart); var cache = new CompilerCache(new[] { viewCollection }, fileSystem); var fileInfo = new RelativeFileInfo(viewFileInfo, viewFileInfo.PhysicalPath); // Act 1 var actual1 = cache.GetOrAdd(fileInfo, compile: _ => { throw new Exception("should not be called"); }); // Assert 1 Assert.Equal(typeof(PreCompile), actual1.CompiledType); // Act 2 fileSystem.DeleteFile(viewStartFileInfo.PhysicalPath); var actual2 = cache.GetOrAdd(fileInfo, compile: _ => CompilationResult.Successful(expectedType)); // Assert 2 Assert.Equal(expectedType, actual2.CompiledType); }
/// <summary> /// Create the views of this content. /// </summary> /// <param name="doc">The <see cref="Document"/> object this content is associated with.</param> /// <returns>A <see cref="ViewCollection"/> object containing the views.</returns> public ViewCollection GetContentViews(Document doc) { var views = new ViewCollection(); foreach (Imaging dataSet in this.contentList) { var view = new ViewImage(doc, dataSet, dataSet.Name, dataSet.ExperimentType); views.Add(view); } return(views); }
/// <summary> /// Create the views of this content. /// </summary> /// <param name="doc">The <see cref="Document"/> object this content is associated with.</param> /// <returns>A <see cref="ViewCollection"/> object containing the views.</returns> public ViewCollection GetContentViews(Document doc) { ViewCollection views = new ViewCollection(); foreach (Imaging dataSet in contentList) { ViewImage view = new ViewImage(doc, dataSet, dataSet.Name); ViewImageController viewCtrl = new ViewImageController(doc, view); views.Add(view); } return(views); }
public void GetOrAdd_UsesValueFromCache_IfGlobalHasNotChanged() { // Arrange var instance = new PreCompile(); var length = Encoding.UTF8.GetByteCount(instance.Content); var fileProvider = new TestFileProvider(); var lastModified = DateTime.UtcNow; var fileInfo = new TestFileInfo { Length = length, LastModified = lastModified, Content = instance.Content }; fileProvider.AddFile(ViewPath, fileInfo); var globalContent = "global-content"; var globalFileInfo = new TestFileInfo { Content = globalContent, LastModified = DateTime.UtcNow }; fileProvider.AddFile("_ViewImports.cshtml", globalFileInfo); var globalRazorFileInfo = new RazorFileInfo { Hash = Crc32.Calculate(GetMemoryStream(globalContent)).ToString(CultureInfo.InvariantCulture), HashAlgorithmVersion = 1, LastModified = globalFileInfo.LastModified, Length = globalFileInfo.Length, RelativePath = "_ViewImports.cshtml", FullTypeName = typeof(RuntimeCompileIdentical).FullName }; var precompiledViews = new ViewCollection(); precompiledViews.Add(globalRazorFileInfo); var cache = new CompilerCache(new[] { precompiledViews }, TestLoadContext, fileProvider); // Act var result = cache.GetOrAdd(ViewPath, compile: _ => { throw new Exception("shouldn't be invoked"); }); // Assert Assert.NotSame(CompilerCacheResult.FileNotFound, result); var actual = result.CompilationResult; Assert.NotNull(actual); Assert.Equal(typeof(PreCompile), actual.CompiledType); }
public void GetOrAdd_UsesValueFromCache_IfViewStartHasNotChanged() { // Arrange var instance = (View)Activator.CreateInstance(typeof(PreCompile)); var length = Encoding.UTF8.GetByteCount(instance.Content); var fileSystem = new TestFileSystem(); var lastModified = DateTime.UtcNow; var fileInfo = new TestFileInfo { Length = length, LastModified = lastModified, Content = instance.Content }; var runtimeFileInfo = new RelativeFileInfo(fileInfo, "ab"); var viewStartContent = "viewstart-content"; var viewStartFileInfo = new TestFileInfo { Content = viewStartContent, LastModified = DateTime.UtcNow }; fileSystem.AddFile("_ViewStart.cshtml", viewStartFileInfo); var viewStartRazorFileInfo = new RazorFileInfo { Hash = RazorFileHash.GetHash(GetMemoryStream(viewStartContent)), LastModified = viewStartFileInfo.LastModified, Length = viewStartFileInfo.Length, RelativePath = "_ViewStart.cshtml", FullTypeName = typeof(RuntimeCompileIdentical).FullName }; var precompiledViews = new ViewCollection(); precompiledViews.Add(viewStartRazorFileInfo); var cache = new CompilerCache(new[] { precompiledViews }, fileSystem); // Act var actual = cache.GetOrAdd(runtimeFileInfo, compile: _ => { throw new Exception("shouldn't be invoked"); }); // Assert Assert.Equal(typeof(PreCompile), actual.CompiledType); }
public void CreateView(string listTitle, string viewTitle, string[] fields) { //Emp List targetList = _context.Web.Lists.GetByTitle(listTitle); ViewCollection viewCollection = targetList.Views; _context.Load(viewCollection); ViewCreationInformation viewCreationInformation = new ViewCreationInformation { Title = viewTitle, RowLimit = 10, SetAsDefaultView = true, ViewFields = fields }; View listView = viewCollection.Add(viewCreationInformation); listView.Update(); }
public void GetOrAdd_IgnoresCachedValueIfFileIsIdentical_ButGlobalWasDeletedSinceCacheWasCreated() { // Arrange var expectedType = typeof(RuntimeCompileDifferent); var lastModified = DateTime.UtcNow; var fileProvider = new TestFileProvider(); var viewCollection = new ViewCollection(); var precompiledView = viewCollection.FileInfos[0]; precompiledView.RelativePath = "Views\\Index.cshtml"; var viewFileInfo = new TestFileInfo { Content = new PreCompile().Content, LastModified = precompiledView.LastModified, PhysicalPath = precompiledView.RelativePath }; fileProvider.AddFile(viewFileInfo.PhysicalPath, viewFileInfo); var globalFileInfo = new TestFileInfo { PhysicalPath = "Views\\_ViewImports.cshtml", Content = "viewstart-content", LastModified = lastModified }; var globalFile = new RazorFileInfo { FullTypeName = typeof(RuntimeCompileIdentical).FullName, RelativePath = globalFileInfo.PhysicalPath, LastModified = globalFileInfo.LastModified, Hash = RazorFileHash.GetHash(globalFileInfo, hashAlgorithmVersion: 1), HashAlgorithmVersion = 1, Length = globalFileInfo.Length }; fileProvider.AddFile(globalFileInfo.PhysicalPath, globalFileInfo); viewCollection.Add(globalFile); var cache = new CompilerCache(new[] { viewCollection }, TestLoadContext, fileProvider); // Act 1 var result1 = cache.GetOrAdd(viewFileInfo.PhysicalPath, compile: _ => { throw new Exception("should not be called"); }); // Assert 1 Assert.NotSame(CompilerCacheResult.FileNotFound, result1); var actual1 = result1.CompilationResult; Assert.NotNull(actual1); Assert.Equal(typeof(PreCompile), actual1.CompiledType); // Act 2 var trigger = fileProvider.GetTrigger(globalFileInfo.PhysicalPath); trigger.IsExpired = true; var result2 = cache.GetOrAdd(viewFileInfo.PhysicalPath, compile: _ => CompilationResult.Successful(expectedType)); // Assert 2 Assert.NotSame(CompilerCacheResult.FileNotFound, result2); var actual2 = result2.CompilationResult; Assert.NotNull(actual2); Assert.Equal(expectedType, actual2.CompiledType); }