示例#1
0
        internal void WriteContentProperty(String path, string propertyName, bool rawValue, PortalContext portalContext, ODataRequest req)
        {
            var content = ODataHandler.LoadContentByVersionRequest(path);

            if (content == null)
            {
                ODataHandler.ContentNotFound(portalContext.OwnerHttpContext, path);
                return;
            }

            if (propertyName == ODataHandler.ActionsPropertyName)
            {
                WriteActionsProperty(portalContext, ODataTools.GetActionItems(content, req).ToArray(), rawValue);
                return;
            }
            if (propertyName == ODataHandler.ChildrenPropertyName)
            {
                WriteChildrenCollection(path, portalContext, req);
                return;
            }

            if (content.Fields.TryGetValue(propertyName, out var field))
            {
                if (field is ReferenceField refField)
                {
                    var refFieldSetting = refField.FieldSetting as ReferenceFieldSetting;
                    var isMultiRef      = true;
                    if (refFieldSetting != null)
                    {
                        isMultiRef = refFieldSetting.AllowMultiple == true;
                    }
                    if (isMultiRef)
                    {
                        WriteMultiRefContents(refField.GetData(), portalContext, req);
                    }
                    else
                    {
                        WriteSingleRefContent(refField.GetData(), portalContext);
                    }
                }
                else if (field is AllowedChildTypesField actField)
                {
                    WriteMultiRefContents(actField.GetData(), portalContext, req);
                }
                else if (!rawValue)
                {
                    WriteSingleContent(portalContext, new Dictionary <string, object> {
                        { propertyName, field.GetData() }
                    });
                }
                else
                {
                    WriteRaw(field.GetData(), portalContext);
                }
            }
            else
            {
                WriteOperationResult(portalContext, req);
            }
        }
示例#2
0
        protected ODataSimpleMeta GetMetadata(Content content, string selfurl, MetadataFormat format)
        {
            if (format == MetadataFormat.Minimal)
            {
                return(new ODataSimpleMeta
                {
                    Uri = selfurl,
                    Type = content.ContentType.Name,
                });
            }

            var snActions = ODataTools.GetActions(content, this.Request).ToArray();

            return(new ODataFullMeta
            {
                Uri = selfurl,
                Type = content.ContentType.Name,
                Actions = snActions.Where(a => a.CausesStateChange && a.IsODataOperation).Select(a => CreateOdataOperation(a, selfurl)).OrderBy(x => x.Title).ToArray(),
                Functions = snActions.Where(a => !a.CausesStateChange && a.IsODataOperation).Select(a => CreateOdataOperation(a, selfurl)).OrderBy(x => x.Title).ToArray(),
            });
        }
示例#3
0
 protected ODataActionItem[] GetActions(Content content)
 {
     return(ODataTools.GetHtmlActionItems(content, this.Request).ToArray());
 }