Пример #1
0
        public BoundAttributeDescriptor Build()
        {
            var validationDiagnostics = Validate();
            var diagnostics           = new HashSet <RazorDiagnostic>(validationDiagnostics);

            if (_diagnostics != null)
            {
                diagnostics.UnionWith(_diagnostics);
            }

            var descriptor = new DefaultBoundAttributeDescriptor(
                _kind,
                Name,
                TypeName,
                IsEnum,
                IsDictionary,
                IndexerAttributeNamePrefix,
                IndexerValueTypeName,
                Documentation,
                GetDisplayName(),
                new Dictionary <string, string>(Metadata),
                diagnostics.ToArray());

            return(descriptor);
        }
Пример #2
0
        public BoundAttributeDescriptor Build()
        {
            var validationDiagnostics = Validate();
            var diagnostics           = new HashSet <RazorDiagnostic>(validationDiagnostics);

            if (_diagnostics != null)
            {
                diagnostics.UnionWith(_diagnostics);
            }

            var parameters = Array.Empty <BoundAttributeParameterDescriptor>();

            if (_attributeParameterBuilders != null)
            {
                // Attribute parameters are case-sensitive.
                var parameterset = new HashSet <BoundAttributeParameterDescriptor>(BoundAttributeParameterDescriptorComparer.Default);
                for (var i = 0; i < _attributeParameterBuilders.Count; i++)
                {
                    parameterset.Add(_attributeParameterBuilders[i].Build());
                }

                parameters = parameterset.ToArray();
            }

            var descriptor = new DefaultBoundAttributeDescriptor(
                _kind,
                Name,
                TypeName,
                IsEnum,
                IsDictionary,
                IndexerAttributeNamePrefix,
                IndexerValueTypeName,
                Documentation,
                GetDisplayName(),
                CaseSensitive,
                parameters,
                new Dictionary <string, string>(Metadata),
                diagnostics.ToArray())
            {
                IsEditorRequired = IsEditorRequired,
            };

            return(descriptor);
        }