当前位置: 首页>>代码示例>>C#>>正文


C# IObjectFacade.GetDomainObject方法代码示例

本文整理汇总了C#中IObjectFacade.GetDomainObject方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectFacade.GetDomainObject方法的具体用法?C# IObjectFacade.GetDomainObject怎么用?C# IObjectFacade.GetDomainObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IObjectFacade的用法示例。


在下文中一共展示了IObjectFacade.GetDomainObject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectSingleItem

        private ActionResult SelectSingleItem(IObjectFacade nakedObject, IActionFacade action, ObjectAndControlData controlData, IDictionary<string, string> selectedItem) {
            var property = DisplaySingleProperty(controlData, selectedItem);

            if (action == null) {
                SetSelectedReferences(nakedObject, selectedItem);
                return property == null ? View("ObjectEdit", nakedObject.GetDomainObject()) : View("PropertyEdit", new PropertyViewModel(nakedObject.GetDomainObject(), property));
            }
            SetSelectedParameters(nakedObject, action, selectedItem);

            return View(property == null ? "ActionDialog" : "PropertyEdit", new FindViewModel {ContextObject = nakedObject.GetDomainObject(), ContextAction = action, PropertyName = property});
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:11,代码来源:GenericControllerImpl.cs

示例2: GetResultAsEnumerable

 private static IEnumerable GetResultAsEnumerable(IObjectFacade result, IActionFacade contextAction, string propertyName) {
     if (result != null) {
         if (result.Specification.IsCollection && !ContextParameterIsCollection(contextAction, propertyName)) {
             return result.GetDomainObject<IEnumerable>();
         }
         return new List<object> {result.GetDomainObject()};
     }
     return new List<object>();
 }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:9,代码来源:GenericControllerImpl.cs

示例3: GetChoiceValue

 public static object GetChoiceValue(IOidStrategy oidStrategy, IObjectFacade item, ChoiceRelType relType, RestControlFlags flags) {
     string title = SafeGetTitle(item);
     object value = ObjectToPredefinedType(item.GetDomainObject());
     return item.Specification.IsParseable ? value : LinkRepresentation.Create(oidStrategy, relType, flags, new OptionalProperty(JsonPropertyNames.Title, title));
 }
开发者ID:Robin--,项目名称:NakedObjectsFramework,代码行数:5,代码来源:RestUtils.cs

示例4: ExecuteAction

        private ActionResult ExecuteAction(ObjectAndControlData controlData, IObjectFacade nakedObject, IActionFacade action) {
            if (ActionExecutingAsContributed(action, nakedObject) && action.ParameterCount == 1) {
                // contributed action being invoked with a single parm that is the current target
                // no dialog - go straight through 

                var ac = new ArgumentsContextFacade {Values = new Dictionary<string, object>(), ValidateOnly = false};

                if (nakedObject.Specification.IsCollection && !nakedObject.Specification.IsParseable) {
                    var oids = nakedObject.ToEnumerable().Select(no => Facade.OidTranslator.GetOidTranslation(no)).ToArray();
                    var spec = nakedObject.ElementSpecification;

                    var ar = Facade.ExecuteListAction(oids, spec, action.Id, ac);
                    return AppropriateView(controlData, GetResult(ar), action);
                }
                else {
                    var oid = Facade.OidTranslator.GetOidTranslation(nakedObject);
                    var ar = Facade.ExecuteObjectAction(oid, action.Id, ac);

                    return AppropriateView(controlData, GetResult(ar), action);
                }
            }

            if (!action.Parameters.Any()) {
                var ac = new ArgumentsContextFacade {Values = new Dictionary<string, object>(), ValidateOnly = false};
                var oid = Facade.OidTranslator.GetOidTranslation(nakedObject);
                var result = Facade.ExecuteObjectAction(oid, action.Id, ac);

                return AppropriateView(controlData, GetResult(result), action);
            }

            SetDefaults(nakedObject, action);
            // do after any parameters set by contributed action so this takes priority
            SetSelectedParameters(action);
            SetPagingValues(controlData, nakedObject);
            var property = DisplaySingleProperty(controlData, controlData.DataDict);

            return View(property == null ? "ActionDialog" : "PropertyEdit", new FindViewModel {ContextObject = nakedObject.GetDomainObject(), ContextAction = action, PropertyName = property});
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:38,代码来源:GenericControllerImpl.cs

示例5: View

 private ActionResult View(IObjectFacade nakedObject) {
     string viewName = nakedObject.IsViewModelEditView ? "ViewModel" : "ObjectView";
     return View(viewName, nakedObject.GetDomainObject());
 }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:4,代码来源:SystemControllerImpl.cs

示例6: 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));
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:54,代码来源:NakedObjectsController.cs

