Пример #1
0
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if (source == null || serializer == null)
            {
                return;
            }
            base.Copy(source, serializer);

            var typedSource = source as Folder;

            if (typedSource != null)
            {
                FileCount         = typedSource.FileCount;
                Children          = typedSource.Children;
                HasRemoteChildren = typedSource.HasRemoteChildren;
                Info           = typedSource.Info;
                Redirection    = typedSource.Redirection;
                FavoriteFolder = typedSource.FavoriteFolder;
                ZoneService    = typedSource.ZoneService;
            }
            else
            {
                JToken token;
                if (source.TryGetProperty("FileCount", out token) && token.Type != JTokenType.Null)
                {
                    FileCount = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
                if (source.TryGetProperty("Children", out token) && token.Type != JTokenType.Null)
                {
                    Children = (IEnumerable <Item>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable <Item>));
                }
                if (source.TryGetProperty("HasRemoteChildren", out token) && token.Type != JTokenType.Null)
                {
                    HasRemoteChildren = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("Info", out token) && token.Type != JTokenType.Null)
                {
                    Info = (ItemInfo)serializer.Deserialize(token.CreateReader(), typeof(ItemInfo));
                }
                if (source.TryGetProperty("Redirection", out token) && token.Type != JTokenType.Null)
                {
                    Redirection = (Redirection)serializer.Deserialize(token.CreateReader(), typeof(Redirection));
                }
                if (source.TryGetProperty("FavoriteFolder", out token) && token.Type != JTokenType.Null)
                {
                    FavoriteFolder = (FavoriteFolder)serializer.Deserialize(token.CreateReader(), typeof(FavoriteFolder));
                }
                if (source.TryGetProperty("ZoneService", out token) && token.Type != JTokenType.Null)
                {
                    ZoneService = (SafeEnum <ZoneService>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum <ZoneService>));
                }
            }
        }
Пример #2
0
        public bool Equals(SafeEnum <TEnumSource> other)
        {
            if (Enum.HasValue && other.Enum.HasValue)
            {
                return(Enum.Value.Equals(other.Enum.Value));
            }
            if (Value != null && other.Value != null)
            {
                return(String.Equals(Value, other.Value, StringComparison.OrdinalIgnoreCase));
            }

            return(true);
        }
