Пример #1
0
 /// <summary>
 /// Cria uma nova instancia de <see cref="HtmlObject"/>
 /// </summary>
 /// <param name="tag">Tag html que representa o controle.</param>
 public HtmlObject(HtmlTag tag)
 {
     _slots               = new Dictionary <ControlProperty, ControlPropertySlot>();
     _renderResult        = new ControlPropertyApplyResult(this);
     _templatedProperties = ControlProperty.GetTemplatedProperties(this.GetType());
     Tag = tag;
 }
        public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
        {
            if (value.AsString().IsEmpty() || value.AsString() == DefaultValue.AsString())
                return;

            result.Attributes[Attribute.ToString().ToLower()] = value.AsString();
        }
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     var boolValue = ConversionHelper.ToBoolean(value);
     if (boolValue == DefaultValue)
         return;
     result.Attributes[Attribute] = boolValue ? ValueIfTrue : ValueIfFalse;
 }
Пример #4
0
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     if (value != null && value.AsString() != DefaultValue.AsString())
     {
         var strValue = (value ?? "").ToString();
         if (strValue.HasValue())
             result.Styles[CssProperty] = strValue.ToLowerInvariant();
     }
 }
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     Object getParams = null;
     var urlStr = value.AsString();
     var uri = new Uri(urlStr, UriKind.RelativeOrAbsolute);
     //url.
     if (GetParamsProperty != null)
         getParams = target.GetValue(GetParamsProperty);
     if (getParams != null)
     {
         IDictionary<String, Object> dict = null;
         if (!(getParams is IDictionary<String, Object>))
             dict = ReflectionHelper.AnonymousToDictionary(getParams);
         else
             dict = (IDictionary<String, Object>)getParams;
         if (uri.Query.HasValue())
             urlStr += urlStr + "&" + Utils.EncodeGetParams(dict);
         else
             urlStr += uri.ToString() + "?" + Utils.EncodeGetParams(dict);
     }
     if (urlStr != null)
         result.Attributes[HtmlAttr.Href] = urlStr;
 }
Пример #6
0
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
 }
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     if (value != null && value.AsString() != DefaultValue.AsString())
     {
         result.Styles[CssProperty] = CssConfig.GetItemNameFromEnum(property.PropertyType, value);
     }
 }
        public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
        {
            var boolValue = ConversionHelper.ToBoolean(value);

            if (boolValue == DefaultValue)
            {
                return;
            }
            result.Attributes[Attribute] = boolValue ? ValueIfTrue : ValueIfFalse;
        }
Пример #9
0
 protected override void ApplyValueProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     result.InnerText.Append(value.AsString());
 }
Пример #10
0
 protected override void ApplyValueProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     if (value.AsString().HasValue())
     {
         result.Attributes[HtmlAttr.Value] = value.AsString();
     }
 }
Пример #11
0
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     if (value != null && value.AsString() != DefaultValue.AsString())
         result.Styles[CssProperty] = CssConfig.GetItemNameFromEnum(property.PropertyType, value);
 }
Пример #12
0
 protected override void ApplyValueProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     if (value.AsString().HasValue())
         result.Attributes[HtmlAttr.Value] = value.AsString();
 }
        public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
        {
            if (value.AsString().IsEmpty() || value.AsString() == DefaultValue.AsString())
            {
                return;
            }

            result.Attributes[Attribute.ToString().ToLower()] = value.AsString();
        }
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     Callback.Invoke(target, property, value, result);
 }
Пример #15
0
 protected override void ApplyValueProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     result.InnerText.Append(value.AsString());
 }
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     Callback.Invoke(target, property, value, result);
 }
Пример #17
0
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     if (value != null && value.AsString() != DefaultValue.AsString())
     {
         var strValue = (value ?? "").ToString();
         if (strValue.HasValue())
         {
             result.Styles[CssProperty] = strValue.ToLowerInvariant();
         }
     }
 }
        public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
        {
            Object getParams = null;
            var    urlStr    = value.AsString();
            var    uri       = new Uri(urlStr, UriKind.RelativeOrAbsolute);

            //url.
            if (GetParamsProperty != null)
            {
                getParams = target.GetValue(GetParamsProperty);
            }
            if (getParams != null)
            {
                IDictionary <String, Object> dict = null;
                if (!(getParams is IDictionary <String, Object>))
                {
                    dict = ReflectionHelper.AnonymousToDictionary(getParams);
                }
                else
                {
                    dict = (IDictionary <String, Object>)getParams;
                }
                if (uri.Query.HasValue())
                {
                    urlStr += urlStr + "&" + Utils.EncodeGetParams(dict);
                }
                else
                {
                    urlStr += uri.ToString() + "?" + Utils.EncodeGetParams(dict);
                }
            }
            if (urlStr != null)
            {
                result.Attributes[HtmlAttr.Href] = urlStr;
            }
        }