public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as ConnectorGroupAccessControl;
            if(typedSource != null)
            {
                Principal = typedSource.Principal;
                CanManage = typedSource.CanManage;
                CanCreate = typedSource.CanCreate;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("Principal", out token) && token.Type != JTokenType.Null)
                {
                    Principal = (Principal)serializer.Deserialize(token.CreateReader(), typeof(Principal));
                }
                if(source.TryGetProperty("CanManage", out token) && token.Type != JTokenType.Null)
                {
                    CanManage = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("CanCreate", out token) && token.Type != JTokenType.Null)
                {
                    CanCreate = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
            }
        }
Example #2
0
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as FileLock;
            if(typedSource != null)
            {
                LockId = typedSource.LockId;
                LockType = typedSource.LockType;
                Owner = typedSource.Owner;
                ExpirationTimeInMinutes = typedSource.ExpirationTimeInMinutes;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("LockId", out token) && token.Type != JTokenType.Null)
                {
                    LockId = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("LockType", out token) && token.Type != JTokenType.Null)
                {
                    LockType = (SafeEnum<LockType>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<LockType>));
                }
                if(source.TryGetProperty("Owner", out token) && token.Type != JTokenType.Null)
                {
                    Owner = (Principal)serializer.Deserialize(token.CreateReader(), typeof(Principal));
                }
                if(source.TryGetProperty("ExpirationTimeInMinutes", out token) && token.Type != JTokenType.Null)
                {
                    ExpirationTimeInMinutes = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
            }
        }
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as AccessControl;
            if(typedSource != null)
            {
                Item = typedSource.Item;
                Principal = typedSource.Principal;
                CanUpload = typedSource.CanUpload;
                CanDownload = typedSource.CanDownload;
                CanView = typedSource.CanView;
                CanDelete = typedSource.CanDelete;
                CanManagePermissions = typedSource.CanManagePermissions;
                NotifyOnUpload = typedSource.NotifyOnUpload;
                NotifyOnDownload = typedSource.NotifyOnDownload;
                IsOwner = typedSource.IsOwner;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("Item", out token) && token.Type != JTokenType.Null)
                {
                    Item = (Item)serializer.Deserialize(token.CreateReader(), typeof(Item));
                }
                if(source.TryGetProperty("Principal", out token) && token.Type != JTokenType.Null)
                {
                    Principal = (Principal)serializer.Deserialize(token.CreateReader(), typeof(Principal));
                }
                if(source.TryGetProperty("CanUpload", out token) && token.Type != JTokenType.Null)
                {
                    CanUpload = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("CanDownload", out token) && token.Type != JTokenType.Null)
                {
                    CanDownload = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("CanView", out token) && token.Type != JTokenType.Null)
                {
                    CanView = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("CanDelete", out token) && token.Type != JTokenType.Null)
                {
                    CanDelete = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("CanManagePermissions", out token) && token.Type != JTokenType.Null)
                {
                    CanManagePermissions = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("NotifyOnUpload", out token) && token.Type != JTokenType.Null)
                {
                    NotifyOnUpload = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("NotifyOnDownload", out token) && token.Type != JTokenType.Null)
                {
                    NotifyOnDownload = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("IsOwner", out token) && token.Type != JTokenType.Null)
                {
                    IsOwner = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
            }
        }