Add Tribufu.ComponentModel

This commit is contained in:
2024-11-19 17:57:48 -03:00
parent bb629eedd1
commit 7bb51a21e1
11 changed files with 84 additions and 46 deletions

View File

@ -0,0 +1,30 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
using System;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace Tribufu.ComponentModel
{
public class EnumMemberConverter<T> : EnumConverter
{
public EnumMemberConverter(Type type) : base(type) { }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var type = typeof(T);
foreach (var field in type.GetFields())
{
if (Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)) is EnumMemberAttribute attribute && value is string enumValue && attribute.Value == enumValue)
{
return field.GetValue(null);
}
}
return base.ConvertFrom(context, culture, value);
}
}
}

View File

@ -0,0 +1 @@
# Tribufu

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.ComponentModel</PackageId>
<Description>Tribufu Component Model Helpers</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworks>net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>

View File

@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.Native</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu Native Interop</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
@ -17,12 +10,12 @@
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\vendor\win-arm64\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-arm64\native\" />
<None Include="..\..\vendor\win-x64\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-x64\native\" />
<None Include="..\..\vendor\win-x86\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-x86\native\" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>

View File

@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.Serialization.Newtonsoft</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu Serialization Helpers for Newtonsoft.Json</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
@ -17,10 +10,10 @@
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
</Project>

View File

@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.Serialization</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu Serialization Helpers</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>

View File

@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.Utils</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu Utils</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
@ -17,9 +10,9 @@
<TargetFrameworks>net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
</Project>

View File

@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu .NET SDK</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
@ -17,10 +10,15 @@
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Tribufu.Native\Tribufu.Native.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.ComponentModel.Annotations" />
<PackageReference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tribufu.Native\Tribufu.Native.csproj" />
</ItemGroup>
</Project>