本文整理汇总了C#中System.Enum.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Enum.GetValue方法的具体用法?C# Enum.GetValue怎么用?C# Enum.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Enum
的用法示例。
在下文中一共展示了Enum.GetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasFlag
public bool HasFlag(Enum value)
{
var thisValue = (int)GetValue();
var intValue = (int)value.GetValue();
return (thisValue & intValue) == intValue;
}
示例2: InitDB
/// <summary>
/// 初始化数据库
/// </summary>
public void InitDB()
{
try
{
string CommandText = "SELECT COUNT(*) as cnt FROM sqlite_master where type='table' and name='{0}'";
object count = this.SqliteHelper.ExecuteScalar(CommandType.Text, String.Format(CommandText, "cards"));
if (count == null || count.ToString() == "0")
{
CommandText = "CREATE TABLE [cards] (kdt integer,epc nvarchar(200),dt integer,flag int,PRIMARY KEY(kdt,epc))";
int x = this.SqliteHelper.ExecuteNonQuery(CommandType.Text, CommandText);
}
CommandText = "SELECT COUNT(*) as cnt FROM sqlite_master where type='table' and name='{0}'";
count = this.SqliteHelper.ExecuteScalar(CommandType.Text, String.Format(CommandText, "WorkTimeList"));
if (count == null || count.ToString() == "0")
{
CommandText = "CREATE TABLE [WorkTimeList] (ID varchar(32),LatestTime integer,FromTime integer,ToTime integer,Flag int ,PRIMARY KEY(ID,LatestTime))";
this.SqliteHelper.ExecuteNonQuery(CommandType.Text, CommandText);
}
CommandText = "SELECT COUNT(*) as cnt FROM sqlite_master where type='table' and name='{0}';";
count = this.SqliteHelper.ExecuteScalar(CommandType.Text, String.Format(CommandText, "params"));
if (count == null || count.ToString() == "0")
{
CommandText = "CREATE TABLE [params] (pkey nvarchar(200),pvalue nvarchar(200),PRIMARY KEY(pkey))";
this.SqliteHelper.ExecuteNonQuery(CommandType.Text, CommandText);
CommandText = "";
CfgAttribute cfgAttr = null;
//Array Arrays = Enum.GetValues(typeof(ConfigParams));
///// <summary>
///// 采集器编号
///// </summary>
//[Cfg("1", "^[a-zA-Z_0-9]+$", RegexOptions.None)]
//DeviceNo,
///// <summary>
///// 循环周期(卡循环使用一次最少用时,单位:分钟)
///// </summary>
//[Cfg("90", @"\d+$", RegexOptions.None)]
//CycInterval,
///// <summary>
///// 采集器功能类型
///// </summary>
//[Cfg("-1", "*", RegexOptions.None)]
//DeviceFuncType
Array Arrays = new Enum[] {
//采集器编号
ConfigParams.DeviceNo,
//循环周期(卡循环使用一次最少用时,单位:分钟)
ConfigParams.CycInterval,
//采集器功能类型
ConfigParams.DeviceFuncType
};
for (int i = 0; i < Arrays.Length; i++)
{
ConfigParams cp = (ConfigParams)Arrays.GetValue(i);
cfgAttr = CfgAttribute.GetAttribute<CfgAttribute>(cp);
CommandText += String.Format("insert into [params] (pkey,pvalue) values('{0}','{1}');", cp.ToString(), cfgAttr.DefaultValue);
}
this.SqliteHelper.ExecuteNonQuery(CommandType.Text, CommandText);
}
}
catch (Exception ex)
{
LogManager.WriteLog(Framework.Libs.Common.LogFile.Error, ex.Message);
throw ex;
}
}