コード例 #1
0
 public static IBindingsBuilder <T> Text <T, F>(
     this IBindingsBuilder <T> bindingsBuilder,
     Expression <Func <T, F> > expression,
     string format = null,
     params LambdaExpression[] otherExpressions)
     where T : class
 {
     if (expression == null)
     {
         throw (new ArgumentNullException("expression"));
     }
     if (format == null)
     {
         string clientFormat;
         string prefix;
         string postfix;
         string nullString;
         int    clientType = CoreHTMLHelpers.
                             GetClientInfo(expression, out clientFormat, out prefix, out postfix, out nullString);
         bindingsBuilder.Add(
             string.Format(textScript,
                           bindingsBuilder.GetFullBindingName(expression),
                           clientFormat,
                           clientType,
                           prefix,
                           postfix,
                           nullString)
             );
         return(bindingsBuilder);
     }
     bindingsBuilder.Add(
         bindingsBuilder.standardString <T, F>("text", expression, format, otherExpressions)
         );
     return(bindingsBuilder);
 }
コード例 #2
0
        public static IBindingsBuilder <T> Value <T, F>(
            this IBindingsBuilder <T> bindingsBuilder,
            Expression <Func <T, F> > expression)
        {
            if (expression == null)
            {
                throw (new ArgumentNullException("expression"));
            }
            string clientFormat;
            string prefix;
            string postfix;
            string nullString;
            int    clientType = CoreHTMLHelpers.
                                GetClientInfo(expression, out clientFormat, out prefix, out postfix, out nullString);

            bindingsBuilder.Add(
                bindingsBuilder.standardString <T, F>("value", expression, null, null)
                );
            bindingsBuilder.Add("valueType: " + clientType);
            if (clientFormat.Length > 0)
            {
                bindingsBuilder.Add("formatString: &quot;" + clientFormat + "&quot;");
            }
            return(bindingsBuilder);
        }
コード例 #3
0
        private static MvcHtmlString _cond <T, F>(
            this HtmlHelper <T> htmlHelper,
            Expression <Func <T, F> > expression,
            ExternalContainerType itemsContainer = ExternalContainerType.koComment,
            object htmlAttributes = null,
            string afterRender    = null,
            bool negateCondition  = false,
            string format         = null,
            params LambdaExpression[] otherExpressions)
        {
            if (expression == null)
            {
                throw (new ArgumentNullException("expression"));
            }
            IDictionary <string, object> attributes = null;

            if (htmlAttributes == null)
            {
                attributes = new RouteValueDictionary();
            }
            else if (htmlAttributes is IDictionary <string, object> )
            {
                attributes = htmlAttributes as IDictionary <string, object>;
            }
            else
            {
                attributes = new RouteValueDictionary(htmlAttributes);
            }
            IBindingsBuilder <T> bindings = htmlHelper.ClientBindings();

            if (bindings == null)
            {
                throw (new ArgumentNullException("bindings"));
            }
            string bindingsValue = string.Format(
                ifScript,
                bindings.standardString(negateCondition ? "ifnot" : "if", expression, format, otherExpressions),
                bindings.ValidationType == "UnobtrusiveClient" ? "true" : "false",
                afterRender == null ? "null" : afterRender);

            if (attributes.ContainsKey("data-bind"))
            {
                attributes["data-bind"] = (attributes["data-bind"] as string) + ", " + bindingsValue;
            }
            else
            {
                attributes["data-bind"] = bindingsValue;
            }
            attributes["data-nobinding"] = "true";
            string openTag;
            string closeTag;

            BasicHtmlHelper.GetContainerTags(itemsContainer, attributes, out openTag, out closeTag);
            htmlPush("_ClientControlsFlowStack_", closeTag);
            return(MvcHtmlString.Create(
                       openTag
                       ));
        }
コード例 #4
0
 public static IBindingsBuilder <T> Submit <T, F>(
     this IBindingsBuilder <T> bindingsBuilder,
     Expression <Func <T, F> > expression,
     string format = null,
     params LambdaExpression[] otherExpressions)
     where T : class
 {
     if (expression == null)
     {
         throw (new ArgumentNullException("expression"));
     }
     bindingsBuilder.Add(
         bindingsBuilder.standardString <T, F>("submit", expression, format, otherExpressions)
         );
     return(bindingsBuilder);
 }
