mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 03:32:57 +00:00
Nullable
This commit is contained in:
parent
2006c47013
commit
2dc373770c
@ -32,12 +32,12 @@ namespace Esiur.AspNetCore.Example
|
||||
public partial class MyResource
|
||||
{
|
||||
|
||||
[Annotation("sss","bb")][Export] int number;
|
||||
[Annotation("A1","B2")][Export] int number;
|
||||
|
||||
[Export]
|
||||
|
||||
public string[] GetInfo() => new string[] { Environment.MachineName, Environment.UserName, Environment.CurrentDirectory,
|
||||
Environment.CommandLine, Environment.OSVersion.ToString(), Environment.ProcessPath };
|
||||
Environment.CommandLine, Environment.OSVersion.ToString()};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ namespace Esiur.AspNetCore
|
||||
{
|
||||
public class EsiurOptions
|
||||
{
|
||||
public DistributedServer Server { get; set; }
|
||||
public required DistributedServer Server { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -36,13 +36,13 @@ namespace Esiur.CLI
|
||||
internal class GetTemplateOptions
|
||||
{
|
||||
[Option('d', "dir", Required = false, HelpText = "Directory name where the generated models will be saved.")]
|
||||
public string Dir { get; set; }
|
||||
public string? Dir { get; set; }
|
||||
|
||||
[Option('u', "username", Required = false, HelpText = "Authentication username.")]
|
||||
public string Username { get; set; }
|
||||
public string? Username { get; set; }
|
||||
|
||||
[Option('p', "password", Required = false, HelpText = "Authentication password.")]
|
||||
public string Password { get; set; }
|
||||
public string? Password { get; set; }
|
||||
|
||||
|
||||
[Option('a', "async-setters", Required = false, HelpText = "Use asynchronous property setters.")]
|
||||
|
@ -13,8 +13,8 @@ namespace Esiur.Examples.StandaloneWebServerDemo
|
||||
{
|
||||
[Export] int color;
|
||||
[Export] string label = "Hello World";
|
||||
[Export] public event ResourceEventHandler<int> Cleared;
|
||||
[Export] public event ResourceEventHandler<Point> Drawn;
|
||||
[Export] public event ResourceEventHandler<int>? Cleared;
|
||||
[Export] public event ResourceEventHandler<Point>? Drawn;
|
||||
|
||||
[Export] List<List<byte>> points;
|
||||
|
||||
|
@ -51,5 +51,7 @@ internal class Program
|
||||
// Start your server
|
||||
await Warehouse.Open();
|
||||
|
||||
Console.WriteLine("Running on http://localhost:8888");
|
||||
|
||||
}
|
||||
}
|
@ -20,13 +20,10 @@
|
||||
<script src="node_modules/esiur/src/esiur.js" type="module"></script>
|
||||
<script src="node_modules/@esiur/iui/src/iui.js" type="module"></script>
|
||||
|
||||
<script src="lib/ui/ui.js" type="module"></script>
|
||||
<script src="lib/auth/init.g.js" type="module"></script>
|
||||
|
||||
<title>Esiur Demo</title>
|
||||
|
||||
<script src="js/app.js"></script>
|
||||
<script src="js/formats.js"></script>
|
||||
|
||||
<!--IUI 2.0 -->
|
||||
<link href="node_modules/@esiur/iui/css/iui.css" rel="stylesheet" />
|
||||
|
@ -6,13 +6,13 @@
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@esiur/iui": "^1.2.1",
|
||||
"esiur": "^2.2.14"
|
||||
"esiur": "^2.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.24.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz",
|
||||
"integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==",
|
||||
"version": "7.26.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz",
|
||||
"integrity": "sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==",
|
||||
"dependencies": {
|
||||
"regenerator-runtime": "^0.14.0"
|
||||
},
|
||||
@ -56,9 +56,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/esiur": {
|
||||
"version": "2.2.14",
|
||||
"resolved": "https://registry.npmjs.org/esiur/-/esiur-2.2.14.tgz",
|
||||
"integrity": "sha512-LS28Fb1uuoOvEuSpVwLJVskwxAZmprYSELaezqlsog15c9geO8ByNJKHFW5IQdBgVTdJZwiwwcpwrDDPZ8OCiA==",
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/esiur/-/esiur-2.3.3.tgz",
|
||||
"integrity": "sha512-enPAhnwuN2FXebfrtSfuCV7xWtVBcb9263ZMab1Vt4UVSoiUueY9/gR75yXqz9smVvSFhWylJ4Zf9vQtD8H6Lw==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.7",
|
||||
"mongodb": "^3.6.9",
|
||||
@ -229,9 +229,9 @@
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "7.5.9",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
|
||||
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
|
||||
"version": "7.5.10",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
|
||||
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
|
||||
"engines": {
|
||||
"node": ">=8.3.0"
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@esiur/iui": "^1.2.1",
|
||||
"esiur": "^2.2.14"
|
||||
"esiur": "^2.3.3"
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
<PackageId>Esiur.Stores.EntityCore</PackageId>
|
||||
<Version>1.3.4</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
8
Esiur.Stores.EntityCore/GlobalSuppressions.cs
Normal file
8
Esiur.Stores.EntityCore/GlobalSuppressions.cs
Normal file
@ -0,0 +1,8 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Usage", "EF1001:Internal EF Core API usage.", Justification = "<Pending>", Scope = "member", Target = "~M:Esiur.Stores.EntityCore.EsiurProxyRewrite.ProcessModelFinalizing(Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder,Microsoft.EntityFrameworkCore.Metadata.Conventions.IConventionContext{Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder})")]
|
@ -7,13 +7,13 @@
|
||||
<Product>Esiur MongoDB Store</Product>
|
||||
<Description>MongoDB Store for Esiur Library</Description>
|
||||
<Copyright>Ahmed Kh. Zamil</Copyright>
|
||||
<PackageLicenseUrl>https://github.com/Esiur/Esiur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/esiur/esiur-dotnet/</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<Version>1.5.6</Version>
|
||||
<PackageId>Esiur.Stores.MongoDB</PackageId>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -72,7 +72,7 @@ public class MongoDBStore : IStore
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
|
||||
OnDestroy?.Invoke(this);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -16,9 +16,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.Examples.StandaloneWe
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.CLI", "Esiur.CLI\Esiur.CLI.csproj", "{5C193127-20D1-4709-90C4-DF714D7E6700}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Esiur.AspNetCore.Example", "Esiur.ASPNet\Esiur.AspNetCore.Example.csproj", "{7C65CC4D-0DE6-4E2A-8DCF-113E1AB85D8A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.AspNetCore.Example", "Esiur.ASPNet\Esiur.AspNetCore.Example.csproj", "{7C65CC4D-0DE6-4E2A-8DCF-113E1AB85D8A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Esiur.AspNetCore", "Esiur.AspNetCore\Esiur.AspNetCore.csproj", "{7B0C521F-8B13-4F2A-BD78-7C692620C831}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.AspNetCore", "Esiur.AspNetCore\Esiur.AspNetCore.csproj", "{7B0C521F-8B13-4F2A-BD78-7C692620C831}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -29,10 +29,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Esiur.Core;
|
||||
|
||||
#nullable enable
|
||||
|
||||
public delegate void DestroyedEvent(object sender);
|
||||
|
||||
public interface IDestructible
|
||||
{
|
||||
event DestroyedEvent OnDestroy;
|
||||
event DestroyedEvent? OnDestroy;
|
||||
void Destroy();
|
||||
}
|
||||
|
@ -24,22 +24,18 @@ SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Esiur.Misc;
|
||||
using System.ComponentModel;
|
||||
using Esiur.Data;
|
||||
using Esiur.Core;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Resource;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Esiur.Resource.Template;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections;
|
||||
using System.Dynamic;
|
||||
|
||||
namespace Esiur.Data;
|
||||
|
||||
#nullable enable
|
||||
|
||||
public static class Codec
|
||||
{
|
||||
|
||||
@ -122,6 +118,10 @@ public static class Codec
|
||||
if (dataType == null)
|
||||
{
|
||||
(var longLen, dataType) = TransmissionType.Parse(data, offset, (uint)data.Length);
|
||||
|
||||
if (dataType == null)
|
||||
throw new NullReferenceException("DataType can't be parsed.");
|
||||
|
||||
len = (uint)longLen;
|
||||
offset = dataType.Value.Offset;
|
||||
}
|
||||
@ -153,8 +153,11 @@ public static class Codec
|
||||
/// <returns>True, if the resource owner is the given connection, otherwise False.</returns>
|
||||
public static bool IsLocalResource(IResource resource, DistributedConnection connection)
|
||||
{
|
||||
if (resource == null)
|
||||
throw new NullReferenceException("Resource is null.");
|
||||
|
||||
if (resource is DistributedResource)
|
||||
if ((resource as DistributedResource).DistributedResourceConnection == connection)
|
||||
if (((DistributedResource)(resource)).DistributedResourceConnection == connection)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -270,7 +273,7 @@ public static class Codec
|
||||
}
|
||||
|
||||
if (valueOrSource is IUserType)
|
||||
valueOrSource = (valueOrSource as IUserType).Get();
|
||||
valueOrSource = ((IUserType)valueOrSource).Get();
|
||||
|
||||
//if (valueOrSource is Func<DistributedConnection, object>)
|
||||
// valueOrSource = (valueOrSource as Func<DistributedConnection, object>)(connection);
|
||||
@ -366,7 +369,7 @@ public static class Codec
|
||||
}
|
||||
|
||||
|
||||
public static Type GetGenericType(Type type, Type ifaceType, int argument = 0)
|
||||
public static Type? GetGenericType(Type type, Type ifaceType, int argument = 0)
|
||||
{
|
||||
if (ifaceType.IsAssignableFrom(type))
|
||||
{
|
||||
|
@ -9,6 +9,8 @@ using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Esiur.Data
|
||||
{
|
||||
public enum RepresentationTypeIdentifier
|
||||
@ -83,8 +85,9 @@ namespace Esiur.Data
|
||||
flags.RemoveAt(0);
|
||||
}
|
||||
|
||||
foreach (var st in SubTypes)
|
||||
st.SetNull(flags);
|
||||
if (SubTypes != null)
|
||||
foreach (var st in SubTypes)
|
||||
st.SetNull(flags);
|
||||
}
|
||||
|
||||
public void SetNull(byte flag)
|
||||
@ -94,8 +97,9 @@ namespace Esiur.Data
|
||||
Nullable = (flag == 2);
|
||||
}
|
||||
|
||||
foreach (var st in SubTypes)
|
||||
st.SetNull(flag);
|
||||
if (SubTypes != null)
|
||||
foreach (var st in SubTypes)
|
||||
st.SetNull(flag);
|
||||
}
|
||||
|
||||
|
||||
@ -108,8 +112,9 @@ namespace Esiur.Data
|
||||
flags.RemoveAt(0);
|
||||
}
|
||||
|
||||
foreach (var st in SubTypes)
|
||||
st.SetNotNull(flags);
|
||||
if (SubTypes != null)
|
||||
foreach (var st in SubTypes)
|
||||
st.SetNotNull(flags);
|
||||
}
|
||||
|
||||
|
||||
@ -126,8 +131,9 @@ namespace Esiur.Data
|
||||
Nullable = (flag != 1);
|
||||
}
|
||||
|
||||
foreach (var st in SubTypes)
|
||||
st.SetNotNull(flag);
|
||||
if (SubTypes != null)
|
||||
foreach (var st in SubTypes)
|
||||
st.SetNotNull(flag);
|
||||
}
|
||||
|
||||
public Type? GetRuntimeType()
|
||||
@ -135,7 +141,7 @@ namespace Esiur.Data
|
||||
|
||||
if (Identifier == RepresentationTypeIdentifier.TypedList)
|
||||
{
|
||||
var sub = SubTypes[0].GetRuntimeType();
|
||||
var sub = SubTypes?[0].GetRuntimeType();
|
||||
if (sub == null)
|
||||
return null;
|
||||
|
||||
@ -149,7 +155,7 @@ namespace Esiur.Data
|
||||
var rt = typeof(Map<,>).MakeGenericType(subs);
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
||||
return Identifier switch
|
||||
{
|
||||
(RepresentationTypeIdentifier.Void) => typeof(void),
|
||||
@ -171,9 +177,9 @@ namespace Esiur.Data
|
||||
(RepresentationTypeIdentifier.DateTime) => Nullable ? typeof(DateTime?) : typeof(DateTime),
|
||||
(RepresentationTypeIdentifier.Resource) => typeof(IResource),
|
||||
(RepresentationTypeIdentifier.Record) => typeof(IRecord),
|
||||
(RepresentationTypeIdentifier.TypedRecord) => Warehouse.GetTemplateByClassId((Guid)GUID, TemplateType.Record)?.DefinedType,
|
||||
(RepresentationTypeIdentifier.TypedResource) => Warehouse.GetTemplateByClassId((Guid)GUID, TemplateType.Resource)?.DefinedType,
|
||||
(RepresentationTypeIdentifier.Enum) => Warehouse.GetTemplateByClassId((Guid)GUID, TemplateType.Enum)?.DefinedType,
|
||||
(RepresentationTypeIdentifier.TypedRecord) => Warehouse.GetTemplateByClassId((Guid)GUID!, TemplateType.Record)?.DefinedType,
|
||||
(RepresentationTypeIdentifier.TypedResource) => Warehouse.GetTemplateByClassId((Guid)GUID!, TemplateType.Resource)?.DefinedType,
|
||||
(RepresentationTypeIdentifier.Enum) => Warehouse.GetTemplateByClassId((Guid)GUID!, TemplateType.Enum)?.DefinedType,
|
||||
|
||||
_ => null
|
||||
};
|
||||
@ -186,7 +192,7 @@ namespace Esiur.Data
|
||||
//public RepresentationType? SubType2; // Map
|
||||
//public RepresentationType? SubType3; // No types yet
|
||||
|
||||
public RepresentationType?[] SubTypes = new RepresentationType[3];
|
||||
public RepresentationType[]? SubTypes = null;
|
||||
|
||||
|
||||
public RepresentationType ToNullable()
|
||||
@ -194,11 +200,11 @@ namespace Esiur.Data
|
||||
return new RepresentationType(Identifier, true, GUID, SubTypes);
|
||||
}
|
||||
|
||||
public static RepresentationType? FromType(Type type)
|
||||
public static RepresentationType? FromType(Type type)
|
||||
{
|
||||
|
||||
var nullable = false;
|
||||
|
||||
var nullable = false;
|
||||
|
||||
var nullType = System.Nullable.GetUnderlyingType(type);
|
||||
|
||||
if (nullType != null)
|
||||
@ -245,7 +251,8 @@ namespace Esiur.Data
|
||||
if (subType == null) // unrecongnized type
|
||||
return null;
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.TypedList, nullable, null, subType);
|
||||
return new RepresentationType(RepresentationTypeIdentifier.TypedList, nullable, null,
|
||||
new RepresentationType[] { subType });
|
||||
|
||||
}
|
||||
}
|
||||
@ -266,7 +273,8 @@ namespace Esiur.Data
|
||||
if (subType2 == null)
|
||||
return null;
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.TypedMap, nullable, null, subType1, subType2);
|
||||
return new RepresentationType(RepresentationTypeIdentifier.TypedMap, nullable, null,
|
||||
new RepresentationType[] { subType1, subType2 });
|
||||
}
|
||||
}
|
||||
//else if (genericType == typeof(AsyncReply<>))
|
||||
@ -285,9 +293,10 @@ namespace Esiur.Data
|
||||
var subTypes = new RepresentationType[args.Length];
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
subTypes[i] = FromType(args[i]);
|
||||
if (subTypes[i] == null)
|
||||
var t = FromType(args[i]);
|
||||
if (t == null)
|
||||
return null;
|
||||
subTypes[i] = t;
|
||||
}
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.Tuple2, nullable, null, subTypes);
|
||||
@ -298,9 +307,10 @@ namespace Esiur.Data
|
||||
var subTypes = new RepresentationType[args.Length];
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
subTypes[i] = FromType(args[i]);
|
||||
if (subTypes[i] == null)
|
||||
var t = FromType(args[i]);
|
||||
if (t == null)
|
||||
return null;
|
||||
subTypes[i] = t;
|
||||
}
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.Tuple3, nullable, null, subTypes);
|
||||
@ -312,9 +322,10 @@ namespace Esiur.Data
|
||||
var subTypes = new RepresentationType[args.Length];
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
subTypes[i] = FromType(args[i]);
|
||||
if (subTypes[i] == null)
|
||||
var t = FromType(args[i]);
|
||||
if (t == null)
|
||||
return null;
|
||||
subTypes[i] = t;
|
||||
}
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.Tuple4, nullable, null, subTypes);
|
||||
@ -325,9 +336,10 @@ namespace Esiur.Data
|
||||
var subTypes = new RepresentationType[args.Length];
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
subTypes[i] = FromType(args[i]);
|
||||
if (subTypes[i] == null)
|
||||
var t = FromType(args[i]);
|
||||
if (t == null)
|
||||
return null;
|
||||
subTypes[i] = t;
|
||||
}
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.Tuple5, nullable, null, subTypes);
|
||||
@ -338,9 +350,10 @@ namespace Esiur.Data
|
||||
var subTypes = new RepresentationType[args.Length];
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
subTypes[i] = FromType(args[i]);
|
||||
if (subTypes[i] == null)
|
||||
var t = FromType(args[i]);
|
||||
if (t == null)
|
||||
return null;
|
||||
subTypes[i] = t;
|
||||
}
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.Tuple6, nullable, null, subTypes);
|
||||
@ -351,9 +364,10 @@ namespace Esiur.Data
|
||||
var subTypes = new RepresentationType[args.Length];
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
subTypes[i] = FromType(args[i]);
|
||||
if (subTypes[i] == null)
|
||||
var t = FromType(args[i]);
|
||||
if (t == null)
|
||||
return null;
|
||||
subTypes[i] = t;
|
||||
}
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.Tuple7, nullable, null, subTypes);
|
||||
@ -373,7 +387,8 @@ namespace Esiur.Data
|
||||
if (subType == null)
|
||||
return null;
|
||||
|
||||
return new RepresentationType(RepresentationTypeIdentifier.TypedList, nullable, null, subType);
|
||||
return new RepresentationType(RepresentationTypeIdentifier.TypedList, nullable, null,
|
||||
new RepresentationType[] { subType });
|
||||
|
||||
}
|
||||
}
|
||||
@ -410,7 +425,7 @@ namespace Esiur.Data
|
||||
|
||||
}
|
||||
|
||||
public RepresentationType(RepresentationTypeIdentifier identifier, bool nullable, Guid? guid = null, params RepresentationType[] subTypes)
|
||||
public RepresentationType(RepresentationTypeIdentifier identifier, bool nullable, Guid? guid = null, RepresentationType[]? subTypes = null)
|
||||
{
|
||||
Nullable = nullable;
|
||||
Identifier = identifier;
|
||||
|
@ -61,7 +61,6 @@ public class PacketServer : IResource
|
||||
}
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
public event PropertyModifiedEvent PropertyModified;
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
|
@ -206,7 +206,8 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
||||
{
|
||||
base.Assign(socket);
|
||||
|
||||
session.LocalHeaders[IIPAuthPacketHeader.IPv4] = socket.RemoteEndPoint.Address.Address;
|
||||
session.LocalHeaders[IIPAuthPacketHeader.IPAddress] = socket.RemoteEndPoint.Address.GetAddressBytes();
|
||||
|
||||
if (socket.State == SocketState.Established &&
|
||||
session.AuthenticationType == AuthenticationType.Client)
|
||||
{
|
||||
|
@ -104,7 +104,6 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
|
||||
set;
|
||||
}
|
||||
|
||||
public event PropertyModifiedEvent PropertyModified;
|
||||
|
||||
public AsyncReply<bool> Trigger(ResourceTrigger trigger)
|
||||
{
|
||||
|
@ -24,6 +24,6 @@ namespace Esiur.Net.Packets
|
||||
Referrer = 15,
|
||||
Time = 16,
|
||||
Certificate = 17,
|
||||
IPv4 = 18
|
||||
IPAddress = 18,
|
||||
}
|
||||
}
|
||||
|
@ -122,8 +122,8 @@ namespace Esiur.Net.Sockets
|
||||
|
||||
await ws.ConnectAsync(url, new CancellationToken());
|
||||
|
||||
|
||||
sock.ReceiveAsync(websocketReceiveBufferSegment, CancellationToken.None)
|
||||
|
||||
_ = sock.ReceiveAsync(websocketReceiveBufferSegment, CancellationToken.None)
|
||||
.ContinueWith(NetworkReceive);
|
||||
|
||||
return true;
|
||||
@ -236,6 +236,8 @@ namespace Esiur.Net.Sockets
|
||||
|
||||
var receivedLength = task.Result.Count;
|
||||
|
||||
totalReceived += receivedLength;
|
||||
|
||||
receiveNetworkBuffer.Write(websocketReceiveBuffer, 0, (uint)receivedLength);
|
||||
|
||||
Receiver?.NetworkReceive(this, receiveNetworkBuffer);
|
||||
|
@ -18,6 +18,7 @@ using Esiur.Core;
|
||||
namespace Esiur.Proxy;
|
||||
|
||||
[Generator]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisCorrectness", "RS1036:Specify analyzer banned API enforcement setting", Justification = "<Pending>")]
|
||||
public class ResourceGenerator : ISourceGenerator
|
||||
{
|
||||
|
||||
@ -182,7 +183,10 @@ public class ResourceGenerator : ISourceGenerator
|
||||
{
|
||||
|
||||
var code = @$"using Esiur.Resource;
|
||||
using Esiur.Core;
|
||||
using Esiur.Core;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace {ci.ClassSymbol.ContainingNamespace.ToDisplayString()} {{
|
||||
";
|
||||
|
||||
@ -192,8 +196,8 @@ namespace {ci.ClassSymbol.ContainingNamespace.ToDisplayString()} {{
|
||||
{
|
||||
code +=
|
||||
@$" public partial class {ci.Name} : IResource {{
|
||||
public virtual Instance Instance {{ get; set; }}
|
||||
public virtual event DestroyedEvent OnDestroy;
|
||||
public virtual Instance? Instance {{ get; set; }}
|
||||
public virtual event DestroyedEvent? OnDestroy;
|
||||
|
||||
public virtual void Destroy() {{ OnDestroy?.Invoke(this); }}
|
||||
";
|
||||
|
@ -270,6 +270,8 @@ public static class TemplateGenerator
|
||||
var rt = new StringBuilder();
|
||||
|
||||
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;");
|
||||
rt.AppendLine("#nullable enable");
|
||||
|
||||
rt.AppendLine($"namespace {nameSpace} {{");
|
||||
|
||||
if (template.Annotation != null)
|
||||
|
@ -22,29 +22,22 @@ SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Esiur.Data;
|
||||
using Esiur.Core;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Esiur.Resource;
|
||||
|
||||
public delegate bool QueryFilter<T>(T value);
|
||||
|
||||
//[JsonConverter(typeof(ResourceJsonConverter))]
|
||||
|
||||
public interface IResource : IDestructible///, INotifyPropertyChanged
|
||||
public interface IResource : IDestructible
|
||||
{
|
||||
AsyncReply<bool> Trigger(ResourceTrigger trigger);
|
||||
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
Instance Instance { get; set; }
|
||||
|
||||
|
||||
Instance? Instance { get; set; }
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ using System.Text;
|
||||
|
||||
namespace Esiur.Resource.Template;
|
||||
|
||||
#nullable enable
|
||||
|
||||
public class MemberData
|
||||
{
|
||||
public MemberInfo Info;
|
||||
@ -15,6 +17,13 @@ public class MemberData
|
||||
public MemberData? Child;
|
||||
public byte Index;
|
||||
|
||||
public MemberData(string name, MemberInfo info, int order)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Info = info;
|
||||
this.Order = order;
|
||||
}
|
||||
|
||||
public MemberInfo GetMemberInfo()
|
||||
{
|
||||
var rt = Info;
|
||||
@ -29,7 +38,7 @@ public class MemberData
|
||||
|
||||
public string? GetAnnotation()
|
||||
{
|
||||
string rt = null;
|
||||
string? rt = null;
|
||||
var md = this;
|
||||
while (md != null)
|
||||
{
|
||||
|
@ -601,18 +601,17 @@ public class TypeTemplate
|
||||
.Where(x => x.GetCustomAttribute<IgnoreAttribute>() == null)
|
||||
.Where(x => x.Name != "Instance")
|
||||
.Where(x => !(x is MethodInfo m && m.IsSpecialName))
|
||||
.Where(x=> !(x is EventInfo e &&
|
||||
!(e.EventHandlerType.IsGenericType &&
|
||||
.Where(x => !(x is EventInfo e &&
|
||||
!(e.EventHandlerType.IsGenericType &&
|
||||
(e.EventHandlerType.GetGenericTypeDefinition() == typeof(ResourceEventHandler<>)
|
||||
|| e.EventHandlerType.GetGenericTypeDefinition() == typeof(CustomResourceEventHandler<>))
|
||||
)
|
||||
))
|
||||
.Select(x => new MemberData()
|
||||
{
|
||||
Name = x.GetCustomAttribute<ExportAttribute>()?.Name ?? x.Name,
|
||||
Info = x,
|
||||
Order = order
|
||||
})
|
||||
.Select(x => new MemberData(
|
||||
name: x.GetCustomAttribute<ExportAttribute>()?.Name ?? x.Name,
|
||||
info: x,
|
||||
order: order
|
||||
))
|
||||
.OrderBy(x => x.Name);
|
||||
|
||||
members.AddRange(mis.ToArray());
|
||||
@ -627,12 +626,11 @@ public class TypeTemplate
|
||||
.Where(x => !(x is FieldInfo c && !c.IsStatic))
|
||||
.Where(x => x.GetCustomAttribute<ExportAttribute>() != null)
|
||||
.Where(x => !(x is MethodInfo m && m.IsSpecialName))
|
||||
.Select(x => new MemberData
|
||||
{
|
||||
Name = x.GetCustomAttribute<ExportAttribute>()?.Name ?? x.Name,
|
||||
Info = x,
|
||||
Order = order
|
||||
})
|
||||
.Select(x => new MemberData (
|
||||
name : x.GetCustomAttribute<ExportAttribute>()?.Name ?? x.Name,
|
||||
info : x,
|
||||
order : order
|
||||
))
|
||||
.OrderBy(x => x.Name);
|
||||
|
||||
members.AddRange(mis.ToArray());
|
||||
@ -641,7 +639,7 @@ public class TypeTemplate
|
||||
|
||||
type = type.BaseType;
|
||||
|
||||
if (type == null
|
||||
if (type == null
|
||||
|| type == typeof(Resource)
|
||||
|| type == typeof(Record)
|
||||
|| type == typeof(EntryPoint))
|
||||
|
@ -4,6 +4,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Esiur.Security.Membership
|
||||
{
|
||||
public class AuthorizationRequest
|
||||
|
@ -3,6 +3,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Esiur.Security.Membership
|
||||
{
|
||||
public class AuthorizationResults
|
||||
@ -12,7 +14,7 @@ namespace Esiur.Security.Membership
|
||||
|
||||
public uint Reference { get; set; }
|
||||
public IIPAuthPacketIAuthDestination Destination { get; set; }
|
||||
public string Clue { get; set; }
|
||||
public string? Clue { get; set; }
|
||||
public IIPAuthPacketIAuthFormat? RequiredFormat { get; set; }
|
||||
public IIPAuthPacketIAuthFormat? ContentFormat { get; set; }
|
||||
public object? Content { get; set; }
|
||||
|
@ -15,7 +15,7 @@ namespace Esiur.Security.Membership
|
||||
{
|
||||
public bool GuestsAllowed { get; set; } = false;
|
||||
|
||||
public event ResourceEventHandler<AuthorizationIndication> Authorization;
|
||||
public event ResourceEventHandler<AuthorizationIndication> Authorization { add { } remove { } }
|
||||
|
||||
KeyList<string, UserInfo> users = new KeyList<string, UserInfo>();
|
||||
|
||||
|
@ -7,6 +7,8 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Test;
|
||||
|
||||
|
||||
@ -25,8 +27,8 @@ public enum SizeEnum:short
|
||||
public partial class MyService
|
||||
{
|
||||
|
||||
[Export] public event ResourceEventHandler<string> StringEvent;
|
||||
[Export] public event ResourceEventHandler<object[]> ArrayEvent;
|
||||
[Export] public event ResourceEventHandler<string>? StringEvent;
|
||||
[Export] public event ResourceEventHandler<object[]>? ArrayEvent;
|
||||
|
||||
[Export] bool boolean = true;
|
||||
[Export] bool[] booleanArray = new bool[] { true, false, true, false, true };
|
||||
@ -124,14 +126,14 @@ public partial class MyService
|
||||
[Export] public List<MyRecord> RecordsList => new() { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
|
||||
|
||||
|
||||
[Export] public MyResource[] myResources;
|
||||
[Export] public MyResource[]? myResources;
|
||||
|
||||
[Export] public MyResource Resource { get; set; }
|
||||
[Export] public MyChildResource ChildResource { get; set; }
|
||||
[Export] public MyResource? Resource { get; set; }
|
||||
[Export] public MyChildResource? ChildResource { get; set; }
|
||||
|
||||
[Export] public MyChildRecord ChildRecord { get; set; } = new MyChildRecord() { ChildName = "Child", Id = 12, Name = "Parent", Score = 12.2 };
|
||||
|
||||
[Export] public IResource[] Resources { get; set; }
|
||||
[Export] public IResource[]? Resources { get; set; }
|
||||
|
||||
[Export]
|
||||
public void Void() =>
|
||||
@ -166,7 +168,7 @@ public partial class MyService
|
||||
|
||||
|
||||
[Export]
|
||||
public void ConnectionOptional(object a1, int a2, string a3 = "sss", DistributedConnection a4 = null) =>
|
||||
public void ConnectionOptional(object a1, int a2, string a3 = "sss", DistributedConnection? a4 = null) =>
|
||||
Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
|
||||
|
||||
[Export]
|
||||
|
Loading…
x
Reference in New Issue
Block a user