Skip to content

Commit

Permalink
🔖 1.23.10614.11642
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Jun 14, 2023
1 parent 7d166ab commit 39cb46d
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public sealed class GenerateRepositoriesAttribute : Attribute
/// </summary>
public bool BackManageAddModel { get; set; } = true;

/// <summary>
/// 是否需要生成后台管理【添加】功能,默认值为:<see langword="true"/>
/// </summary>
public bool BackManageCanAdd { get; set; } = true;

/// <summary>
/// 指定生成后台管理【添加】仓储层函数实现种类,默认值为:<see cref="RepositoryMethodImplType.Expression"/>
/// </summary>
Expand All @@ -26,6 +31,11 @@ public sealed class GenerateRepositoriesAttribute : Attribute
/// </summary>
public bool BackManageEditModel { get; set; } = true;

/// <summary>
/// 是否需要生成后台管理【编辑】功能,默认值为:<see langword="true"/>
/// </summary>
public bool BackManageCanEdit { get; set; } = true;

/// <summary>
/// 后台管理【编辑】模型是否仅作为详情展示的只读用途,决定是否生成 Update 函数,默认值为:<see langword="false"/>
/// </summary>
Expand All @@ -41,6 +51,11 @@ public sealed class GenerateRepositoriesAttribute : Attribute
/// </summary>
public bool BackManageTableModel { get; set; } = true;

/// <summary>
/// 是否需要生成后台管理【表格查询】功能,默认值为:<see langword="true"/>
/// </summary>
public bool BackManageCanTable { get; set; } = true;

/// <summary>
/// 指定生成后台管理【表格查询】仓储层函数实现种类,默认值为:<see cref="RepositoryMethodImplType.Expression"/>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<ProjectReference Include="..\BD.Common.AspNetCore.Identity.BackManage\BD.Common.AspNetCore.Identity.BackManage.csproj" />
<ProjectReference Include="..\BD.Common.Primitives\BD.Common.Primitives.csproj" />
<ProjectReference Include="..\BD.Common.Repositories.EFCore\BD.Common.Repositories.EFCore.csproj" />
<!--<ProjectReference Include="..\BD.Common.Repositories.SourceGenerator.Annotations\BD.Common.Repositories.SourceGenerator.Annotations.csproj" />-->
<!--<ProjectReference Include="..\BD.Common.Repositories.SourceGenerator\BD.Common.Repositories.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />-->
<ProjectReference Include="..\BD.Common.Repositories.SourceGenerator.Annotations\BD.Common.Repositories.SourceGenerator.Annotations.csproj" />
<ProjectReference Include="..\BD.Common.Repositories.SourceGenerator\BD.Common.Repositories.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\BD.Common.Repositories\BD.Common.Repositories.csproj" />
<ProjectReference Include="..\BD.Common\BD.Common.csproj" />
</ItemGroup>
Expand All @@ -55,8 +55,8 @@
<PackageReference Include="AutoMapper" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="Humanizer.Core.zh-CN" />
<PackageReference Include="BD.Common.Repositories.SourceGenerator.Annotations" />
<PackageReference Include="BD.Common.Repositories.SourceGenerator" />
<!--<PackageReference Include="BD.Common.Repositories.SourceGenerator.Annotations" />
<PackageReference Include="BD.Common.Repositories.SourceGenerator" />-->
</ItemGroup>

<Import Project="..\TFM_NETX_WINDOWS.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
namespace BD.Common.Repositories.SourceGenerator.ConsoleTest.Entities.Design;

