mirror of https://github.com/SixLabors/ImageSharp
57 changed files with 142 additions and 499 deletions
@ -1,46 +0,0 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
|
|
||||
using System.Collections.Generic; |
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Common.Extensions |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Encapsulates a series of time saving extension methods to the <see cref="T:System.Collections.Generic.List"/> class.
|
|
||||
/// </summary>
|
|
||||
internal static class ListExtensions |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Inserts an item at the given index automatically expanding the capacity if required.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="T">The type of object within the list</typeparam>
|
|
||||
/// <param name="list">The list</param>
|
|
||||
/// <param name="index">The index</param>
|
|
||||
/// <param name="item">The item to insert</param>
|
|
||||
public static void SafeInsert<T>(this List<T> list, int index, T item) |
|
||||
{ |
|
||||
if (index >= list.Count) |
|
||||
{ |
|
||||
list.Add(item); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
list[index] = item; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Removes the last element from a list and returns that element. This method changes the length of the list.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="T">The type of object within the list</typeparam>
|
|
||||
/// <param name="list">The list</param>
|
|
||||
/// <returns>The last element in the specified sequence.</returns>
|
|
||||
public static T Pop<T>(this List<T> list) |
|
||||
{ |
|
||||
int last = list.Count - 1; |
|
||||
T item = list[last]; |
|
||||
list.RemoveAt(last); |
|
||||
return item; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,53 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents the ICC profile version number.
|
||||
|
/// </summary>
|
||||
|
public readonly struct IccVersion : IEquatable<IccVersion> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="IccVersion"/> struct.
|
||||
|
/// </summary>
|
||||
|
/// <param name="major">The major version number.</param>
|
||||
|
/// <param name="minor">The minor version number.</param>
|
||||
|
/// <param name="patch">The patch version number.</param>
|
||||
|
public IccVersion(int major, int minor, int patch) |
||||
|
{ |
||||
|
this.Major = major; |
||||
|
this.Minor = minor; |
||||
|
this.Patch = patch; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the major version number.
|
||||
|
/// </summary>
|
||||
|
public int Major { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the minor version number.
|
||||
|
/// </summary>
|
||||
|
public int Minor { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the patch number.
|
||||
|
/// </summary>
|
||||
|
public int Patch { get; } |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public bool Equals(IccVersion other) => |
||||
|
this.Major == other.Major && |
||||
|
this.Minor == other.Minor && |
||||
|
this.Patch == other.Patch; |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public override string ToString() |
||||
|
{ |
||||
|
return string.Join(".", this.Major, this.Minor, this.Patch); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue