public IFileInfo GetFileInfo(string subpath) { if (subpath is null) { throw new ArgumentNullException(nameof(subpath)); } string PathToCheck = CleanPath(subpath); RazorFileInfo fileInfo = new RazorFileInfo(); RazorCompiledItemAttribute rca = RazorViews.FirstOrDefault(rcal => rcal.Identifier == PathToCheck); fileInfo.Exists = rca != null; if (rca != null) { string LocalPath = rca.Identifier.From(PathToCheck); bool Directory = LocalPath.Contains("/"); string Name = LocalPath.To("/"); fileInfo.IsDirectory = Directory; fileInfo.LastModified = DateTime.MinValue; fileInfo.Name = Name; fileInfo.PhysicalPath = ""; } return(fileInfo); }
protected override RazorCompiledItem CreateItem(RazorCompiledItemAttribute attribute) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } return(new InBizModuleViewCompiledItem(attribute, ModuleName)); }
/// <summary> /// Creates a <see cref="RazorCompiledItem"/> from a <see cref="RazorCompiledItemAttribute"/>. /// </summary> /// <param name="attribute">The <see cref="RazorCompiledItemAttribute"/>.</param> /// <returns>A <see cref="RazorCompiledItem"/> created from <paramref name="attribute"/>.</returns> protected virtual RazorCompiledItem CreateItem(RazorCompiledItemAttribute attribute) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } return(new DefaultRazorCompiledItem(attribute.Type, attribute.Kind, attribute.Identifier)); }
public MystiqueModuleViewCompiledItem(RazorCompiledItemAttribute attr, string moduleName) { Type = attr.Type; Kind = attr.Kind; Identifier = $"/{GlobalConst.ModulePrefix}/{moduleName}{attr.Identifier}"; Metadata = Type.GetCustomAttributes(inherit: true).Select(o => o is RazorSourceChecksumAttribute rsca ? new RazorSourceChecksumAttribute(rsca.ChecksumAlgorithm, rsca.Checksum, $"/{GlobalConst.ModulePrefix}/{moduleName}{rsca.Identifier}") : o).ToList(); }
public MystiqueModuleViewCompiledItem(RazorCompiledItemAttribute attr, string moduleName) { Type = attr.Type; Kind = attr.Kind; Identifier = "/Modules/" + moduleName + attr.Identifier; Metadata = Type.GetCustomAttributes(inherit: true).Select(o => o is RazorSourceChecksumAttribute rsca ? new RazorSourceChecksumAttribute(rsca.ChecksumAlgorithm, rsca.Checksum, "/Modules/" + moduleName + rsca.Identifier) : o).ToList(); }
public void PopulateFeature_ReadsAttributesFromTheCurrentAssembly() { // Arrange var item1 = new RazorCompiledItemAttribute(typeof(string), "mvc.1.0.view", "view"); var assembly = new AssemblyWithEmptyLocation( new RazorViewAttribute[] { new RazorViewAttribute("view", typeof(string)) }, new RazorCompiledItemAttribute[] { item1 }); var partManager = new ApplicationPartManager(); partManager.ApplicationParts.Add(new AssemblyPart(assembly)); partManager.FeatureProviders.Add(new ViewsFeatureProvider()); var feature = new ViewsFeature(); // Act partManager.PopulateFeature(feature); // Assert var descriptor = Assert.Single(feature.ViewDescriptors); Assert.Equal(typeof(string), descriptor.Item.Type); Assert.Equal("mvc.1.0.view", descriptor.Item.Kind); Assert.Equal("view", descriptor.Item.Identifier); }