// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Linq.Expressions;
namespace Microsoft.AspNet.Mvc.Rendering
{
///
/// Value-related extensions for and .
///
public static class HtmlHelperValueExtensions
{
///
/// Returns the formatted value for the specified expression .
///
/// The instance this method extends.
/// Expression name, relative to the current model.
/// A containing the formatted value.
///
/// Converts the expression result to a directly.
///
public static string Value([NotNull] this IHtmlHelper htmlHelper, string name)
{
return htmlHelper.Value(name, format: null);
}
///
/// Returns the formatted value for the specified .
///
/// The instance this method extends.
/// The expression to be evaluated against the current model.
/// The type of the model.
/// The type of the result.
/// A containing the formatted value.
///
/// Converts the result to a directly.
///
public static string ValueFor(
[NotNull] this IHtmlHelper htmlHelper,
[NotNull] Expression> expression)
{
return htmlHelper.ValueFor(expression, format: null);
}
///
/// Returns the formatted value for the current model.
///
/// The instance this method extends.
/// A containing the formatted value.
///
/// Converts the model value to a directly.
///
public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper)
{
return htmlHelper.Value(name: null, format: null);
}
///
/// Returns the formatted value for the current model.
///
/// The instance this method extends.
///
/// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx).
///
/// A containing the formatted value.
///
/// Converts the model value to a directly if
/// is null or empty.
///
public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper, string format)
{
return htmlHelper.Value(name: null, format: format);
}
}
}