Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor all flickr entities #34

Merged
merged 16 commits into from
Jun 7, 2023
11,076 changes: 11,076 additions & 0 deletions doc/SandCastleDocuments.xml

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion src/Flickr.Net.Core.Test/BlubTest.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
using FlickrNet.Core.Configuration;

namespace Flickr.Net.Core.Test;
/// <summary>
/// The blub test.
/// </summary>

public class BlubTest
{
/// <summary>
/// Tests the.
/// </summary>
[Fact]
public void Test()
{
var t = new FlickrConfigurationSettings();
var t = new FlickrConfiguration();
Assert.NotNull(t);
}

private void TESTTEST()
{
//var t = new Flickr(null, null);
//t.
}
}
37 changes: 37 additions & 0 deletions src/Flickr.Net.Core/Configuration/FlickrConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace FlickrNet.Core.Configuration;
/// <summary>
/// The flickr configuration.
/// </summary>

public class FlickrConfiguration
{
/// <summary>
/// Gets or sets the api key.
/// </summary>
public string ApiKey { get; set; }

/// <summary>
/// Gets or sets the shared secret.
/// </summary>
public string SharedSecret { get; set; }

/// <summary>
/// Gets or sets a value indicating whether cache disabled.
/// </summary>
public bool CacheDisabled { get; set; }

/// <summary>
/// Gets or sets the cache location.
/// </summary>
public string CacheLocation { get; set; }

/// <summary>
/// Gets or sets the cache size.
/// </summary>
public int CacheSize { get; set; } = 0;

/// <summary>
/// Gets or sets the cache timeout.
/// </summary>
public TimeSpan CacheTimeout { get; set; } = TimeSpan.MinValue;
}

This file was deleted.

2 changes: 1 addition & 1 deletion src/Flickr.Net.Core/Entities/ActivityEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Xml;

namespace FlickrNet.Core.Entities;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// A user event on a photo, e.g. Comment or Favourite etc.
Expand Down
84 changes: 28 additions & 56 deletions src/Flickr.Net.Core/Entities/ActivityItem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Xml;