Пример #3
0
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if (source == null || serializer == null)
            {
                return;
            }
            base.Copy(source, serializer);

            var typedSource = source as Share;

            if (typedSource != null)
            {
                AliasID          = typedSource.AliasID;
                ShareType        = typedSource.ShareType;
                Title            = typedSource.Title;
                HasSentMessage   = typedSource.HasSentMessage;
                SentMessageTitle = typedSource.SentMessageTitle;
                RequireLogin     = typedSource.RequireLogin;
                RequireUserInfo  = typedSource.RequireUserInfo;
                Parent           = typedSource.Parent;
                Creator          = typedSource.Creator;
                User             = typedSource.User;
                Items            = typedSource.Items;
                CreationDate     = typedSource.CreationDate;
                ExpirationDate   = typedSource.ExpirationDate;
                MaxDownloads     = typedSource.MaxDownloads;
                TotalDownloads   = typedSource.TotalDownloads;
                IsViewOnly       = typedSource.IsViewOnly;
                TrackUntilDate   = typedSource.TrackUntilDate;
                SendFrequency    = typedSource.SendFrequency;
                SendInterval     = typedSource.SendInterval;
                LastDateSent     = typedSource.LastDateSent;
                IsConsumed       = typedSource.IsConsumed;
                IsRead           = typedSource.IsRead;
                IsArchived       = typedSource.IsArchived;
                SendTool         = typedSource.SendTool;
                SendMethod       = typedSource.SendMethod;
                UsesStreamIDs    = typedSource.UsesStreamIDs;
                Uri               = typedSource.Uri;
                Recipients        = typedSource.Recipients;
                Zone              = typedSource.Zone;
                Signature         = typedSource.Signature;
                HasRemoteChildren = typedSource.HasRemoteChildren;
                Redirection       = typedSource.Redirection;
                ShareSubType      = typedSource.ShareSubType;
            }
            else
            {
                JToken token;
                if (source.TryGetProperty("AliasID", out token) && token.Type != JTokenType.Null)
                {
                    AliasID = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if (source.TryGetProperty("ShareType", out token) && token.Type != JTokenType.Null)
                {
                    ShareType = (SafeEnum <ShareType>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum <ShareType>));
                }
                if (source.TryGetProperty("Title", out token) && token.Type != JTokenType.Null)
                {
                    Title = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if (source.TryGetProperty("HasSentMessage", out token) && token.Type != JTokenType.Null)
                {
                    HasSentMessage = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("SentMessageTitle", out token) && token.Type != JTokenType.Null)
                {
                    SentMessageTitle = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if (source.TryGetProperty("RequireLogin", out token) && token.Type != JTokenType.Null)
                {
                    RequireLogin = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("RequireUserInfo", out token) && token.Type != JTokenType.Null)
                {
                    RequireUserInfo = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("Parent", out token) && token.Type != JTokenType.Null)
                {
                    Parent = (Item)serializer.Deserialize(token.CreateReader(), typeof(Item));
                }
                if (source.TryGetProperty("Creator", out token) && token.Type != JTokenType.Null)
                {
                    Creator = (User)serializer.Deserialize(token.CreateReader(), typeof(User));
                }
                if (source.TryGetProperty("User", out token) && token.Type != JTokenType.Null)
                {
                    User = (User)serializer.Deserialize(token.CreateReader(), typeof(User));
                }
                if (source.TryGetProperty("Items", out token) && token.Type != JTokenType.Null)
                {
                    Items = (IEnumerable <Item>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable <Item>));
                }
                if (source.TryGetProperty("CreationDate", out token) && token.Type != JTokenType.Null)
                {
                    CreationDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if (source.TryGetProperty("ExpirationDate", out token) && token.Type != JTokenType.Null)
                {
                    ExpirationDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if (source.TryGetProperty("MaxDownloads", out token) && token.Type != JTokenType.Null)
                {
                    MaxDownloads = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
                if (source.TryGetProperty("TotalDownloads", out token) && token.Type != JTokenType.Null)
                {
                    TotalDownloads = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
                if (source.TryGetProperty("IsViewOnly", out token) && token.Type != JTokenType.Null)
                {
                    IsViewOnly = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("TrackUntilDate", out token) && token.Type != JTokenType.Null)
                {
                    TrackUntilDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if (source.TryGetProperty("SendFrequency", out token) && token.Type != JTokenType.Null)
                {
                    SendFrequency = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
                if (source.TryGetProperty("SendInterval", out token) && token.Type != JTokenType.Null)
                {
                    SendInterval = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
                if (source.TryGetProperty("LastDateSent", out token) && token.Type != JTokenType.Null)
                {
                    LastDateSent = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if (source.TryGetProperty("IsConsumed", out token) && token.Type != JTokenType.Null)
                {
                    IsConsumed = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("IsRead", out token) && token.Type != JTokenType.Null)
                {
                    IsRead = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("IsArchived", out token) && token.Type != JTokenType.Null)
                {
                    IsArchived = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("SendTool", out token) && token.Type != JTokenType.Null)
                {
                    SendTool = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if (source.TryGetProperty("SendMethod", out token) && token.Type != JTokenType.Null)
                {
                    SendMethod = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if (source.TryGetProperty("UsesStreamIDs", out token) && token.Type != JTokenType.Null)
                {
                    UsesStreamIDs = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("Uri", out token) && token.Type != JTokenType.Null)
                {
                    Uri = (Uri)serializer.Deserialize(token.CreateReader(), typeof(Uri));
                }
                if (source.TryGetProperty("Recipients", out token) && token.Type != JTokenType.Null)
                {
                    Recipients = (IEnumerable <ShareAlias>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable <ShareAlias>));
                }
                if (source.TryGetProperty("Zone", out token) && token.Type != JTokenType.Null)
                {
                    Zone = (Zone)serializer.Deserialize(token.CreateReader(), typeof(Zone));
                }
                if (source.TryGetProperty("Signature", out token) && token.Type != JTokenType.Null)
                {
                    Signature = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if (source.TryGetProperty("HasRemoteChildren", out token) && token.Type != JTokenType.Null)
                {
                    HasRemoteChildren = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if (source.TryGetProperty("Redirection", out token) && token.Type != JTokenType.Null)
                {
                    Redirection = (Redirection)serializer.Deserialize(token.CreateReader(), typeof(Redirection));
                }
                if (source.TryGetProperty("ShareSubType", out token) && token.Type != JTokenType.Null)
                {
                    ShareSubType = (SafeEnum <ShareSubType>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum <ShareSubType>));
                }
            }
        }