Initial Commit after switching from SVN to git
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace MFR_RESTClient.generic;
|
||||
|
||||
public static class GenericExtensions
|
||||
{
|
||||
public static object? TryConvert(this string input, Type targetType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var converter = TypeDescriptor.GetConverter(targetType);
|
||||
return converter?.ConvertFromString(context: null, culture: CultureInfo.InvariantCulture, text: input);
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum EntityTypes
|
||||
{
|
||||
ItemType,
|
||||
ServiceRequest,
|
||||
Item,
|
||||
StockMovement,
|
||||
CostCenter,
|
||||
ItemUnit,
|
||||
TimeEvent,
|
||||
Document,
|
||||
Invoice,
|
||||
Report,
|
||||
Comment,
|
||||
Attachment,
|
||||
Appointment,
|
||||
Step,
|
||||
ServiceObject,
|
||||
StepListTemplate,
|
||||
StepListTemplateInstance,
|
||||
Contact,
|
||||
Tag,
|
||||
Product,
|
||||
Company,
|
||||
User,
|
||||
Qualification,
|
||||
none = -1
|
||||
}
|
||||
|
||||
public static class EntityHelper
|
||||
{
|
||||
public static string EntityName(EntityTypes et)
|
||||
{
|
||||
var ret = et.ToString().Replace("_", "-");
|
||||
return ret.StartsWith("-") ? ret[1..] : ret;
|
||||
}
|
||||
|
||||
public static EntityTypes EntityValue(string etname)
|
||||
{
|
||||
if (Enum.TryParse<EntityTypes>(etname, out var et))
|
||||
return et;
|
||||
|
||||
foreach (EntityTypes ty in Enum.GetValues<EntityTypes>())
|
||||
{
|
||||
if (string.Equals(ty.ToString(), etname, StringComparison.OrdinalIgnoreCase))
|
||||
return ty;
|
||||
}
|
||||
|
||||
return EntityTypes.none;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class MFRItem
|
||||
{
|
||||
public Dictionary<string, string> Fields { get; set; }
|
||||
|
||||
protected MFRItem()
|
||||
{
|
||||
Fields = new Dictionary<string, string>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user