本文整理汇总了C#中ViewModel类的典型用法代码示例。如果您正苦于以下问题:C# ViewModel类的具体用法?C# ViewModel怎么用?C# ViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ViewModel类属于命名空间,在下文中一共展示了ViewModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: add_material
public void add_material()
{
// Setup
var mock = new Mock();
mock.PrepareProfileDB();
mock.PrepareServicesDB();
mock.PrepareServiceMaterialsDB();
mock.PrepareQuotesDB();
mock.PrepareCustomersDB();
var materialsDB = mock.PrepareMaterialsDB();
new Autonomy().Activate();
var manageMaterialsViewModel = new ManageMaterials.ViewModel();
var viewModel = new ViewModel();
// Test
viewModel.Name = SOME_TEXT;
viewModel.Description = SOME_TEXT;
viewModel.Quantity = SOME_DECIMAL_VALUE.ToString();
viewModel.UnitType = SOME_TEXT;
viewModel.BaseCost = SOME_DECIMAL_VALUE.ToString();
viewModel.MarkupPrice = SOME_DECIMAL_VALUE.ToString();
viewModel.Save.Execute(null);
// Verify
var expected = viewModel.IsSaved && manageMaterialsViewModel.Materials.Single().Name == SOME_TEXT;
Assert.IsTrue(expected);
}
开发者ID:bizmonger,项目名称:QuoteBuilder,代码行数:28,代码来源:_AddMaterial.cs
示例2: DefaultOperationView
/// <summary>
/// Initializes a new instance of the <see cref="DefaultOperationView"/> class.
/// </summary>
public DefaultOperationView()
{
InitializeComponent();
_viewModel = new ViewModel();
this.DataContext = _viewModel;
}
开发者ID:Knatter33,项目名称:AlarmWorkflow,代码行数:10,代码来源:DefaultOperationView.xaml.cs
示例3: Communication
public async Task<ActionResult> Communication()
{
ViewData["time"] = DateTime.UtcNow.ToLongTimeString();
var productIds = _productsDb.Select(p => p.Id).ToList();
var vm = new ViewModel(UIKeysPubSubCache.Communication.ProductsDiv, page => page.Html.Action("Communication", new { model = productIds }));
return ViewModel(vm);
}
开发者ID:padzikm,项目名称:CompositeUI,代码行数:7,代码来源:PubSubCacheController.cs
示例4: ObjectClassViewModel
public ObjectClassViewModel(IViewModelDependencies appCtx,
IZetboxContext dataCtx, ViewModel parent, ObjectClass cls)
: base(appCtx, dataCtx, parent, cls)
{
_cls = cls;
cls.PropertyChanged += ModulePropertyChanged;
}
开发者ID:daszat,项目名称:zetbox,代码行数:7,代码来源:ObjectClassViewModel.cs
示例5: MainWindow
public MainWindow()
{
var dataModel = new ViewModel<Model>(new {Name = "sam"});
dataModel.When(x=>x.Name,"Thelonious").Set(x=>x.Age,51);
DataContext = dataModel;
InitializeComponent();
}
开发者ID:gregnehus,项目名称:VirtualViewModel,代码行数:7,代码来源:MainWindow.xaml.cs
示例6: CollectionPropertyDependencyTest
public void CollectionPropertyDependencyTest()
{
List<string> property_notifications = new List<string>();
Model m = new Model();
m.Items.Add(new Item() { Prop = 42 });
m.Items.Add(new Item() { Prop = 23 });
m.Items.Add(new Item() { Prop = 17 });
ViewModel vm = new ViewModel(m);
m.PropertyChanged += (sender, args) => property_notifications.Add("Model:" + args.PropertyName);
vm.PropertyChanged += (sender, args) => property_notifications.Add("ViewModel:" + args.PropertyName);
var item = new Item() { Prop = 1 };
item.PropertyChanged += (sender, args) => property_notifications.Add("Item:" + args.PropertyName);
m.Items.Add(item);
Assert.AreEqual(1, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("ViewModel:Items"));
property_notifications.Clear();
item.Prop = 42;
Assert.AreEqual(3, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("Item:Prop"));
Assert.IsTrue(property_notifications.Contains("ViewModel:Items")); // Called by Item.Prop changed
Assert.IsTrue(property_notifications.Contains("ViewModel:Items")); // Called by ItemViewModel.PropSquared
property_notifications.Clear();
m.Items.Remove(item);
Assert.AreEqual(1, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("ViewModel:Items"));
}
开发者ID:lycilph,项目名称:Projects,代码行数:33,代码来源:CollectionPropertyDependency.cs
示例7: Submit
public void Submit(ViewModel.PaymentViewModel model)
{
var order = _uow.OrderService.Get(t => t.OrderId == model.OrderId && t.TradeNo == model.TradeNo);
if (order == null)
Response.Redirect("PayError");
model.OrderModel = order;
model.FrontCallbackUrl = Ichari.Common.WebUtils.GetAppSettingValue("FrontPayUrl");
model.BackCallbackUrl = Ichari.Common.WebUtils.GetAppSettingValue("BackPayUrl");
if (model.Source == Model.Enum.PaySource.Donation)
{
model.ProdUrl = Ichari.Common.WebUtils.GetAppSettingValue("DonateUrl");
model.ProdName = Ichari.Common.WebUtils.GetAppSettingValue("DonationName");
}
switch (model.PayWayType)
{
case PayWay.UnionPay :
// 要使用各种Srv必须先使用LoadConf载入配置
UPOPSrv.LoadConf(Server.MapPath("~/conf.xml.config"));
var p = GenParams(model);
var srv = new FrontPaySrv(p);
//写入订单支付记录
SavePayLog(model);
Response.ContentEncoding = srv.Charset;
_log.Info(srv.CreateHtml());
Response.Write(srv.CreateHtml());
break;
}
}
开发者ID:ichari,项目名称:ichari,代码行数:32,代码来源:PaymentController.cs
示例8: OnStartup
public Result OnStartup(UIControlledApplication application)
{
ThisApp = this;
var elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_GenericAnnotation);
_updaterModified = new UpdaterModified(application.ActiveAddInId);
if (!UpdaterRegistry.IsUpdaterRegistered(_updaterModified.GetUpdaterId()))
{
UpdaterRegistry.RegisterUpdater(_updaterModified);
UpdaterRegistry.AddTrigger(_updaterModified.GetUpdaterId(), elementCategoryFilter, Element.GetChangeTypeAny());
}
_updaterAdded = new UpdaterAdded(application.ActiveAddInId);
if (!UpdaterRegistry.IsUpdaterRegistered(_updaterAdded.GetUpdaterId()))
{
UpdaterRegistry.RegisterUpdater(_updaterAdded);
UpdaterRegistry.AddTrigger(_updaterAdded.GetUpdaterId(), elementCategoryFilter, Element.GetChangeTypeElementAddition());
}
_paneId = new DockablePaneId(Guid.NewGuid());
_handler = new RequestHandler();
_exEvent = ExternalEvent.Create(_handler);
_sheetNoteModel = new ViewModel();
_mainPage = new MainPage { Resources = {["ViewModel"] = _sheetNoteModel } };
application.RegisterDockablePane(_paneId, "Sheet Note Manager", (IDockablePaneProvider)_mainPage);
application.ControlledApplication.DocumentClosed += new EventHandler<DocumentClosedEventArgs>(OnDocumentClosed);
application.ControlledApplication.DocumentOpened += new EventHandler<DocumentOpenedEventArgs>(OnDocumentOpened);
return Result.Succeeded;
}
开发者ID:dangwalsh,项目名称:Gensler.SheetNoteManager,代码行数:32,代码来源:Application.cs
示例9: AddEntity
private ViewModel.QuestionSet AddEntity(ViewModel.QuestionSet entity)
{
// Create the new entity
var qs = this.uow.Context.QuestionSets.Create();
qs.Title = entity.Title;
qs.QuestionSetType = uow.Context.QuestionSetTypes.FirstOrDefault(x => x.Id == entity.QuestionSetTypeId);
qs.Active = entity.Active;
qs.ValidFrom = DateTime.Now;
this.uow.Context.QuestionSets.Add(qs);
// Add each question to this question set
// Each question should exist in the database already, so we allow
// this to fail with an exception if it does not
foreach (var question in entity.Questions)
{
qs.Questions.Add(this.uow.Context.Questions.FirstOrDefault(x => x.Id == question));
}
// Submit the changes to the database
this.uow.Save();
// We now have a database Id for this entity
entity.Id = qs.Id;
return entity;
}
开发者ID:richardprice,项目名称:medicalquestionnaire,代码行数:27,代码来源:QuestionSets.cs
示例10: update_service
public void update_service()
{
// Setup
new Bootstrap().Run();
Publish(Messages.REQUEST_SAVE_SERVICE, Mocks.SERVICE_1);
var servicesViewModel = new ManageServices.ViewModel();
servicesViewModel.Load.Execute(null);
var viewModel = new ViewModel();
// Test
var service = servicesViewModel.Services.First();
viewModel.ServiceToUpdate = servicesViewModel.Services.First();
viewModel.Name = SOME_OTHER_TEXT;
viewModel.Materials = service.Materials;
viewModel.TaxPercentage = service.TaxPercentage.ToString();
viewModel.LaborCost = service.LaborCost.ToString();
viewModel.Description = service.Description;
viewModel.Update.Execute(null);
// Verify
var expected = viewModel.IsUpdated && Mocks.SERVICE_1.Name == SOME_OTHER_TEXT;
Assert.IsTrue(expected);
}
开发者ID:bizmonger,项目名称:QuoteBuilder,代码行数:26,代码来源:_EditService.cs
示例11: ActivityLauncher
public ActivityLauncher(
ActivityService activityService,
ViewModel.Factory viewModelFactory)
{
this.activityService = activityService;
this.viewModelFactory = viewModelFactory;
}
开发者ID:rtaylornc,项目名称:IntelliMediaCore,代码行数:7,代码来源:ActivityLauncher.cs
示例12: VideoInfo
public VideoInfo(ViewModel.INode node)
: this()
{
Context = node;
LoadVideoDetails();
}
开发者ID:chris-tomich,项目名称:Glyma,代码行数:7,代码来源:VideoInfo.cs
示例13: MultipleModelsDependenciesTest
public void MultipleModelsDependenciesTest()
{
List<string> property_notifications = new List<string>();
ModelA ma = new ModelA() { PropA = 1 };
ModelB mb = new ModelB() { PropB = 2 };
ViewModel vm = new ViewModel(ma, mb);
int current_total;
ma.PropertyChanged += (sender, args) => property_notifications.Add("ModelA:" + args.PropertyName);
mb.PropertyChanged += (sender, args) => property_notifications.Add("ModelB:" + args.PropertyName);
vm.PropertyChanged += (sender, args) => property_notifications.Add("ViewModel:" + args.PropertyName);
ma.PropA = 2;
Assert.AreEqual(2, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("ModelA:PropA"));
Assert.IsTrue(property_notifications.Contains("ViewModel:Total"));
property_notifications.Clear();
mb.PropB = 40;
Assert.AreEqual(2, property_notifications.Count);
Assert.IsTrue(property_notifications.Contains("ModelB:PropB"));
Assert.IsTrue(property_notifications.Contains("ViewModel:Total"));
var total_property = TypeDescriptor.GetProperties(vm)["Total"];
var total = total_property.GetValue(vm);
Assert.AreEqual(42, total);
}
开发者ID:lycilph,项目名称:Projects,代码行数:30,代码来源:MultipleModelsDependencies.cs
示例14: add_service_material
public void add_service_material()
{
// Setup
new Bootstrap().Run();
Mocks.SERVICE_1.Materials.Clear();
Publish(Messages.REQUEST_SAVE_SERVICE, Mocks.SERVICE_1);
Publish(Messages.REQUEST_SAVE_MATERIAL, Mocks.MATERIAL_1);
Subscribe(Messages.REQUEST_SELECTED_SERVICE, obj =>
Publish(Messages.REQUEST_SELECTED_SERVICE_RESPONSE, Mocks.SERVICE_1));
var viewModel = new ViewModel();
// Test
viewModel.SelectedMaterialFromCache = viewModel.Materials.FirstOrDefault();
viewModel.Add.Execute(null);
// Verify
var expected = viewModel.AssignedMaterials.Single() != null &&
!viewModel.Materials.Any();
Assert.IsTrue(expected);
}
开发者ID:bizmonger,项目名称:QuoteBuilder,代码行数:25,代码来源:_ManageServiceMaterials.cs
示例15: AssemblyViewModel
public AssemblyViewModel(
IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent,
Assembly obj)
: base(appCtx, dataCtx, parent, obj)
{
_assembly = obj;
}
开发者ID:jrgcubano,项目名称:zetbox,代码行数:7,代码来源:AssemblyViewModel.cs
示例16: Add
public ActionResult Add(ViewModel.Newsletter.newsletterItem item)
{
if (db.tbl_newsletterUser.Any(a => a.email == item.email))
{
return Json(new { isSuccess = "No", msg = lang.mailExist });
}
try
{
if (ModelState.IsValid)
{
var newItem = new tbl_newsletterUser();
newItem.email = item.email;
newItem.createTime = DateTime.Now;
newItem.ipNo = getUserIP();
db.tbl_newsletterUser.Add(newItem);
db.SaveChanges();
return Json(new { isSuccess = "Ok", msg = lang.newsletterSuccessMsg });
}
else
{
string errorMessages = string.Join("<br />", ModelState.Values.Where(E => E.Errors.Count > 0).SelectMany(E => E.Errors).Select(E => E.ErrorMessage).ToArray());
return Json(new { isSuccess = "No", msg = errorMessages });
}
}
catch (Exception ex)
{
errorSend(ex, "Newsletter Kayıt İşleminde");
return Json(new { isSuccess = "No", msg = lang.unexpectedErrorMsg });
}
}
开发者ID:erkanAslanel,项目名称:titizOto,代码行数:34,代码来源:NewsletterController.cs
示例17: Display_view_model
public void Display_view_model()
{
var vm = new ViewModel
{
GameScore = 12,
GameFinished = true
};
var frames = new List<ListViewItem>();
for (var i = 12; i > 0; i--)
{
var lvm = new ListViewItem(i.ToString());
lvm.SubItems.Add(i.ToString());
lvm.SubItems.Add((i+1).ToString());
lvm.SubItems.Add((i + i + 1).ToString());
frames.Add(lvm);
}
vm.Frames = frames;
var sut = new UI();
sut.Display(vm);
sut.ShowDialog();
}
开发者ID:ralfw,项目名称:dnp2013,代码行数:25,代码来源:test_UI.cs
示例18: MainWindow
public MainWindow()
{
var vm = new ViewModel();
DataContext = vm;
InitializeComponent();
}
开发者ID:Carlluna2001,项目名称:WPF_TemplateDemo-,代码行数:7,代码来源:MainWindow.xaml.cs
示例19: ExportTypeEditor
/// <summary>
/// Initializes a new instance of the <see cref="ExportTypeEditor"/> class.
/// </summary>
public ExportTypeEditor()
{
InitializeComponent();
_viewModel = new ViewModel();
this.DataContext = _viewModel;
}
开发者ID:happy5217744,项目名称:AlarmWorkflow,代码行数:10,代码来源:ExportTypeEditor.xaml.cs
示例20: Index
public Task<ViewResult> Index()
{
return Task<ViewResult>.Factory.StartNew(() =>
{
using (var client = new NewsServiceClient())
{
var timer = new Stopwatch();
timer.Start();
var worldNews = client.GetWorldNews();
var sportNews = client.GetSportNews();
var funNews = client.GetFunNews();
var result = worldNews
.Union(sportNews)
.Union(funNews)
.Convert();
timer.Stop();
var model = new ViewModel { News = result, Elapsed = timer.Elapsed };
return View(model);
}
});
}
开发者ID:eugeneagafonov,项目名称:ConferenceDemos,代码行数:26,代码来源:NewAsyncController.cs
注:本文中的ViewModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论