# @umm/accessor_utility_core

> Accessor Utility

Latest version **1.0.8** (published 2017-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @umm/accessor_utility_core
pnpm add @umm/accessor_utility_core
yarn add @umm/accessor_utility_core
bun add @umm/accessor_utility_core
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2017-09-11 |
| First published | 2017-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 0 |
| Author | Tetsuya Mori |
| Maintainers | takyama, risacankidsstar, mkaya, hanage, fakestarbaby, monry |

## Links

- npm: https://www.npmjs.com/package/@umm/accessor_utility_core
- Repository: https://github.com/umm-projects/accessor_utility_core
- Issues: https://github.com/umm-projects/accessor_utility_core/issues
- npm.io page: https://npm.io/package/@umm/accessor_utility_core

## Dependencies (4)

- [ncp](https://npm.io/package/ncp.md) ^2.0.0
- [glob](https://npm.io/package/glob.md) ^7.1.2
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.1

## Recent versions

- 1.0.8 (latest) — 2017-09-11
- 1.0.7 — 2017-08-11
- 1.0.6 — 2017-07-27
- 1.0.5 — 2017-07-27
- 1.0.4 — 2017-07-27
- 1.0.3 — 2017-07-25
- 1.0.2 — 2017-07-21

## README

# What?

アクセサ (もどき) として任意のオブジェクトからアクセスさせる際の型ベースのデータストアを提供します。

# Why?

* `ConditionalWeakTable` が使いたい！
* しかし Unity は2017年7月現在、 .NET 3.5 系である
    * Experimental として .NET 4.6 を選択可能ではある
* 無いなら作っちまおう！

# Install

```shell
$ npm install github:umm-projects/accessor_utility_core.git
```

# Usage

* 正直、このパッケージだけでは殆ど何もできません。
* こいつが提供する `AccessorUtility` を継承したクラスをこさえてください。
* んで、それっぽい interface でも書いて、それの拡張クラスとしてアクセサもどきを実装します。

```csharp
using UnityEngine;
using AccessorUtility;

// 別に継承しなくても良いんだけど、毎回 Generic 書くのダルいので
public class SampleAccessor : AccessorUtility<MonoBehaviour, Component> {}

// interface として提供するコトで、ちょっと DI っぽく実装できます
public interface IRectTransformAccessor {
}

public static class RectTransformAccessorExtension {

    // この拡張メソッド内でデータストアにインスタンスを保持します
    // 型ベースなので、複数のキーを持たせて…、みたいなのは無理っす
    public static RectTransform RectTransform(this IRectTransformAccessor self) {
        // ココが強引なんだよなぁ…。
        MonoBehaviour instance = (MonoBehaviour)self;
        return SampleAccessor.instanceMapMap[instance][typeof(RectTransform)];
    }

}

public class Hoge : MonoBehaviour, IRectTransformAccessor {

    public void Start() {
        Debug.Log(this.RectTransform().sizeDelta);
    }

}
```

# License

Copyright (c) 2017 Tetsuya Mori

Released under the MIT license, see [LICENSE.txt](LICENSE.txt)

---
_Source: https://npm.io/package/@umm/accessor_utility_core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