namespace FlickrNet.Core.Entities;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// Activity class used for <see cref="Flickr.ActivityUserPhotos()"/>
/// and <see cref="Flickr.ActivityUserComments"/>.
/// Activity class used for <see cref="Flickr.ActivityUserPhotos()"/> and <see cref="Flickr.ActivityUserComments"/>.
/// </summary>
public sealed class ActivityItem : IFlickrParsable
{
Expand Down Expand Up @@ -49,25 +48,19 @@ public ActivityItem()
/// <summary>
/// The number of new comments within the given time frame.
/// </summary>
/// <remarks>
/// Only applicable for <see cref="Flickr.ActivityUserPhotos()"/>.
/// </remarks>
/// <remarks>Only applicable for <see cref="Flickr.ActivityUserPhotos()"/>.</remarks>
public int NewComments { get; set; }

/// <summary>
/// The number of old comments within the given time frame.
/// </summary>
/// <remarks>
/// Only applicable for <see cref="Flickr.ActivityUserPhotos()"/>.
/// </remarks>
/// <remarks>Only applicable for <see cref="Flickr.ActivityUserPhotos()"/>.</remarks>
public int OldComments { get; set; }

/// <summary>
/// The number of comments on the item.
/// </summary>
/// <remarks>
/// Only applicable for <see cref="Flickr.ActivityUserComments"/>.
/// </remarks>
/// <remarks>Only applicable for <see cref="Flickr.ActivityUserComments"/>.</remarks>
public int Comments { get; set; }

/// <summary>
Expand All @@ -78,9 +71,7 @@ public ActivityItem()
/// <summary>
/// You want more! You got it!
/// </summary>
/// <remarks>
/// Actually, not sure what this it for!
/// </remarks>
/// <remarks>Actually, not sure what this it for!</remarks>
public bool More { get; set; }

/// <summary>
Expand Down Expand Up @@ -111,50 +102,42 @@ public ActivityItem()
/// <summary>
/// The activity item owners buddy icon.
/// </summary>
public string OwnerBuddyIcon
{
get
{
return UtilityMethods.BuddyIcon(OwnerServer, OwnerFarm, OwnerId);
}
}
public string OwnerBuddyIcon => UtilityMethods.BuddyIcon(OwnerServer, OwnerFarm, OwnerId);

/// <summary>
/// If the type is a photoset then this contains the number of photos in the set. Otherwise returns -1.
/// If the type is a photoset then this contains the number of photos in the set. Otherwise
/// returns -1.
/// </summary>
public int? Photos { get; set; }

/// <summary>
/// If this is a photoset then returns the primary photo id, otherwise will be null (<code>Nothing</code> in VB.Net).
/// If this is a photoset then returns the primary photo id, otherwise will be null (
/// <code>Nothing</code>
/// in VB.Net).
/// </summary>
public string PrimaryPhotoId { get; set; }

/// <summary>
/// The number of new notes within the given time frame.
/// </summary>
/// <remarks>
/// Only applicable for photos and when calling <see cref="Flickr.ActivityUserPhotos()"/>.
/// </remarks>
/// <remarks>Only applicable for photos and when calling <see cref="Flickr.ActivityUserPhotos()"/>.</remarks>
public int? NewNotes { get; set; }

/// <summary>
/// The number of old notes within the given time frame.
/// </summary>
/// <remarks>
/// Only applicable for photos and when calling <see cref="Flickr.ActivityUserPhotos()"/>.
/// </remarks>
/// <remarks>Only applicable for photos and when calling <see cref="Flickr.ActivityUserPhotos()"/>.</remarks>
public int? OldNotes { get; set; }

/// <summary>
/// The number of comments on the photo.
/// </summary>
/// <remarks>
/// Only applicable for photos and when calling <see cref="Flickr.ActivityUserComments"/>.
/// </remarks>
/// <remarks>Only applicable for photos and when calling <see cref="Flickr.ActivityUserComments"/>.</remarks>
public int? Notes { get; set; }

/// <summary>
/// If the type is a photo then this contains the number of favourites in the set. Otherwise returns -1.
/// If the type is a photo then this contains the number of favourites in the set. Otherwise
/// returns -1.
/// </summary>
public int? Favorites { get; set; }

Expand Down Expand Up @@ -251,33 +234,22 @@ private void LoadAttributes(XmlReader reader)
switch (reader.LocalName)
{
case "type":
switch (reader.Value)
ItemType = reader.Value switch
{
case "photoset":
ItemType = ActivityItemType.Photoset;
break;

case "photo":
ItemType = ActivityItemType.Photo;
break;

case "gallery":
ItemType = ActivityItemType.Gallery;
break;
}
"photoset" => ActivityItemType.Photoset,
"photo" => ActivityItemType.Photo,
"gallery" => ActivityItemType.Gallery,
_ => ActivityItemType.Unknown,
};
break;

case "media":
switch (reader.Value)
Media = reader.Value switch
{
case "photo":
Media = MediaType.Photos;
break;

case "video":
Media = MediaType.Videos;
break;
}
"photo" => MediaType.Photos,
"video" => MediaType.Videos,
_ => MediaType.None,
};
break;

case "owner":
Expand Down
10 changes: 3 additions & 7 deletions src/Flickr.Net.Core/Entities/Auth.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
namespace FlickrNet.Core.Entities;

