protected string GetId() { var modelType = GetModelType(); if (modelType == ModelType.For) { return(For.Name); } if (modelType == ModelType.Model) { return(ElementNaming.Id(ViewContext.ViewData.Model)); } throw new InvalidOperationException("Modeless view or partial not supported yet"); }
public override void Process(TagHelperContext context, TagHelperOutput output) { var model = For.Model as IEnumerable; if (model == null) { throw new ArgumentException("Attribute 'for' has to be a IEnumerable"); } if (model.GetEnumerator().MoveNext()) { var modelType = For.Metadata.ContainerType ?? For.ModelExplorer.Container.ModelType; output.TagName = "table"; output.Attributes.Add("id", ElementNaming.Id(modelType)); } else { output.SuppressOutput(); } }