Giter Club home page Giter Club logo

dotnetextra's People

Contributors

in-async avatar

Watchers

 avatar  avatar

Forkers

maikebing

dotnetextra's Issues

Binary を Base16 にリネーム

Binary だと責務が一見して判らない。やっている事は 16 進文字列と byte 配列の相互変換なので、Base16 にリネームする。

併せて、インターフェースも Encode(), TryDecode() 等に揃える。

Encode() に offset / length パラメーターを追加

現状 byte 配列の一部に対してエンコードする為には対象の範囲をいったん byte の部分配列にアロケーションする必要があり無駄なので、エンコード範囲を指定するパラメーターを追加する。

UnixTime 型を追加

ドラフト

/// <summary>
/// UNIX 時間を表す構造体。
/// </summary>
public readonly struct UnixTime {

    /// <summary>
    /// UNIX Epoch (1970-01-01T00:00:00Z)。
    /// </summary>
    public static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

    /// <summary>
    /// 現在の UNIX 時間を表す <see cref="UnixTime"/> を返します。
    /// </summary>
    public static UnixTime Now => new UnixTime(DateTime.Now);

    /// <summary>
    /// <see cref="UnixTime"/> 構造体の新しいインスタンスを初期化します。
    /// </summary>
    /// <param name="date">UNIX 時間の元となる日時。</param>
    public UnixTime(DateTime date) => TimeSpan = date.ToUniversalTime() - Epoch;

    /// <summary>
    /// UNIX 時間を表す秒。
    /// </summary>
    public long Value => (long)TimeSpan.TotalSeconds;

    /// <summary>
    /// UNIX 時間の <see cref="TimeSpan"/> 表現。
    /// </summary>
    public TimeSpan TimeSpan { get; }
}

Base64Url.Encode() にパディング オプションを追加

base64url はパディングの有無が任意な為、現実装は常に省略している。系によってはパディングが必要かもしれないので、オプション引数で対応する。

public static string Encode(byte[] bin, bool padding = false) {

Base64Url の効率化

先ずは単純に、String.Replace() ではなく StringBuilder.Replace() の使用を検討する。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.