本文整理汇总了C#中IValueProvider.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IValueProvider.GetValue方法的具体用法?C# IValueProvider.GetValue怎么用?C# IValueProvider.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IValueProvider
的用法示例。
在下文中一共展示了IValueProvider.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Desrialize
private ODataQueryCriteria Desrialize(IValueProvider values)
{
var criteria = new ODataQueryCriteria();
var orderBy = values.GetValue("$orderby");
if (orderBy != null)
{
criteria.OrderBy = orderBy.AttemptedValue;
}
var filter = values.GetValue("$filter");
if (filter != null)
{
criteria.Filter = filter.AttemptedValue;
}
ParsePagingInfo(values, criteria);
var expand = values.GetValue("$expand");
if (expand != null)
{
criteria.Expand = expand.AttemptedValue;
}
return criteria;
}
示例2: ParsePagingInfo
private static void ParsePagingInfo(IValueProvider values, ODataQueryCriteria criteria)
{
var pn = values.GetValue("$pageNumber");
var tc = values.GetValue("$inlinecount");
if (pn != null || tc != null)
{
var pageNumber = pn != null ? (int)pn.ConvertTo(typeof(int)) : 1;
var needCount = tc != null && !string.IsNullOrWhiteSpace(tc.AttemptedValue);
var ps = values.GetValue("$pageSize");
int pageSize = ps != null ? (int)ps.ConvertTo(typeof(int)) : 10;
var pagingInfo = new PagingInfo(pageNumber, pageSize, needCount);
criteria.PagingInfo = pagingInfo;
}
}
示例3: GetModel
public object GetModel(ControllerContext controllerContext, Type modelType, IValueProvider valueProvider, string key)
{
if (!valueProvider.ContainsPrefix(key))
{
return null;
}
ModelMetadata modelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, modelType);
if (!modelMetadata.IsComplexType)
{
return valueProvider.GetValue(key).ConvertTo(modelType);
}
if (modelType.IsArray)
{
return GetArrayModel(controllerContext, modelType, valueProvider,key);
}
Type enumerableType = ExtractGenericInterface(modelType, typeof(IEnumerable<>));
if (null != enumerableType)
{
return GetCollectionModel(controllerContext, modelType, valueProvider, key);
}
if (modelMetadata.IsComplexType)
{
return GetComplexModel(controllerContext, modelType, valueProvider, key);
}
return null;
}
示例4: QuestionSelected
private bool QuestionSelected(IValueProvider provider, int idx)
{
var valResult = provider.GetValue(ResultName(idx));
return ((valResult != null)
&& !string.IsNullOrEmpty(valResult.AttemptedValue)
&& valResult.AttemptedValue.Contains("true"));
}
示例5: GetModel
public object GetModel(ControllerContext controllerContext, Type modelType, IValueProvider valueProvider, string key)
{
if (!valueProvider.ContainsPrefix(key))
{
return null;
}
return valueProvider.GetValue(key).ConvertTo(modelType);
}
示例6: GetFormField
string GetFormField(string key, IValueProvider provider) {
ValueProviderResult result = provider.GetValue(key);
if(result != null) {
return (string)result.ConvertTo(typeof(string));
}
return null;
}
示例7: UpdatePageStatus
private void UpdatePageStatus(CmsPage page, IValueProvider valueProvider)
{
int pageStatusId;
if (Int32.TryParse(valueProvider.GetValue("Page.Status.Id").AttemptedValue, out pageStatusId))
{
Status pageStatus = pageService.LoadPageType(pageStatusId);
page.Status = pageStatus;
}
}
示例8: BindValue
private static void BindValue(dynamic shape, IValueProvider valueProvider, string prefix) {
// if the shape has a Name property, look for a value in
// the ValueProvider
var name = shape.Name;
if (name != null) {
ValueProviderResult value = valueProvider.GetValue(prefix + name);
if (value != null) {
shape.Value = value.AttemptedValue;
}
}
}
示例9: GetCurrentValue
public static string GetCurrentValue(this IGridDataKey dataKey, IValueProvider valueProvider)
{
var value = valueProvider.GetValue(dataKey.RouteKey);
if (value != null)
{
return value.AttemptedValue;
}
return null;
}
示例10: GetSupportedUavs
private static IEnumerable<UavTypeDTO> GetSupportedUavs(IValueProvider valueProvider)
{
if (valueProvider.GetValue("UavType") == null)
throw new Exception("UavTypes is NULL");
var types = (string[]) valueProvider.GetValue("UavType").ConvertTo(typeof (string[]));
return types.Select(item => new UavTypeDTO()
{
Id = int.Parse(item)
}).ToList();
}
示例11: GetArrayModel
protected virtual object GetArrayModel( ControllerContext controllerContext, Type modelType, IValueProvider valueProvider, string prefix)
{
if (valueProvider.ContainsPrefix(prefix) && !string.IsNullOrEmpty(prefix))
{
ValueProviderResult result = valueProvider.GetValue(prefix);
if (null != result)
{
return result.ConvertTo(modelType);
}
}
return null;
}
示例12: ApplyValues
/// <summary>
/// 在表单上应用指定值提供程序的值
/// </summary>
/// <param name="form">要应用的表单</param>
/// <param name="valueProvider">提供值的 ValueProvider 实例</param>
/// <returns>返回表单,便于链式调用</returns>
public static HtmlForm ApplyValues( this HtmlForm form, IValueProvider valueProvider )
{
foreach ( var key in form.InputControls.Select( c => c.Name ) )
{
if ( valueProvider.ContainsPrefix( key ) )
{
form[key].TrySetValue( valueProvider.GetValue( key ).AttemptedValue );
}
}
return form;
}
示例13: ApplyValues
/// <summary>
/// 在表单上应用指定值提供程序的值
/// </summary>
/// <param name="form">要应用的表单</param>
/// <param name="valueProvider">提供值的 ValueProvider 实例</param>
/// <returns>返回表单,便于链式调用</returns>
public static HtmlForm ApplyValues( this HtmlForm form, IValueProvider valueProvider )
{
foreach ( var control in form.Controls )
{
if ( valueProvider.ContainsPrefix( control.Name ) )
control.Value = valueProvider.GetValue( control.Name ).AttemptedValue;
}
return form;
}
示例14: BindDataSource
private static IValueSet BindDataSource(IValueProvider provider)
{
ValueDictionary values = new ValueDictionary();
foreach (string key in provider.Keys)
{
ValueProviderResult result = provider.GetValue(key);
if (result == null)
continue;
values.Add(key, result.Value);
}
return values;
}
示例15: TestInit
public void TestInit()
{
_actionContext = new HttpActionContext();
_valueProvider = Mock.Create<IValueProvider>(Behavior.Loose);
Mock.Arrange(() => _valueProvider.GetValue("process")).Returns(new ValueProviderResult(ProcessName, ProcessName, null));
_bindingContext = new ModelBindingContext
{
ValueProvider = _valueProvider,
ModelMetadata =
new ModelMetadata(new EmptyModelMetadataProvider(), null, null, typeof(SearchParameters), null)
};
}