コード例 #1
0
        private string LoadJson()
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();

                sb.Append("\"DeleteFlag\":\"" + (DeleteFlag == null ? "" : DeleteFlag.NAME) + "\"");
                sb.Append(",");
                sb.Append("\"IsReadable\":" + IsReadable.ToString().ToLower() + "");
                sb.Append(",");
                sb.Append("\"IsCreatable\":" + IsCreatable.ToString().ToLower() + "");
                sb.Append(",");
                sb.Append("\"IsEditable\":" + IsEditable.ToString().ToLower() + "");
                sb.Append(",");
                sb.Append("\"IsDeletable\":" + IsDeletable.ToString().ToLower() + "");
                sb.Append(",");
                string fEntityKeys = "{" + (FirstEntityKeys.Any() ? FirstEntityKeys.Select(x => "\"" + x.Key + "\":" + js.Serialize(x.Value)).Aggregate((a, b) => a + "," + b) : "") + "}";
                sb.Append("\"FirstEntity\":" + fEntityKeys);

                string baseJson = base.Json;

                baseJson = baseJson.Replace(("\"SecurityZone\":\"" + base.SecurityZone + "\""), ("\"SecurityZone\":\"" + SecurityZone + "\""));

                sb.Append(string.IsNullOrEmpty(baseJson) ? "" : ("," + baseJson));

                sb.Append(",\"AVAILABLE_FORMATS\":[");
                if (AVAILABLE_FORMATS != null && AVAILABLE_FORMATS.Any())
                {
                    sb.Append(AVAILABLE_FORMATS.Select(x => "{" + x.Json + "}").Aggregate((a, b) => a + "," + b));
                }
                sb.Append("]");
                return(sb.ToString());
            }
            catch (Exception e) { WSStatus status = WSStatusBase.NONE.clone(); CFunc.RegError(GetType(), e, ref status); }

            return(string.Empty);
        }
コード例 #2
0
        public new void ReadXmlAttributes(XmlReader reader)
        {
            base.ReadXmlAttributes(reader);

            #region DeleteFlag
            string _DeleteFlag = reader["deleteFlag"];
            if (!string.IsNullOrEmpty(_DeleteFlag) && GetXParam(_DeleteFlag) != null)
            {
                DeleteFlag = (WSTableParam)GetXParam(_DeleteFlag);
            }
            #endregion

            #region IsReadableBySchema
            string _AttrIsReadableBySchema = reader["readable"];
            if (!string.IsNullOrEmpty(_AttrIsReadableBySchema))
            {
                if (_AttrIsReadableBySchema.IsTrue() || _AttrIsReadableBySchema.IsFalse())
                {
                    _IsReadableBySchema = _AttrIsReadableBySchema.IsTrue();
                }
                else
                {
                    _IsReadableBySchema = true;
                    ReadableFilter      = _AttrIsReadableBySchema.ToJson();
                }
            }
            #endregion

            #region IsCreatableBySchema
            string _AttrIsCreatableBySchema = reader["creatable"];
            if (!string.IsNullOrEmpty(_AttrIsCreatableBySchema))
            {
                if (_AttrIsCreatableBySchema.IsTrue() || _AttrIsCreatableBySchema.IsFalse())
                {
                    _IsCreatableBySchema = _AttrIsCreatableBySchema.IsTrue();
                }
                else
                {
                    _IsCreatableBySchema = true;
                    CreatableFilter      = _AttrIsCreatableBySchema.ToJson();
                }
            }
            #endregion

            #region IsEditableBySchema
            string _AttrIsEditableBySchema = reader["editable"];
            if (!string.IsNullOrEmpty(_AttrIsEditableBySchema))
            {
                if (_AttrIsEditableBySchema.IsTrue() || _AttrIsEditableBySchema.IsFalse())
                {
                    _IsEditableBySchema = _AttrIsEditableBySchema.IsTrue();
                }
                else
                {
                    _IsEditableBySchema = true;
                    EditableFilter      = _AttrIsEditableBySchema.ToJson();
                }
            }
            #endregion

            #region IsDeletableBySchema
            string _AttrIsDeletableBySchema = reader["deletable"];
            if (!string.IsNullOrEmpty(_AttrIsDeletableBySchema))
            {
                if (_AttrIsDeletableBySchema.IsTrue() || _AttrIsDeletableBySchema.IsFalse())
                {
                    _IsDeletableBySchema = _AttrIsDeletableBySchema.IsTrue();
                }
                else
                {
                    _IsDeletableBySchema = true;
                    DeletableFilter      = _AttrIsDeletableBySchema.ToJson();
                }
            }
            #endregion

            #region AllowOwnerAccess
            string  _AllowOwnerAccess  = reader["allowOwnerAccess"];
            dynamic _dAllowOwnerAccess = AllowOwnerAccess;
            if (!string.IsNullOrEmpty(_AllowOwnerAccess) && typeof(bool).Read(_AllowOwnerAccess, out _dAllowOwnerAccess))
            {
                AllowOwnerAccess = _dAllowOwnerAccess;
            }
            #endregion

            #region BaseFilter
            try
            {
                string _BaseFilterValue = reader["baseFilter"];
                if (!string.IsNullOrEmpty(_BaseFilterValue))
                {
                    BaseFilter = _BaseFilterValue.ToJson();
                }
            }
            catch (Exception e) { WSStatus status = WSStatusBase.NONE.clone(); CFunc.RegError(GetType(), e, ref status); }

            #endregion
        }