本文整理汇总了C#中System.Web.Mvc.ValueProviderResult类的典型用法代码示例。如果您正苦于以下问题:C# ValueProviderResult类的具体用法?C# ValueProviderResult怎么用?C# ValueProviderResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValueProviderResult类属于System.Web.Mvc命名空间,在下文中一共展示了ValueProviderResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetModelValue
internal static object GetModelValue(ValueProviderResult result, Type memberType)
{
var memberMapping = ModelMappingManager.MappingFor(memberType);
var descriptor = new ModelDescriptor(memberMapping);
var value = result.ConvertTo(descriptor.KeyProperty.PropertyType);
return memberMapping.Configuration.Repository().Find(value);
}
开发者ID:edurdias,项目名称:RunningObjects,代码行数:7,代码来源:ModelBinder.cs
示例2: GetValue
public ValueProviderResult GetValue(string key)
{
ValueProviderResult result;
result = new ValueProviderResult(data,
"Id", CultureInfo.CurrentCulture);
return result;
}
开发者ID:jfvaleroso,项目名称:WMS,代码行数:7,代码来源:CryptoValueProvider.cs
示例3: ParseDate
public static DateTime ParseDate(ValueProviderResult value)
{
// Create an array of all supported standard date and time format specifiers.
string[] formats = {"d", "D", "f", "F", "g", "G", "m", "o", "r",
"s", "t", "T", "u", "U", "Y", "dd/MM/yyyy hh:mm:ss", "MM/dd/yyyy hh:mm:ss"};
//
CultureInfo[] cultures = {CultureInfo.CreateSpecificCulture("de-DE"),
CultureInfo.CreateSpecificCulture("en-US"),
CultureInfo.CreateSpecificCulture("he-IL"),
CultureInfo.CreateSpecificCulture("es-ES"),
CultureInfo.CreateSpecificCulture("fr-FR")};
var parsedSuccesfuly = false;
int cultureIndex = 0;
DateTime foundDateTime = DateTime.MinValue;
while (!parsedSuccesfuly && cultureIndex < cultures.Length)
{
parsedSuccesfuly = DateTime.TryParseExact(value.AttemptedValue, formats, cultures[cultureIndex], DateTimeStyles.None, out foundDateTime);
cultureIndex++;
}
if (parsedSuccesfuly)
{
return foundDateTime;
}
throw new FormatException("Could not parse the specified date, culture is not supported");
}
开发者ID:UrK,项目名称:kululu_v1,代码行数:28,代码来源:CommonDateTime.cs
示例4: GetValue
protected virtual ValueProviderResult GetValue(string key)
{
ValueProviderResult res = null;
string val = this._context.HttpContext.Request.Form[key.Replace('.', '[')+']'] as string;
if (val != null)
res = new ValueProviderResult(val, val, CultureInfo.CurrentCulture);
return res;
}
开发者ID:Naviam,项目名称:Home-Accounting-Old,代码行数:8,代码来源:MyFormValueProvider.cs
示例5: NHValueProviderResult
/// <summary>
/// </summary>
/// <param name="result"></param>
/// <param name="sessionWrapper"></param>
/// <exception cref="ArgumentNullException"></exception>
public NHValueProviderResult(ValueProviderResult result, SessionWrapper sessionWrapper)
{
_result = result;
_sessionWrapper = sessionWrapper;
AttemptedValue = result.AttemptedValue;
Culture = result.Culture;
RawValue = result.RawValue;
}
开发者ID:luqizheng,项目名称:Qi4Net,代码行数:13,代码来源:NHValueProviderResult.cs
示例6: SetModelState
private void SetModelState(ModelBindingContext bindingContext, ValueProviderResult valueProviderResult)
{
ModelState modelState;
if (!bindingContext.ModelState.TryGetValue(bindingContext.ModelName, out modelState))
{
bindingContext.ModelState.Add(bindingContext.ModelName, modelState = new ModelState());
}
modelState.Value = valueProviderResult;
}
开发者ID:ittray,项目名称:LocalDemo,代码行数:9,代码来源:MyDefaultModelBinder.cs
示例7: ConvertToCanConvertArraysToSingleElements
public void ConvertToCanConvertArraysToSingleElements() {
// Arrange
ValueProviderResult vpr = new ValueProviderResult(new int[] { 1, 20, 42 }, "", CultureInfo.InvariantCulture);
// Act
string converted = (string)vpr.ConvertTo(typeof(string));
// Assert
Assert.AreEqual("1", converted);
}
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:10,代码来源:ValueProviderResultTest.cs
示例8: ConvertToCanConvertSingleElementsToSingleElements
public void ConvertToCanConvertSingleElementsToSingleElements() {
// Arrange
ValueProviderResult vpr = new ValueProviderResult(42, "", CultureInfo.InvariantCulture);
// Act
string converted = (string)vpr.ConvertTo(typeof(string));
// Assert
Assert.IsNotNull(converted);
Assert.AreEqual("42", converted);
}
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:11,代码来源:ValueProviderResultTest.cs
示例9: ConvertToChecksTypeConverterCanConvertFrom
public void ConvertToChecksTypeConverterCanConvertFrom() {
// Arrange
object original = "someValue";
ValueProviderResult vpr = new ValueProviderResult(original, null, CultureInfo.GetCultureInfo("fr-FR"));
// Act
DefaultModelBinderTest.StringContainer returned = (DefaultModelBinderTest.StringContainer)vpr.ConvertTo(typeof(DefaultModelBinderTest.StringContainer));
// Assert
Assert.AreEqual(returned.Value, "someValue (fr-FR)");
}
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:11,代码来源:ValueProviderResultTest.cs
示例10: GetValue
public ValueProviderResult GetValue(string key)
{
ValueProviderResult result=null;
if (this.dictionary.ContainsKey(key))
{
result = new ValueProviderResult(this.dictionary[key],
this.dictionary[key], CultureInfo.CurrentCulture);
}
return result;
}
开发者ID:jfvaleroso,项目名称:WMS_Revised,代码行数:11,代码来源:CryptoValueProvider.cs
示例11: BindMinistryModels
/// <summary>
/// Creates the list of ministries selected by the system users
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
private static List<MinistryModel> BindMinistryModels(ValueProviderResult result)
{
var rawValue = result.RawValue as string[];
if (rawValue == null || rawValue.Length == 0)
{
return null;
}
List<MinistryModel> models = ManageMinistryModelHelper.GetMinistryModels(rawValue);
return models;
}
开发者ID:kscott5,项目名称:HolyAngels,代码行数:16,代码来源:ModelBinderHelper.cs
示例12: GetNonModelValue
internal static object GetNonModelValue(ValueProviderResult result, Type memberType)
{
var innerType = Nullable.GetUnderlyingType(memberType) ?? memberType;
if (innerType.IsEnum)
return Enum.Parse(innerType, result.AttemptedValue);
var value = innerType == typeof(Boolean)
? result.AttemptedValue.Split(',')[0]
: result.AttemptedValue;
return TypeDescriptor.GetConverter(innerType).ConvertFrom(null, CultureInfo.CurrentCulture, value);
}
开发者ID:edurdias,项目名称:RunningObjects,代码行数:13,代码来源:ModelBinder.cs
示例13: GetValue_should_not_throw_exception_when_try_to_convert_value_from_ModelState
public void GetValue_should_not_throw_exception_when_try_to_convert_value_from_ModelState()
{
result = new ValueProviderResult("11/22/2000", "11/22/2000", new CultureInfo("en-US"));
state = new ModelState();
state.Value = result;
viewContext.ViewData.ModelState.Remove("DatePicker1");
viewContext.ViewData.ModelState.Add("DatePicker1", state);
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
Assert.DoesNotThrow(() => datepicker.GetValue(o => (DateTime?)o));
}
开发者ID:hazzik,项目名称:telerikaspnetmvc,代码行数:13,代码来源:InputComponentExtensionsTests.cs
示例14: InputComponentExtensionsTests
public InputComponentExtensionsTests()
{
viewContext = TestHelper.CreateViewContext();
datepicker = DatePickerTestHelper.CreateDatePicker(null, viewContext);
datepicker.Name = "DatePicker1";
result = new ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
state = new ModelState();
state.Value = result;
viewContext.ViewData.ModelState.Add("DatePicker1", state);
currentCulture = CultureInfo.CurrentCulture;
}
开发者ID:hazzik,项目名称:telerikaspnetmvc,代码行数:13,代码来源:InputComponentExtensionsTests.cs
示例15: TryGetValue
public static bool TryGetValue(this IValueProvider valueProvider, string key, out ValueProviderResult result)
{
try
{
result = valueProvider.GetValue(key);
return true;
}
catch
{
result = null;
return false;
}
}
开发者ID:jjeeccaa,项目名称:MyMVCDemoASPX,代码行数:13,代码来源:ValueProviderBinder.cs
示例16: IsValidName
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
bool isValidName = false;
string keyValue = string.Format("{0}:{1}", Name, Argument);
var value = controllerContext.Controller.ValueProvider.GetValue(keyValue);
if (value != null) {
value = new ValueProviderResult(Argument, Argument, null);
controllerContext.Controller.ControllerContext.RouteData.Values[Name] = Argument;
isValidName = true;
}
return isValidName;
}
开发者ID:martinAusBerlin,项目名称:LHFS,代码行数:13,代码来源:MultipleButtonAttribute.cs
示例17: BindStartEndTime
private static string BindStartEndTime(ValueProviderResult result)
{
var rawValue = result.RawValue as string;
if (string.IsNullOrEmpty(rawValue))
{
return null;
}
// Is time valid?
Convert.ToDateTime(string.Format("1/1/2012 {0}", rawValue));
return rawValue.Trim();
}
开发者ID:kscott5,项目名称:HolyAngels,代码行数:13,代码来源:ModelBinderHelper.cs
示例18: ToValueProvider
public IDictionary<string, ValueProviderResult> ToValueProvider() {
CultureInfo currentCulture = CultureInfo.CurrentCulture;
Dictionary<string, ValueProviderResult> dict = new Dictionary<string, ValueProviderResult>(StringComparer.OrdinalIgnoreCase);
string[] keys = AllKeys;
foreach (string key in keys) {
string[] rawValue = GetValues(key);
string attemptedValue = this[key];
ValueProviderResult vpResult = new ValueProviderResult(rawValue, attemptedValue, currentCulture);
dict[key] = vpResult;
}
return dict;
}
开发者ID:ledgarl,项目名称:Samples,代码行数:14,代码来源:FormCollection.cs
示例19: BindModel
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
ValueProviderResult valueResultHours = bindingContext.ValueProvider
.GetValue(bindingContext.ModelName + ".Hours");
ValueProviderResult valueResultMinutes = bindingContext.ValueProvider
.GetValue(bindingContext.ModelName + ".Minutes");
ValueProviderResult valueResultSeconds = bindingContext.ValueProvider
.GetValue(bindingContext.ModelName + ".Seconds");
if (valueResultHours != null || valueResultMinutes != null | valueResultSeconds != null)
{
int hours = 0;
int minutes = 0;
int seconds = 0;
TimeSpan? actualValue = null;
var valueResult = new ValueProviderResult(null, string.Empty, System.Globalization.CultureInfo.CurrentCulture);
var modelState = new ModelState { Value = valueResult };
try
{
if (valueResultHours != null)
{
hours = int.Parse(valueResultHours.AttemptedValue);
}
if (valueResultMinutes != null)
{
minutes = int.Parse(valueResultMinutes.AttemptedValue);
}
if (valueResultSeconds != null)
{
seconds = int.Parse(valueResultSeconds.AttemptedValue);
}
actualValue = new TimeSpan(hours, minutes, seconds);
}
catch (FormatException e)
{
modelState.Errors.Add(e);
}
bindingContext.ModelState.Add(bindingContext.ModelName, modelState);
return actualValue;
}
else
{
return base.BindModel(controllerContext, bindingContext);
}
}
开发者ID:turtlechalk,项目名称:ui-for-aspnet-mvc-examples,代码行数:50,代码来源:TimeSpanModelBinder.cs
示例20: ConvertToCanConvertArraysToArrays
public void ConvertToCanConvertArraysToArrays() {
// Arrange
ValueProviderResult vpr = new ValueProviderResult(new int[] { 1, 20, 42 }, "", CultureInfo.InvariantCulture);
// Act
string[] converted = (string[])vpr.ConvertTo(typeof(string[]));
// Assert
Assert.IsNotNull(converted);
Assert.AreEqual(3, converted.Length);
Assert.AreEqual("1", converted[0]);
Assert.AreEqual("20", converted[1]);
Assert.AreEqual("42", converted[2]);
}
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:14,代码来源:ValueProviderResultTest.cs
注:本文中的System.Web.Mvc.ValueProviderResult类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论