mirror of
https://github.com/Tribufu/TribufuDotNet
synced 2026-08-09 21:01:07 +00:00
Migrate to new tribufu project structure (#2)
* Migrate to new tribufu project structure * Update .gitignore * Remove old api files * Update Directory.Build.props * Rename solution
This commit is contained in:
parent
be25ee8fe3
commit
7e8e192dc3
115 changed files with 41 additions and 262 deletions
30
Source/Tribufu.ComponentModel/EnumMemberConverter.cs
Normal file
30
Source/Tribufu.ComponentModel/EnumMemberConverter.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Source/Tribufu.ComponentModel/README.md
Normal file
1
Source/Tribufu.ComponentModel/README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Tribufu ComponentModel
|
||||
17
Source/Tribufu.ComponentModel/Tribufu.ComponentModel.csproj
Normal file
17
Source/Tribufu.ComponentModel/Tribufu.ComponentModel.csproj
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<PackageId>Tribufu.ComponentModel</PackageId>
|
||||
<Description>Tribufu ComponentModel</Description>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<IsPublishable>false</IsPublishable>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue