DartSignalR 1.0.0
dotnet add package DartSignalR --version 1.0.0
NuGet\Install-Package DartSignalR -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DartSignalR" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DartSignalR --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DartSignalR, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DartSignalR as a Cake Addin
#addin nuget:?package=DartSignalR&version=1.0.0
// Install DartSignalR as a Cake Tool
#tool nuget:?package=DartSignalR&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DartSignalR
Convert your C# SignalR class to dart class to use it with your projects using signalr_core Add the types you want to convert and call Run to get string that is the dart class The package will convert the type and any other type that used in it.
// create a runner
var runner = new ConverterRunner();
// Create you convert requests
var requests = new List<ConvertRequest> {
ConvertRequest.For<ExampleHub>(isSignalRHub:true),
};
// run
var code = runner.Run(requests);
Convert Request
- Type: The type you want to convert to dart class, you can use ConvertRequest.For<Type>()
- SkipMethods: The methods to skip converting in this type.
- skipProperties: The properties to skip converting in this type.
- isSignalRHub: is this class is SignalRHub. This will set the methods to send and returns responses from HubConnection.
- keepRawJson: Set this property to true to add new property to the dart class that contains the raw json of the class. This could help if you have abstract class and you need to keep the original request from the hub.
- editableClass: Set this to true so the properties of the dart class will not have the final word and could be changed in the run time.
The result of this ExampleHub is
// File generated at 7/16/2022 3:10:27 PM
import 'package:flutter/foundation.dart';
import 'package:signalr_core/signalr_core.dart';
class ExampleHub{
final HubConnection connection;
const ExampleHub({ required this.connection});
Future<String> A_User(AddUser command) async =>
await connection.invoke('A_User' ,args: [command]) as String;
Future<HubResult> U_User(UpdateUser command) async =>
HubResult.fromJson(await connection.invoke('U_User' ,args: [command]) as Map<String,dynamic>);
void D_User(DeleteUser id) =>
connection.send(methodName: 'D_User' ,args: [id]);
void G_User(int id) =>
connection.send(methodName: 'G_User' ,args: [id]);
void GA_User() =>
connection.send(methodName: 'GA_User' );
void A_Account(AddAccount command) =>
connection.send(methodName: 'A_Account' ,args: [command]);
void U__Account(UpdateAccount command) =>
connection.send(methodName: 'U__Account' ,args: [command]);
void D__Account(DeleteAccount id) =>
connection.send(methodName: 'D__Account' ,args: [id]);
void G_Account(GetAccount id) =>
connection.send(methodName: 'G_Account' ,args: [id]);
void GA_Account() =>
connection.send(methodName: 'GA_Account' );
}
class AddUser{
final String? firstName;
final String? lastName;
final int? age;
final List<Address> addresses;
const AddUser({this.firstName, this.lastName, this.age, this.addresses = const []});
AddUser.fromJson(Map<String, dynamic> json):
firstName = json['firstName'] == null ? null : json['firstName'] as String,
lastName = json['lastName'] == null ? null : json['lastName'] as String,
age = json['age'] == null ? null : json['age'] as int,
addresses = json['addresses'] == null ? <Address>[] : List<Address>.from(json['addresses'].map((x) =>Address.fromJson(x as Map<String, dynamic>)) as Iterable);
Map<String, dynamic> toJson() => {
'firstName': firstName,
'lastName': lastName,
'age': age,
'addresses': List<dynamic>.from(addresses.map((x) => x.toJson()))
};
}
class HubResult{
final Result result;
final String? message;
const HubResult({this.result = Result.Done, this.message});
HubResult.fromJson(Map<String, dynamic> json):
result = Result.values.firstWhere((f)=> describeEnum(f.toString()) == (json['result'] as String)),
message = json['message'] == null ? null : json['message'] as String;
Map<String, dynamic> toJson() => {
'result': describeEnum(result),
'message': message
};
}
class UpdateUser{
final int? id;
final String? firstName;
final String? lastName;
final int? age;
final List<Address> addresses;
const UpdateUser({this.id, this.firstName, this.lastName, this.age, this.addresses = const []});
UpdateUser.fromJson(Map<String, dynamic> json):
id = json['id'] == null ? null : json['id'] as int,
firstName = json['firstName'] == null ? null : json['firstName'] as String,
lastName = json['lastName'] == null ? null : json['lastName'] as String,
age = json['age'] == null ? null : json['age'] as int,
addresses = json['addresses'] == null ? <Address>[] : List<Address>.from(json['addresses'].map((x) =>Address.fromJson(x as Map<String, dynamic>)) as Iterable);
Map<String, dynamic> toJson() => {
'id': id,
'firstName': firstName,
'lastName': lastName,
'age': age,
'addresses': List<dynamic>.from(addresses.map((x) => x.toJson()))
};
}
class DeleteUser{
final int? id;
const DeleteUser({this.id});
DeleteUser.fromJson(Map<String, dynamic> json):
id = json['id'] == null ? null : json['id'] as int;
Map<String, dynamic> toJson() => {
'id': id
};
}
class AddAccount{
final String? userName;
final String? email;
final String? password;
final List<String> rights;
final DateTime? lastVisit;
const AddAccount({this.userName, this.email, this.password, this.rights = const [], this.lastVisit});
AddAccount.fromJson(Map<String, dynamic> json):
userName = json['userName'] == null ? null : json['userName'] as String,
email = json['email'] == null ? null : json['email'] as String,
password = json['password'] == null ? null : json['password'] as String,
rights = json['rights'] == null ? <String>[] : List<String>.from(json['rights'].map((x) =>x) as Iterable),
lastVisit = json['lastVisit'] == null ? null : DateTime.parse(json['lastVisit'].toString()).toLocal();
Map<String, dynamic> toJson() => {
'userName': userName,
'email': email,
'password': password,
'rights': List<dynamic>.from(rights.map((x) =>x)),
'lastVisit': lastVisit?.toUtc().toIso8601String()
};
}
class UpdateAccount{
final int? id;
final String? userName;
final String? email;
final String? password;
final List<String> rights;
final DateTime? lastVisit;
const UpdateAccount({this.id, this.userName, this.email, this.password, this.rights = const [], this.lastVisit});
UpdateAccount.fromJson(Map<String, dynamic> json):
id = json['id'] == null ? null : json['id'] as int,
userName = json['userName'] == null ? null : json['userName'] as String,
email = json['email'] == null ? null : json['email'] as String,
password = json['password'] == null ? null : json['password'] as String,
rights = json['rights'] == null ? <String>[] : List<String>.from(json['rights'].map((x) =>x) as Iterable),
lastVisit = json['lastVisit'] == null ? null : DateTime.parse(json['lastVisit'].toString()).toLocal();
Map<String, dynamic> toJson() => {
'id': id,
'userName': userName,
'email': email,
'password': password,
'rights': List<dynamic>.from(rights.map((x) =>x)),
'lastVisit': lastVisit?.toUtc().toIso8601String()
};
}
class DeleteAccount{
final int? id;
const DeleteAccount({this.id});
DeleteAccount.fromJson(Map<String, dynamic> json):
id = json['id'] == null ? null : json['id'] as int;
Map<String, dynamic> toJson() => {
'id': id
};
}
class GetAccount{
final int? id;
const GetAccount({this.id});
GetAccount.fromJson(Map<String, dynamic> json):
id = json['id'] == null ? null : json['id'] as int;
Map<String, dynamic> toJson() => {
'id': id
};
}
class Address{
final String? city;
final String? street;
final String? number;
const Address({this.city, this.street, this.number});
Address.fromJson(Map<String, dynamic> json):
city = json['city'] == null ? null : json['city'] as String,
street = json['street'] == null ? null : json['street'] as String,
number = json['number'] == null ? null : json['number'] as String;
Map<String, dynamic> toJson() => {
'city': city,
'street': street,
'number': number
};
}
enum Result{
Done,
Error,
}
Duration parseDuration(String s) {
var hours = 0;
var minutes = 0;
var micros = 0;
List<String> parts = s.split(':');
if (parts.length > 2) {
hours = int.parse(parts[parts.length - 3]);
}
if (parts.length > 1) {
minutes = int.parse(parts[parts.length - 2]);
}
micros = (double.parse(parts[parts.length - 1]) * 1000000).round();
return Duration(hours: hours, minutes: minutes, microseconds: micros);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 240 | 7/17/2022 |