using FlickrNet.Core.Entities.Interfaces;
using FlickrNet.Core.Enums;
using FlickrNet.Core.Internals;
using System;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// Successful authentication returns a <see cref="Auth"/> object.
Expand All @@ -12,7 +7,8 @@ namespace FlickrNet.Core.Entities;
public sealed class Auth : IFlickrParsable
{
/// <summary>
/// The authentication token returned by the <see cref="Flickr.AuthGetToken"/> or <see cref="Flickr.AuthCheckToken(string)"/> methods.
/// The authentication token returned by the <see cref="Flickr.AuthGetToken"/> or <see
/// cref="Flickr.AuthCheckToken(string)"/> methods.
/// </summary>
public string Token { get; set; }

Expand Down
10 changes: 5 additions & 5 deletions src/Flickr.Net.Core/Entities/Blog.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace FlickrNet.Core.Entities;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// Provides details of a specific blog, as configured by the user.
/// </summary>
public sealed class Blog : IFlickrParsable
{
/// <summary>
/// The ID Flickr has assigned to the blog. Use this to post to the blog using
/// The ID Flickr has assigned to the blog. Use this to post to the blog using
/// <see cref="Flickr.BlogsPostPhoto(string, string, string, string)"/> or
/// <see cref="Flickr.BlogsPostPhoto(string, string, string, string, string)"/>.
/// </summary>
Expand All @@ -23,8 +23,8 @@ public sealed class Blog : IFlickrParsable
public string BlogUrl { get; set; }

/// <summary>
/// If Flickr stores the password for this then this will be 0, meaning you do not need to pass in the
/// password when posting.
/// If Flickr stores the password for this then this will be 0, meaning you do not need to pass
/// in the password when posting.
/// </summary>
public bool NeedsPassword { get; set; }

Expand Down Expand Up @@ -70,4 +70,4 @@ void IFlickrParsable.Load(System.Xml.XmlReader reader)
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/Flickr.Net.Core/Entities/BlogService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Xml;

namespace FlickrNet.Core.Entities;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// Details of the blog services supported by Flickr. e.g. Twitter, Blogger etc.
Expand Down
2 changes: 1 addition & 1 deletion src/Flickr.Net.Core/Entities/Brand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Xml;

namespace FlickrNet.Core.Entities;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// A particular camera brand.
Expand Down
2 changes: 1 addition & 1 deletion src/Flickr.Net.Core/Entities/Camera.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Xml;

namespace FlickrNet.Core.Entities;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// The details of a particular camera model.
Expand Down
2 changes: 1 addition & 1 deletion src/Flickr.Net.Core/Entities/Cluster.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.ObjectModel;

namespace FlickrNet.Core.Entities;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// A tag cluster (a tag and a group of common sibling tags).
Expand Down
23 changes: 21 additions & 2 deletions src/Flickr.Net.Core/Entities/Collection.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
using System.Collections.ObjectModel;
using System.Xml;

namespace FlickrNet.Core.Entities;
namespace Flickr.Net.Core.Entities;

/// <summary>
/// The collection.
/// </summary>
/// <remarks/>
public sealed class Collection : IFlickrParsable
{
private readonly Collection<CollectionSet> _subsets = new();
private readonly Collection<Collection> _subcollections = new();

/// <remarks/>
/// <summary>
/// Gets or sets the collection id.
/// </summary>
public string CollectionId { get; set; }

/// <remarks/>
/// <summary>
/// Gets or sets the title.
/// </summary>
public string Title { get; set; }

/// <remarks/>
/// <summary>
/// Gets or sets the description.
/// </summary>
public string Description { get; set; }

/// <remarks/>
/// <summary>
/// Gets or sets the icon large.
/// </summary>
public string IconLarge { get; set; }

/// <remarks/>
/// <summary>
/// Gets or sets the icon small.
/// </summary>
public string IconSmall { get; set; }

/// <summary>
Expand Down Expand Up @@ -88,7 +106,8 @@ void IFlickrParsable.Load(XmlReader reader)

reader.MoveToElement();

// If this is an empty collection then skip to next item, which wont be a child, but may be a sibling.
// If this is an empty collection then skip to next item, which wont be a child, but may be
// a sibling.
if (reader.IsEmptyElement)
{
reader.Skip();
Expand Down
Loading