示例7: AsFile

        protected FileContentResult AsFile(IObjectFacade domainObject) {
            var fileAttachment = domainObject.GetAttachment();

            if (fileAttachment != null) {
                bool addHeader = !string.IsNullOrWhiteSpace(fileAttachment.ContentDisposition);

                if (addHeader) {
                    string dispositionValue = string.Format("{0}; filename={1}", fileAttachment.ContentDisposition, fileAttachment.FileName);
                    Response.AddHeader("Content-Disposition", dispositionValue);
                }

                Stream stream = fileAttachment.Content;
                using (var br = new BinaryReader(stream)) {
                    byte[] bytes = br.ReadBytes((int) stream.Length);
                    var mimeType = fileAttachment.MimeType ?? "image/bmp";

                    // need to use different File overloads or will end up with two content-disposition headers 
                    return addHeader ? File(bytes, mimeType) : File(bytes, mimeType, fileAttachment.FileName);
                }
            }
            var byteArray = domainObject.GetDomainObject<object>() as byte[];
            return File(byteArray, AttachmentContextFacade.DefaultMimeType);
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:23,代码来源:NakedObjectsController.cs

示例8: GetStandalone

        private static MvcHtmlString GetStandalone(HtmlHelper html, IObjectFacade collectionNakedObject, Func<IAssociationFacade, bool> filter, Func<IAssociationFacade, int> order, TagBuilder tag, bool withTitle) {
            Func<IObjectFacade, string> linkFunc = item => html.Object(html.ObjectTitle(item).ToString(), IdConstants.ViewAction, item.Object).ToString();

            string menu = collectionNakedObject.Specification.IsQueryable ? html.MenuOnTransient(collectionNakedObject.GetDomainObject()).ToString() : "";
            string id = collectionNakedObject.Oid == null ? "" : Encode(html.Facade().OidTranslator.GetOidTranslation(collectionNakedObject));

            // can only be standalone and hence page if we have an id 
            tag.InnerHtml += html.CollectionTable(collectionNakedObject, linkFunc, filter, order, !String.IsNullOrEmpty(id), collectionNakedObject.Specification.IsQueryable, withTitle);

            return html.WrapInForm(IdConstants.EditObjectAction,
                html.Facade().GetObjectTypeShortName(collectionNakedObject.GetDomainObject()),
                menu + tag,
                IdConstants.ActionName,
                new RouteValueDictionary(new { id }));
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:15,代码来源:CommonHtmlHelper.cs

示例9: GetBooleanFieldValue

        private static string GetBooleanFieldValue(this HtmlHelper html, IObjectFacade valueNakedObject) {
            var state = valueNakedObject.GetDomainObject<bool?>();

            string img = "unset.png";
            string alt = MvcUi.TriState_NotSet;

            if (state.HasValue) {
                if (state.Value) {
                    img = "checked.png";
                    alt = MvcUi.TriState_True;
                } else {
                    img = "unchecked.png";
                    alt = MvcUi.TriState_False;
                }
            }

            var url = new UrlHelper(html.ViewContext.RequestContext);
            var tag = new TagBuilder("img");
            tag.MergeAttribute("src", url.Content("~/Images/" + img));
            tag.MergeAttribute("alt", alt);

            return tag.ToString();
        }
开发者ID:priaonehaha,项目名称:NakedObjectsFramework,代码行数:23,代码来源:CommonHtmlHelper.cs


注:本文中的IObjectFacade.GetDomainObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。