コード例 #5
0
 public static IBindingsBuilder <T> SelectedOptions <T, F>(
     this IBindingsBuilder <T> bindingsBuilder,
     Expression <Func <T, F> > expression,
     string format = null,
     params LambdaExpression[] otherExpressions)
 {
     if (expression == null)
     {
         throw (new ArgumentNullException("expression"));
     }
     bindingsBuilder.Add(
         bindingsBuilder.standardString <T, F>("selectedOptions", expression, format, otherExpressions)
         );
     bindingsBuilder.Add("valueType: " + CoreHTMLHelpers.GetClientType(typeof(F)));
     return(bindingsBuilder);
 }
コード例 #6
0
        public static IBindingsBuilder <T> Options <T, F>(
            this IBindingsBuilder <T> bindingsBuilder,
            Expression <Func <T, F> > expression,
            string caption = null)
        {
            if (expression == null)
            {
                throw (new ArgumentNullException("expression"));
            }
            bindingsBuilder.Add(
                bindingsBuilder.standardString <T, F>("options", expression, null, null)
                );

            int clientType = CoreHTMLHelpers.GetClientType(typeof(F));

            bindingsBuilder.Add("valueType: " + clientType);

            if (!string.IsNullOrWhiteSpace(caption))
            {
                bindingsBuilder.Add("optionsCaption: &quot;" + caption + "&quot;");
            }
            return(bindingsBuilder);
        }
コード例 #7
0
        public static IBindingsBuilder <T> Options <T, F, IF, IFT>(
            this IBindingsBuilder <T> bindingsBuilder,
            Expression <Func <T, IEnumerable <F> > > expression,
            Expression <Func <F, IF> > valueField,
            Expression <Func <F, IFT> > textField,
            string caption          = null,
            string valueFieldFormat = null,
            string textFieldFormat  = null)

        {
            if (expression == null)
            {
                throw (new ArgumentNullException("expression"));
            }
            bindingsBuilder.Add(
                bindingsBuilder.standardString <T, IEnumerable <F> >("options", expression, null, null)
                );
            if (valueFieldFormat == null)
            {
                bindingsBuilder.Add("optionsValue: &quot;" + ExpressionHelper.GetExpressionText(valueField) + "&quot;");
            }
            else
            {
                bindingsBuilder.Add(
                    baseStandardString <F, IF>("optionsValue", valueField, valueFieldFormat, null)
                    );
            }
            string clientFormat;
            string prefix;
            string postfix;
            string nullString;
            int    clientType = CoreHTMLHelpers.
                                GetClientInfo(valueField, out clientFormat, out prefix, out postfix, out nullString);

            bindingsBuilder.Add("valueType: " + clientType);
            if (clientFormat.Length > 0)
            {
                bindingsBuilder.Add("formatString: &quot;" + clientFormat + "&quot;");
            }
            if (textFieldFormat == null)
            {
                bindingsBuilder.Add("optionsText: &quot;" + ExpressionHelper.GetExpressionText(textField) + "&quot;");
            }
            else
            {
                bindingsBuilder.Add(
                    baseStandardString <F, IFT>("optionsText", textField, textFieldFormat, null)
                    );
            }
            clientType = CoreHTMLHelpers.
                         GetClientInfo(textField, out clientFormat, out prefix, out postfix, out nullString);
            bindingsBuilder.Add("textType: " + clientType);
            if (clientFormat.Length > 0)
            {
                bindingsBuilder.Add("textFormatString: &quot;" + clientFormat + "&quot;");
            }
            bindingsBuilder.Add("textPrefix: &quot;" + prefix + "&quot;");
            bindingsBuilder.Add("textPostfix: &quot;" + postfix + "&quot;");
            bindingsBuilder.Add("textNullString: &quot;" + nullString + "&quot;");
            if (!string.IsNullOrWhiteSpace(caption))
            {
                bindingsBuilder.Add("optionsCaption: &quot;" + caption + "&quot;");
            }
            return(bindingsBuilder);
        }