[GenerateRepositories(
BackManageAddModel = false,
BackManageEditModel = false,
BackManageTableModel = false,
Repository = false,
Entity = false,
RepositoryConstructorArguments = new[] {
"ISysUserRepository",
"ASDASDRepository",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ public abstract class RepositoryTemplateBase<TTemplate, TTemplateMetadata> : Tem
{
public interface IRepositoryTemplateMetadata : ITemplateMetadata
{
/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageAddModel"/>
bool BackManageAddModel { get; }
/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageCanAdd"/>
bool BackManageCanAdd { get; }

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageAddMethodImplType"/>
RepositoryMethodImplType BackManageAddMethodImplType { get; }

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageEditModel"/>
bool BackManageEditModel { get; }
/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageCanEdit"/>
bool BackManageCanEdit { get; }

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageEditModelReadOnly"/>
bool BackManageEditModelReadOnly { get; }

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageEditMethodImplType"/>
RepositoryMethodImplType BackManageEditMethodImplType { get; }

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageTableModel"/>
bool BackManageTableModel { get; }
/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageCanTable"/>
bool BackManageCanTable { get; }

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageTableMethodImplType"/>
RepositoryMethodImplType BackManageTableMethodImplType { get; }
Expand Down Expand Up @@ -975,7 +975,7 @@ protected void WriteMethods(Stream stream, TTemplateMetadata metadata, Immutable
WriteUpdate(stream, metadata, fields, idField);
}
}
if (metadata.BackManageAddModel)
if (metadata.BackManageCanEdit)
{
WriteInsert(stream, metadata, fields, idField);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ public readonly record struct Metadata(
/// <inheritdoc cref="GenerateRepositoriesAttribute.ApiRoutePrefix"/>
public string? ApiRoutePrefix => GenerateRepositoriesAttribute.ApiRoutePrefix;

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageAddModel"/>
public bool BackManageAddModel => GenerateRepositoriesAttribute.BackManageAddModel;
/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageCanAdd"/>
public bool BackManageCanAdd => GenerateRepositoriesAttribute.BackManageCanAdd;

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageEditModel"/>
public bool BackManageEditModel => GenerateRepositoriesAttribute.BackManageEditModel;
/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageCanEdit"/>
public bool BackManageCanEdit => GenerateRepositoriesAttribute.BackManageCanEdit;

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageEditModelReadOnly"/>
public bool BackManageEditModelReadOnly => GenerateRepositoriesAttribute.BackManageEditModelReadOnly;

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageTableModel"/>
public bool BackManageTableModel => GenerateRepositoriesAttribute.BackManageTableModel;
/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageCanTable"/>
public bool BackManageCanTable => GenerateRepositoriesAttribute.BackManageCanTable;
}

void WriteConstructor(
Expand Down Expand Up @@ -210,19 +210,19 @@ public sealed partial class {2}Controller : BaseAuthorizeController<{2}Controlle

#endregion

if (metadata.BackManageEditModel)
if (metadata.BackManageCanEdit)
{
WriteEditById(stream, metadata, routePrefixU8, classNamePluralizeLowerU8, idField, repositoryInterfaceTypeArgNameU8);
if (!metadata.BackManageEditModelReadOnly)
{
WriteUpdate(stream, metadata, idField, routePrefixU8, classNamePluralizeLowerU8, repositoryInterfaceTypeArgNameU8);
}
}
if (metadata.BackManageAddModel)
if (metadata.BackManageCanAdd)
{
WriteInsert(stream, metadata, routePrefixU8, classNamePluralizeLowerU8, repositoryInterfaceTypeArgNameU8);
}
if (metadata.BackManageTableModel)
if (metadata.BackManageCanTable)
{
WriteQuery(stream, metadata, fields, routePrefixU8, classNamePluralizeLowerU8, repositoryInterfaceTypeArgNameU8);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public readonly record struct Metadata(
GenerateRepositoriesAttribute GenerateRepositoriesAttribute) : ITemplateMetadata
{
/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageAddModel"/>
public bool BackManageAddModel => GenerateRepositoriesAttribute.BackManageAddModel;
public bool BackManageAddModel => GenerateRepositoriesAttribute.BackManageAddModel && GenerateRepositoriesAttribute.BackManageCanAdd;

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageEditModel"/>
public bool BackManageEditModel => GenerateRepositoriesAttribute.BackManageEditModel;
public bool BackManageEditModel => GenerateRepositoriesAttribute.BackManageEditModel && GenerateRepositoriesAttribute.BackManageCanEdit;

/// <inheritdoc cref="GenerateRepositoriesAttribute.BackManageTableModel"/>
public bool BackManageTableModel => GenerateRepositoriesAttribute.BackManageTableModel;
public bool BackManageTableModel => GenerateRepositoriesAttribute.BackManageTableModel && GenerateRepositoriesAttribute.BackManageCanTable;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ public readonly record struct Metadata(
{
public string[]? ConstructorArguments => GenerateRepositoriesAttribute.RepositoryConstructorArguments;

public bool BackManageAddModel => GenerateRepositoriesAttribute.BackManageAddModel;
public bool BackManageCanAdd => GenerateRepositoriesAttribute.BackManageCanAdd;

public RepositoryMethodImplType BackManageAddMethodImplType => GenerateRepositoriesAttribute.BackManageAddMethodImplType;

public bool BackManageEditModel => GenerateRepositoriesAttribute.BackManageEditModel;
public bool BackManageCanEdit => GenerateRepositoriesAttribute.BackManageCanEdit;

public bool BackManageEditModelReadOnly => GenerateRepositoriesAttribute.BackManageEditModelReadOnly;

public RepositoryMethodImplType BackManageEditMethodImplType => GenerateRepositoriesAttribute.BackManageEditMethodImplType;

public bool BackManageTableModel => GenerateRepositoriesAttribute.BackManageTableModel;
public bool BackManageCanTable => GenerateRepositoriesAttribute.BackManageCanTable;

public RepositoryMethodImplType BackManageTableMethodImplType => GenerateRepositoriesAttribute.BackManageTableMethodImplType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public readonly record struct Metadata(
string? PrimaryKeyTypeName = null,
GenerateRepositoriesAttribute GenerateRepositoriesAttribute = null!) : IRepositoryTemplateMetadata
{
public bool BackManageAddModel => GenerateRepositoriesAttribute.BackManageAddModel;
public bool BackManageCanAdd => GenerateRepositoriesAttribute.BackManageCanAdd;

public RepositoryMethodImplType BackManageAddMethodImplType => GenerateRepositoriesAttribute.BackManageAddMethodImplType;

public bool BackManageEditModel => GenerateRepositoriesAttribute.BackManageEditModel;
public bool BackManageCanEdit => GenerateRepositoriesAttribute.BackManageCanEdit;

public bool BackManageEditModelReadOnly => GenerateRepositoriesAttribute.BackManageEditModelReadOnly;

public RepositoryMethodImplType BackManageEditMethodImplType => GenerateRepositoriesAttribute.BackManageEditMethodImplType;

public bool BackManageTableModel => GenerateRepositoriesAttribute.BackManageTableModel;
public bool BackManageCanTable => GenerateRepositoriesAttribute.BackManageCanTable;

public RepositoryMethodImplType BackManageTableMethodImplType => GenerateRepositoriesAttribute.BackManageTableMethodImplType;
}
Expand Down
22 changes: 11 additions & 11 deletions src/BD.Common/Net/DynamicHttpWindowsProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private HttpWindowsProxy(WinInetProxyHelper proxyHelper, Vanara.PInvoke.WinHTTP.
}
else
{
tmp = proxyHelper.ProxyBypass.Substring(start, idx - start);
tmp = proxyHelper.ProxyBypass[start..idx];
}

// Skip trailing characters if any.
Expand Down Expand Up @@ -479,7 +479,7 @@ public static MultiProxy Parse(FailedProxyCache failedProxyCache, string? proxyC
Array.Resize(ref uris, idx + 1);
uris[idx] = uri;

span = span.Slice(charactersConsumed);
span = span[charactersConsumed..];
}

return new MultiProxy(failedProxyCache, uris);
Expand Down Expand Up @@ -631,7 +631,7 @@ private static bool TryParseProxyConfigPart(ReadOnlySpan<char> proxyString, bool
break;
}

proxyString = proxyString.Slice(iter);
proxyString = proxyString[iter..];

// Determine which scheme this part is for.
// If no schema is defined, use both.
Expand All @@ -640,23 +640,23 @@ private static bool TryParseProxyConfigPart(ReadOnlySpan<char> proxyString, bool
if (proxyString.StartsWith("http="))
{
proxyType = INSECURE_FLAG;
proxyString = proxyString.Slice("http=".Length);
proxyString = proxyString["http=".Length..];
}
else if (proxyString.StartsWith("https="))
{
proxyType = SECURE_FLAG;
proxyString = proxyString.Slice("https=".Length);
proxyString = proxyString["https=".Length..];
}

if (proxyString.StartsWith("http://"))
{
proxyType = INSECURE_FLAG;
proxyString = proxyString.Slice("http://".Length);
proxyString = proxyString["http://".Length..];
}
else if (proxyString.StartsWith("https://"))
{
proxyType = SECURE_FLAG;
proxyString = proxyString.Slice("https://".Length);
proxyString = proxyString["https://".Length..];
}

// Find the next delimiter, or end of string.
Expand All @@ -667,15 +667,15 @@ private static bool TryParseProxyConfigPart(ReadOnlySpan<char> proxyString, bool
}

// Return URI if it's a match to what we want.
if ((proxyType & wantedFlag) != 0 && Uri.TryCreate(Concat("http://", proxyString.Slice(0, iter)), UriKind.Absolute, out uri))
if ((proxyType & wantedFlag) != 0 && Uri.TryCreate(Concat("http://", proxyString[..iter]), UriKind.Absolute, out uri))
{
charactersConsumed = originalLength - proxyString.Length + iter;
Debug.Assert(charactersConsumed > 0);

return true;
}

proxyString = proxyString.Slice(iter);
proxyString = proxyString[iter..];
}

uri = null;
Expand Down Expand Up @@ -1208,11 +1208,11 @@ public bool GetProxyForUrl(
string destination = uri.AbsoluteUri;
if (uri.Scheme == UriScheme.Wss)
{
destination = UriScheme.Https + destination.Substring(UriScheme.Wss.Length);
destination = UriScheme.Https + destination[UriScheme.Wss.Length..];
}
else if (uri.Scheme == UriScheme.Ws)
{
destination = UriScheme.Http + destination.Substring(UriScheme.Ws.Length);
destination = UriScheme.Http + destination[UriScheme.Ws.Length..];
}
#pragma warning restore CA1845

Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<IsTrimmable>true</IsTrimmable>
<!--<Version>1.yy.1MMdd.1hhmm</Version>-->
<Version>1.23.10614.11615</Version>
<Version>1.23.10614.11642</Version>
<PackageIconUrl>https://avatars.githubusercontent.com/u/79355691?s=200&amp;v=4</PackageIconUrl>
<Company>长沙次元超越科技有限公司</Company>
<Copyright>©️ $(Company). All rights reserved.</Copyright>
Expand Down

0 comments on commit 39cb46d

Please sign in to comment.