Published angel2_container

This commit is contained in:
thomashii@dukefirehawk.com 2023-04-15 09:07:24 +08:00
parent bdf7d33c54
commit 168c51074b
8 changed files with 56 additions and 10 deletions

View file

@ -47,7 +47,7 @@ void main() async {
//Container container = Container(reflector); //Container container = Container(reflector);
//container.registerSingleton<SalesController>(SalesController()); //container.registerSingleton<SalesController>(SalesController());
// Useing GeneratedReflector // Using GeneratedReflector
initializeReflectable(); initializeReflectable();
var app = Angel(reflector: GeneratedReflector()); var app = Angel(reflector: GeneratedReflector());

View file

@ -1,12 +1,10 @@
# Change Log # Change Log
## 7.1.1 ## 7.1.0-beta.1
* Moved `defaultErrorMessage` to `ContainerConst` class to resolve reflectatable issue.
## 7.1.0
* Require Dart >= 2.18 * Require Dart >= 2.18
* Moved `defaultErrorMessage` to `ContainerConst` class to resolve reflectatable issue.
* Added `hashCode`
## 7.0.0 ## 7.0.0

View file

@ -5,8 +5,41 @@
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container/LICENSE) [![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container/LICENSE)
An better IoC container for Angel3, ultimately allowing Angel3 to be used without `dart:mirrors` package. An better IoC container for Angel3, ultimately allowing Angel3 to be used with or without `dart:mirrors` package.
```dart ```dart
import 'package:angel3_container/angel3_container.dart'; import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
@Expose('/sales', middleware: [process1])
class SalesController extends Controller {
@Expose('/', middleware: [process2])
Future<String> route1(RequestContext req, ResponseContext res) async {
return "Sales route";
}
}
bool process1(RequestContext req, ResponseContext res) {
res.write('Hello, ');
return true;
}
bool process2(RequestContext req, ResponseContext res) {
res.write('From Sales, ');
return true;
}
void main() async {
// Using Mirror Reflector
var app = Angel(reflector: MirrorsReflector());
// Sales Controller
app.container.registerSingleton<SalesController>(SalesController());
await app.mountController<SalesController>();
var http = AngelHttp(app);
var server = await http.startServer('localhost', 3000);
print("Angel server listening at ${http.uri}");
}
``` ```

View file

@ -1,4 +1,5 @@
import '../../angel3_container.dart'; import '../../angel3_container.dart';
import 'package:quiver/core.dart';
final Map<Symbol, String?> _symbolNames = <Symbol, String?>{}; final Map<Symbol, String?> _symbolNames = <Symbol, String?>{};
@ -66,6 +67,9 @@ class _EmptyReflectedClass extends ReflectedClass {
bool operator ==(other) { bool operator ==(other) {
return other is ReflectedClass && other.hashCode == hashCode; return other is ReflectedClass && other.hashCode == hashCode;
} }
@override
int get hashCode => hash2(this, " ");
} }
class _EmptyReflectedType extends ReflectedType { class _EmptyReflectedType extends ReflectedType {
@ -90,6 +94,9 @@ class _EmptyReflectedType extends ReflectedType {
bool operator ==(other) { bool operator ==(other) {
return other is ReflectedType && other.hashCode == hashCode; return other is ReflectedType && other.hashCode == hashCode;
} }
@override
int get hashCode => hash2(this, " ");
} }
class _EmptyReflectedInstance extends ReflectedInstance { class _EmptyReflectedInstance extends ReflectedInstance {
@ -101,6 +108,9 @@ class _EmptyReflectedInstance extends ReflectedInstance {
return other is ReflectedInstance && other.hashCode == hashCode; return other is ReflectedInstance && other.hashCode == hashCode;
} }
@override
int get hashCode => hash2(this, " ");
@override @override
ReflectedInstance getField(String name) { ReflectedInstance getField(String name) {
throw UnsupportedError( throw UnsupportedError(

View file

@ -4,6 +4,8 @@ import 'dart:mirrors' as dart;
import '../exception.dart'; import '../exception.dart';
import '../reflector.dart'; import '../reflector.dart';
import 'package:quiver/core.dart';
/// A [Reflector] implementation that forwards to `dart:mirrors`. /// A [Reflector] implementation that forwards to `dart:mirrors`.
/// ///
/// Useful on the server, where reflection is supported. /// Useful on the server, where reflection is supported.
@ -176,6 +178,9 @@ class _ReflectedClassMirror extends ReflectedClass {
bool operator ==(other) { bool operator ==(other) {
return other is _ReflectedClassMirror && other.mirror == mirror; return other is _ReflectedClassMirror && other.mirror == mirror;
} }
@override
int get hashCode => hash2(mirror, " ");
} }
class _ReflectedDeclarationMirror extends ReflectedDeclaration { class _ReflectedDeclarationMirror extends ReflectedDeclaration {

View file

@ -1,5 +1,5 @@
name: angel3_container name: angel3_container
version: 7.1.1 version: 7.1.0-beta.1
description: Angel3 hierarchical DI container, and pluggable backends for reflection. description: Angel3 hierarchical DI container, and pluggable backends for reflection.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container

View file

@ -1,5 +1,5 @@
name: angel3_orm_generator name: angel3_orm_generator
version: 7.1.2 version: 7.1.3
description: Code generators for Angel3 ORM. Generates query builder classes. description: Code generators for Angel3 ORM. Generates query builder classes.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_generator repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_generator