CntrlComparison parsing

This commit is contained in:
2015-12-04 10:15:51 -05:00
parent 4d46f206ac
commit 685e8c8658
39 changed files with 820 additions and 491 deletions
+45
View File
@@ -0,0 +1,45 @@
using System;
using System.Linq;
using System.Runtime.CompilerServices;
namespace LeafWeb.Core.Utility
{
[AttributeUsage(AttributeTargets.Property)]
public class ParseInfoAttribute : Attribute
{
public int Position { get; private set; }
public string Units { get; private set; }
public string Title { get; private set; }
public string AlterateTitle { get; private set; }
public string ExampleValue { get; private set; }
public string[] FieldNames
{
get
{
var fieldNames = new[] {Title, Title.SplitCamelCase()};
if (!string.IsNullOrEmpty(AlterateTitle))
fieldNames = fieldNames.Concat(new[] { AlterateTitle }).ToArray();
return fieldNames;
}
}
public ParseInfoAttribute(int position, [CallerMemberName]string title = null, string units = null, string alternateTitle = null, string exampleValue = null)
{
AlterateTitle = alternateTitle;
ExampleValue = exampleValue;
Title = title;
Position = position;
Units = units;
}
public bool IsTitleMatch(string title)
{
return FieldNames.Any(t => string.Compare(title, t, StringComparison.InvariantCultureIgnoreCase) == 0);
}
public bool IsPositionMatch(int index)
{
return Position == index;
}
}
}