private void ProcessLayoutRendering([NotNull] XmlTextWriter output, [NotNull] ValidationWriter writer, [NotNull] ValidationAnalyzerOptions options, [NotNull] Item item, [NotNull] XElement renderingElement) { Debug.ArgumentNotNull(output, nameof(output)); Debug.ArgumentNotNull(writer, nameof(writer)); Debug.ArgumentNotNull(options, nameof(options)); Debug.ArgumentNotNull(item, nameof(item)); Debug.ArgumentNotNull(renderingElement, nameof(renderingElement)); var renderingItemId = renderingElement.GetAttributeValue("id"); if (string.IsNullOrEmpty(renderingItemId)) { return; } var renderingItem = item.Database.GetItem(renderingItemId); if (renderingItem == null) { return; } foreach (var renderingValidationDescriptor in ValidationManager.RenderingValidations) { if (options.InactiveValidations.Contains("[" + renderingValidationDescriptor.Attribute.Name + "]")) { continue; } if (!renderingValidationDescriptor.Instance.CanCheck(options.ContextName, item, renderingElement, renderingItem)) { continue; } try { writer.Clear(); renderingValidationDescriptor.Instance.Check(writer, item, renderingElement, renderingItem); writer.Write(output, renderingValidationDescriptor.Attribute.Category, renderingValidationDescriptor.Attribute.Name); } catch (Exception ex) { Log.Error("Validations", ex, GetType()); } } }
private void ProcessItem([NotNull] XmlTextWriter output, [NotNull] ValidationWriter writer, [NotNull] ValidationManager.ItemValidationDescriptor descriptor, [NotNull] Item item) { Debug.ArgumentNotNull(output, nameof(output)); Debug.ArgumentNotNull(writer, nameof(writer)); Debug.ArgumentNotNull(descriptor, nameof(descriptor)); Debug.ArgumentNotNull(item, nameof(item)); try { writer.Clear(); descriptor.Instance.Check(writer, item); writer.Write(output, descriptor.Attribute.Category, descriptor.Attribute.Name); } catch (Exception ex) { Log.Error("Validations", ex, GetType()); } }
private void ProcessCustomValidations([NotNull] XmlTextWriter output, [NotNull] ValidationWriter writer, [NotNull] XElement element, [NotNull] ValidationAnalyzerOptions options, [NotNull] XmlDocument webConfig, [NotNull] XmlDocument expandedWebConfig, [NotNull] FileSystemNavigator webFileSystem, [NotNull] FileSystemNavigator dataFileSystem) { Debug.ArgumentNotNull(output, nameof(output)); Debug.ArgumentNotNull(writer, nameof(writer)); Debug.ArgumentNotNull(element, nameof(element)); Debug.ArgumentNotNull(options, nameof(options)); Debug.ArgumentNotNull(webConfig, nameof(webConfig)); Debug.ArgumentNotNull(expandedWebConfig, nameof(expandedWebConfig)); Debug.ArgumentNotNull(webFileSystem, nameof(webFileSystem)); Debug.ArgumentNotNull(dataFileSystem, nameof(dataFileSystem)); var customValidation = new CustomValidation(); customValidation.Load(element); writer.Clear(); customValidation.Process(writer, options, webConfig, expandedWebConfig, webFileSystem, dataFileSystem); writer.Write(output, customValidation.Category, customValidation.Title); }
private void ProcessValidations([NotNull] XmlTextWriter output, [NotNull] ValidationAnalyzerOptions options) { Debug.ArgumentNotNull(output, nameof(output)); Debug.ArgumentNotNull(options, nameof(options)); var writer = new ValidationWriter(); foreach (var definition in ValidationManager.Validations.OrderBy(v => v.Attribute.Category).ThenBy(v => v.Type.Name)) { if (options.InactiveValidations.Contains("[" + definition.Attribute.Name + "]")) { continue; } var instance = definition.GetInstance(); if (instance == null) { continue; } if (!instance.CanCheck(options.ContextName)) { continue; } try { writer.Clear(); instance.Check(writer); writer.Write(output, definition.Attribute.Category, definition.Attribute.Name); } catch (Exception ex) { Log.Error("Validations", ex, GetType()); } } }