本文整理汇总了C#中Models.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Models.GetType方法的具体用法?C# Models.GetType怎么用?C# Models.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Models
的用法示例。
在下文中一共展示了Models.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Edit
public ActionResult Edit(Models.UserModel item)
{
var properties = new List<string>()
{
"Username",
"FirstName",
"LastName",
"Email",
"IsAdmin"
};
foreach (var property in properties)
{
var propInfo = item.GetType().GetProperty(property);
if (propInfo == null)
{
continue;
}
var val = propInfo.GetValue(item, null);
if (val == null)
{
continue;
}
SetProperty(new Commands.SetUserPropertyCommand
{
UserID = item.Id,
Name = property,
Value = val.ToString()
});
}
return RedirectToAction("Details", new { id=item.Id });
}
示例2: Convert
private void Convert(Models.Question q, QuestionAjax qa)
{
qa.url = Url.Action(q.GetType().Name, "Question", new { guid = q.Guid });
qa.name = q.Description;
qa.question = q.Title;
qa.answer = q.Answer;
if (q is MultipleChoiceQuestion)
{
qa.answers = getMultipleChoiceAnswers(((MultipleChoiceQuestion)q).Answers);
}
else if (q is OddOneOutQuestion)
{
qa.answers = getMultipleChoiceAnswers(((OddOneOutQuestion)q).Answers);
qa.answer += " " + ((OddOneOutQuestion)q).Explanation;
}
else
{
qa.answers = "<span class=\"subtle\">open vraag</span>";
}
}
示例3: GetName
public static string GetName(Models.OrderStatus orderStatus)
{
DisplayAttribute[] attributes = (DisplayAttribute[])orderStatus.GetType().GetField(orderStatus.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false);
return attributes.Length > 0 ? attributes[0].Name : string.Empty;
}
示例4: NavigateToProviderLinkWizard
/// <summary>
/// Navigates the app to the wizard of linking a provider.
/// </summary>
public void NavigateToProviderLinkWizard(Models.Providers.ICartridgeProvider provider)
{
if (provider == null || provider.GetType() != typeof(Models.Providers.OneDriveCartridgeProvider))
{
throw new NotSupportedException();
}
NavigateCore(new Uri(String.Format("/Views/SettingsPage.xaml?{0}={1}&{2}={3}", SettingsViewModel.ProviderServiceNameKey, provider.ServiceName, SettingsViewModel.ProviderWizardKey, Boolean.TrueString), UriKind.Relative));
}