コード例 #1
0
        private static void WriteBoundAttributeParameter(JsonWriter writer, BoundAttributeParameterDescriptor boundAttributeParameter, JsonSerializer serializer)
        {
            writer.WriteStartObject();

            writer.WritePropertyName(nameof(BoundAttributeParameterDescriptor.Name));
            writer.WriteValue(boundAttributeParameter.Name);

            writer.WritePropertyName(nameof(BoundAttributeParameterDescriptor.TypeName));
            writer.WriteValue(boundAttributeParameter.TypeName);

            if (boundAttributeParameter.IsEnum != default)
            {
                writer.WritePropertyName(nameof(BoundAttributeParameterDescriptor.IsEnum));
                writer.WriteValue(boundAttributeParameter.IsEnum);
            }

            if (boundAttributeParameter.Documentation != null)
            {
                writer.WritePropertyName(nameof(BoundAttributeParameterDescriptor.Documentation));
                writer.WriteValue(boundAttributeParameter.Documentation);
            }

            if (boundAttributeParameter.Diagnostics != null && boundAttributeParameter.Diagnostics.Count > 0)
            {
                writer.WritePropertyName(nameof(BoundAttributeParameterDescriptor.Diagnostics));
                serializer.Serialize(writer, boundAttributeParameter.Diagnostics);
            }

            writer.WritePropertyName(nameof(BoundAttributeParameterDescriptor.Metadata));
            WriteMetadata(writer, boundAttributeParameter.Metadata);

            writer.WriteEndObject();
        }
コード例 #2
0
    public static bool IsDefaultKind(this BoundAttributeParameterDescriptor parameter)
    {
        if (parameter == null)
        {
            throw new ArgumentNullException(nameof(parameter));
        }

        return(string.Equals(parameter.Kind, TagHelperConventions.DefaultKind, StringComparison.Ordinal));
    }
コード例 #3
0
    public static string GetPropertyName(this BoundAttributeParameterDescriptor parameter)
    {
        if (parameter == null)
        {
            throw new ArgumentNullException(nameof(parameter));
        }

        parameter.Metadata.TryGetValue(TagHelperMetadata.Common.PropertyName, out var propertyName);
        return(propertyName);
    }
コード例 #4
0
 private static void WriteBoundAttributeParameter(JsonWriter writer, BoundAttributeParameterDescriptor boundAttributeParameter, JsonSerializer serializer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("Kind");
     writer.WriteValue(boundAttributeParameter.Kind);
     writer.WritePropertyName("Name");
     writer.WriteValue(boundAttributeParameter.Name);
     writer.WritePropertyName("TypeName");
     writer.WriteValue(boundAttributeParameter.TypeName);
     writer.WritePropertyName("IsEnum");
     writer.WriteValue(boundAttributeParameter.IsEnum);
     writer.WritePropertyName("Documentation");
     writer.WriteValue(boundAttributeParameter.Documentation);
     writer.WritePropertyName("Diagnostics");
     serializer.Serialize(writer, boundAttributeParameter.Diagnostics);
     writer.WritePropertyName("Metadata");
     WriteMetadata(writer, boundAttributeParameter.Metadata);
     writer.WriteEndObject();
 }
コード例 #5
0
        public static BoundAttributeDescriptionInfo From(BoundAttributeParameterDescriptor parameterAttribute, string parentTagHelperTypeName)
        {
            if (parameterAttribute is null)
            {
                throw new ArgumentNullException(nameof(parameterAttribute));
            }

            if (parentTagHelperTypeName is null)
            {
                throw new ArgumentNullException(nameof(parentTagHelperTypeName));
            }

            var propertyName    = parameterAttribute.GetPropertyName();
            var descriptionInfo = new BoundAttributeDescriptionInfo(
                parameterAttribute.TypeName,
                parentTagHelperTypeName,
                propertyName,
                parameterAttribute.Documentation);

            return(descriptionInfo);
        }