本文整理汇总了C#中NakedObjects.Web.Mvc.Models.ObjectAndControlData.GetAction方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectAndControlData.GetAction方法的具体用法?C# ObjectAndControlData.GetAction怎么用?C# ObjectAndControlData.GetAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NakedObjects.Web.Mvc.Models.ObjectAndControlData
的用法示例。
在下文中一共展示了ObjectAndControlData.GetAction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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});
}
示例2: 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);
}
示例3: 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
});
}
示例4: 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);
}
示例5: GetPageSize
internal int GetPageSize(ObjectAndControlData controlData) {
if (controlData.DataDict.ContainsKey(IdConstants.PageSizeKey)) {
return int.Parse(controlData.DataDict[IdConstants.PageSizeKey]);
}
if (!string.IsNullOrEmpty(controlData.PageSize)) {
return int.Parse(controlData.PageSize);
}
var action = controlData.GetAction(Facade);
return action != null ? action.PageSize : 0;
}
示例6: 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;
}
示例7: AddAttemptedValues
internal void AddAttemptedValues(ObjectAndControlData controlData) {
var action = controlData.GetAction(Facade);
var form = controlData.Form;
foreach (var parm in action.Parameters) {
string name = IdHelper.GetParameterInputId(action, parm);
ValueProviderResult vp = form.GetValue(name);
string[] values = vp == null ? new string[] {} : (string[]) vp.RawValue;
if (parm.Specification.IsCollection && !parm.Specification.IsParseable) {
// handle collection mementos
if (parm.IsChoicesEnabled == Choices.Multiple || !CheckForAndAddCollectionMementoNew(name, values, controlData)) {
var itemSpec = parm.ElementType;
var itemvalues = values.Select(v => itemSpec.IsParseable ? (object) v : GetNakedObjectFromId(v).GetDomainObject<object>()).ToList();
if (itemvalues.Any()) {
var no = Facade.GetObject(itemvalues);
AddAttemptedValue(name, no);
}
}
}
else {
string value = values.Any() ? values.First() : "";
if (!string.IsNullOrEmpty(value)) {
AddAttemptedValue(name, parm.Specification.IsParseable ? (object) value : FilterCollection(GetNakedObjectFromId(value), controlData));
}
}
}
}