本文整理汇总了C#中NakedObjects.Web.Mvc.Models.ObjectAndControlData.GetNakedObject方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectAndControlData.GetNakedObject方法的具体用法?C# ObjectAndControlData.GetNakedObject怎么用?C# ObjectAndControlData.GetNakedObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NakedObjects.Web.Mvc.Models.ObjectAndControlData
的用法示例。
在下文中一共展示了ObjectAndControlData.GetNakedObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditObject
public virtual ActionResult EditObject(ObjectAndControlData controlData, FormCollection form) {
Decrypt(form);
controlData.Form = form;
var nakedObject = controlData.GetNakedObject(Facade);
SetExistingCollectionFormats(form);
if (nakedObject.IsNotPersistent) {
RefreshTransient(nakedObject, form);
}
switch (controlData.SubAction) {
case (ObjectAndControlData.SubActionType.Action):
SetNewCollectionFormats(controlData);
return ActionOnNotPersistentObject(controlData);
case (ObjectAndControlData.SubActionType.None):
AddAttemptedValuesNew(nakedObject, controlData);
return View("ObjectEdit", nakedObject.GetDomainObject());
case (ObjectAndControlData.SubActionType.Pager):
SetNewCollectionFormats(controlData);
return AppropriateView(controlData, nakedObject);
case (ObjectAndControlData.SubActionType.Redisplay):
return Redisplay(controlData);
}
Log.ErrorFormat("SubAction handling not implemented in EditObject for {0}", controlData.SubAction.ToString());
throw new NotImplementedException(controlData.SubAction.ToString());
}
示例2: Details
public virtual ActionResult Details(ObjectAndControlData controlData) {
Debug.Assert(controlData.SubAction == ObjectAndControlData.SubActionType.Details ||
controlData.SubAction == ObjectAndControlData.SubActionType.None);
var nakedObject = controlData.GetNakedObject(Facade);
nakedObject = FilterCollection(nakedObject, controlData);
SetNewCollectionFormats(controlData);
return AppropriateView(controlData, nakedObject);
}
示例3: Select
private ActionResult Select(ObjectAndControlData controlData) {
return SelectSingleItem(controlData.GetNakedObject(Facade), null, controlData, controlData.DataDict);
}
示例4: ApplyEditAction
private ActionResult ApplyEditAction(ObjectAndControlData controlData) {
var nakedObject = controlData.GetNakedObject(Facade);
var ok = ApplyEdit(nakedObject, controlData);
if (ok) {
string targetActionId = controlData.DataDict["targetActionId"];
var oid = Facade.OidTranslator.GetOidTranslation(nakedObject);
var targetAction = Facade.GetObjectAction(oid, targetActionId).Action;
return ExecuteAction(controlData, nakedObject, targetAction);
}
return View("ViewModel", nakedObject.GetDomainObject());
}
示例5: Redisplay
private ActionResult Redisplay(ObjectAndControlData controlData) {
SetNewCollectionFormats(controlData);
var property = DisplaySingleProperty(controlData, controlData.DataDict);
var isEdit = bool.Parse(controlData.DataDict["editMode"]);
var nakedObject = controlData.GetNakedObject(Facade);
return property == null ? View(isEdit ? "ObjectEdit" : "ObjectView", nakedObject.GetDomainObject()) :
View(isEdit ? "PropertyEdit" : "PropertyView", new PropertyViewModel(nakedObject.GetDomainObject(), property));
}
示例6: ApplyEdit
private ActionResult ApplyEdit(ObjectAndControlData controlData) {
var nakedObject = controlData.GetNakedObject(Facade);
var viewName = ApplyEdit(nakedObject, controlData) ? "ObjectView" : "ObjectEdit";
return View(viewName, nakedObject.GetDomainObject());
}
示例7: ApplyEditAndClose
private ActionResult ApplyEditAndClose(ObjectAndControlData controlData) {
var nakedObject = controlData.GetNakedObject(Facade);
if (ApplyEdit(nakedObject, controlData)) {
// last object or home
object lastObject = Session.LastObject(Facade, ObjectCache.ObjectFlag.BreadCrumb);
if (lastObject == null) {
return RedirectHome();
}
nakedObject = Facade.GetObject(lastObject);
return AppropriateView(controlData, nakedObject);
}
return View("ObjectEdit", nakedObject.GetDomainObject());
}
示例8: AppropriateView
internal ActionResult AppropriateView(ObjectAndControlData controlData, IObjectFacade nakedObject, IActionFacade action = null, string propertyName = null) {
if (nakedObject == null) {
// no object to go to
// if action on object go to that object.
// if action on collection go to collection
// if action on service go to last object
nakedObject = controlData.GetNakedObject(Facade);
if (nakedObject.Specification.IsService) {
object lastObject = Session.LastObject(Facade, ObjectCache.ObjectFlag.BreadCrumb);
if (lastObject == null) {
return RedirectHome();
}
nakedObject = Facade.GetObject(lastObject);
}
if (nakedObject.IsCollectionMemento) {
// if we have returned null and existing object is collection memento need to make
// sure action remains action from original collectionMemento.
action = nakedObject.MementoAction;
}
}
if (nakedObject.Specification.IsCollection && !nakedObject.Specification.IsParseable) {
int collectionSize = nakedObject.Count();
if (collectionSize == 1) {
// remove any paging data - to catch case where custom page has embedded standalone collection as paging data will confuse rendering
ViewData.Remove(IdConstants.PagingData);
// is this safe TODO !!
return View("ObjectView", nakedObject.ToEnumerable().First().GetDomainObject());
}
nakedObject = Page(nakedObject, collectionSize, controlData);
// todo is there a better way to do this ?
action = action ?? nakedObject.MementoAction;
int page, pageSize;
CurrentlyPaging(controlData, collectionSize, out page, out pageSize);
var format = ViewData["NofCollectionFormat"] as string;
return View("StandaloneTable", ActionResultModel.Create(Facade, action, nakedObject, page, pageSize, format));
}
// remove any paging data - to catch case where custom page has embedded standalone collection as paging data will confuse rendering
ViewData.Remove(IdConstants.PagingData);
if (controlData.DataDict.Values.Contains("max")) {
// maximizing an inline object - do not update history
ViewData.Add("updateHistory", false);
}
return propertyName == null ? View(nakedObject.IsNotPersistent ? "ObjectView" : "ViewNameSetAfterTransaction", nakedObject.GetDomainObject()) :
View(nakedObject.IsNotPersistent ? "PropertyView" : "ViewNameSetAfterTransaction", new PropertyViewModel(nakedObject.GetDomainObject(), propertyName));
}
示例9: SelectOnAction
private ActionResult SelectOnAction(ObjectAndControlData controlData) {
var nakedObjectAction = controlData.GetAction(Facade);
var contextNakedObject = FilterCollection(controlData.GetNakedObject(Facade), controlData);
return SelectSingleItem(contextNakedObject, nakedObjectAction, controlData, controlData.DataDict);
}
示例10: Action
public virtual ActionResult Action(ObjectAndControlData controlData) {
var no = controlData.GetNakedObject(Facade);
var action = controlData.GetAction(Facade);
return View("ActionDialog", new FindViewModel {
ContextObject = no.GetDomainObject(),
ContextAction = action
});
}
示例11: InitialAction
private ActionResult InitialAction(ObjectAndControlData controlData) {
var nakedObject = controlData.GetNakedObject(Facade);
var nakedObjectAction = controlData.GetAction(Facade);
CheckConcurrency(nakedObject, null, controlData, (z, x, y) => IdHelper.GetConcurrencyActionInputId(x, nakedObjectAction, y));
return ExecuteAction(controlData, nakedObject, nakedObjectAction);
}
示例12: Edit
public virtual ActionResult Edit(ObjectAndControlData controlData, FormCollection form) {
Decrypt(form);
controlData.Form = form;
AddFilesToControlData(controlData);
var nakedObject = controlData.GetNakedObject(Facade);
RefreshTransient(nakedObject, form);
SetExistingCollectionFormats(form);
AddAttemptedValuesNew(nakedObject, controlData);
switch (controlData.SubAction) {
case (ObjectAndControlData.SubActionType.Find):
return Find(controlData);
case (ObjectAndControlData.SubActionType.Select):
return Select(controlData);
case (ObjectAndControlData.SubActionType.ActionAsFind):
return ActionAsFind(controlData);
case (ObjectAndControlData.SubActionType.InvokeActionAsFind):
return InvokeActionAsFind(controlData);
case (ObjectAndControlData.SubActionType.InvokeActionAsSave):
return InvokeActionAsSave(controlData);
case (ObjectAndControlData.SubActionType.Redisplay):
return Redisplay(controlData);
case (ObjectAndControlData.SubActionType.None):
return ApplyEdit(controlData);
case (ObjectAndControlData.SubActionType.SaveAndClose):
return ApplyEditAndClose(controlData);
case (ObjectAndControlData.SubActionType.Action):
return ApplyEditAction(controlData);
}
Log.ErrorFormat("SubAction handling not implemented in Edit for {0}", controlData.SubAction.ToString());
throw new NotImplementedException(controlData.SubAction.ToString());
}
示例13: ApplyAction
private ActionResult ApplyAction(ObjectAndControlData controlData) {
var targetNakedObject = FilterCollection(controlData.GetNakedObject(Facade), controlData);
var targetAction = controlData.GetAction(Facade);
CheckConcurrency(targetNakedObject, null, controlData, (z, x, y) => IdHelper.GetConcurrencyActionInputId(x, targetAction, y));
if (targetNakedObject.IsNotPersistent) {
RefreshTransient(targetNakedObject, controlData.Form);
}
// do after any parameters set by contributed action so this takes priority
SetSelectedParameters(targetAction);
var ac = GetParameterValues(targetAction, controlData);
ActionResultContextFacade ar;
if (targetNakedObject.Specification.IsCollection && !targetNakedObject.Specification.IsParseable) {
var oids = targetNakedObject.ToEnumerable().Select(no => Facade.OidTranslator.GetOidTranslation(no)).ToArray();
var spec = targetNakedObject.ElementSpecification;
ar = Facade.ExecuteListAction(oids, spec, targetAction.Id, ac);
}
else {
var oid = Facade.OidTranslator.GetOidTranslation(targetNakedObject);
ar = Facade.ExecuteObjectAction(oid, targetAction.Id, ac);
}
if (!HasError(ar)) {
targetNakedObject.SetIsNotQueryableState(targetAction.IsContributed);
return AppropriateView(controlData, GetResult(ar), targetAction);
}
foreach (var parm in ar.ActionContext.VisibleParameters) {
if (!string.IsNullOrEmpty(parm.Reason)) {
ModelState.AddModelError(IdHelper.GetParameterInputId(targetAction, parm.Parameter), parm.Reason);
}
}
if (!(string.IsNullOrEmpty(ar.ActionContext.Reason))) {
ModelState.AddModelError("", ar.ActionContext.Reason);
}
var property = DisplaySingleProperty(controlData, controlData.DataDict);
return View(property == null ? "ActionDialog" : "PropertyEdit", new FindViewModel {ContextObject = targetNakedObject.GetDomainObject(), ContextAction = targetAction, PropertyName = property});
}
示例14: DisplaySingleProperty
protected string DisplaySingleProperty(ObjectAndControlData controlData, IDictionary<string, string> data) {
if (Request.IsAjaxRequest()) {
var nakedObject = controlData.GetNakedObject(Facade);
if (controlData.SubAction == ObjectAndControlData.SubActionType.Redisplay) {
var assocs = nakedObject.Specification.Properties.Where(p => p.IsCollection && !p.Specification.IsParseable);
var item = assocs.SingleOrDefault(a => data.ContainsKey(a.Id));
return item == null ? null : item.Id;
}
if (controlData.ActionId == null) {
var assocs = nakedObject.Specification.Properties.Where(p => !p.IsCollection || p.Specification.IsParseable);
var item = assocs.SingleOrDefault(a => data.ContainsKey(a.Id));
return item == null ? null : item.Id;
}
{
var parms = controlData.GetAction(Facade).Parameters;
var item = parms.SingleOrDefault(p => data.ContainsKey(p.Id));
return item == null ? null : item.Id;
}
}
return null;
}