예제 #1
0
        static string ReplaceAttribute(string output, BbAttribute attribute, string rawValue, string placeholderStr, Dictionary <string, string> attrValuesById)
        {
            string effectiveValue;

            if (attribute.ContentTransformer == null)
            {
                effectiveValue = rawValue;
            }
            else
            {
                var ctx = new AttributeRenderingContextImpl(attribute, rawValue, attrValuesById);

                effectiveValue = attribute.ContentTransformer(ctx);
            }

            if (effectiveValue == null)
            {
                effectiveValue = string.Empty;
            }

            var encodedValue =
                attribute.HtmlEncodingMode == HtmlEncodingMode.HtmlAttributeEncode
                    ? HttpUtility.HtmlAttributeEncode(effectiveValue)
                    : attribute.HtmlEncodingMode == HtmlEncodingMode.HtmlEncode
                          ? HttpUtility.HtmlEncode(effectiveValue)
                          : effectiveValue;

            output = output.Replace(placeholderStr, encodedValue);

            return(output);
        }
예제 #2
0
        string TryGetValue(BbAttribute attr)
        {
            string value;

            AttributeValues.TryGetValue(attr, out value);

            return(value);
        }
        public AttributeRenderingContextImpl(BbAttribute attribute,
                                             string attributeValue,
                                             IDictionary <string, string> getAttributeValueByIdData)
        {
            Attribute = attribute;

            AttributeValue = attributeValue;

            GetAttributeValueByIdData = getAttributeValueByIdData;
        }