本文整理匯總了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;
}
}