本文整理汇总了C#中IDevice.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IDevice.GetType方法的具体用法?C# IDevice.GetType怎么用?C# IDevice.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDevice
的用法示例。
在下文中一共展示了IDevice.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
///
/// </summary>
/// <param name="device"></param>
/// <param name="operaName"></param>
/// <param name="keyValues"></param>
public ExecuteResult Execute(IDevice device, string operaName, KeyValueCollection keyValues)
{
if (device == null)
{
throw new ArgumentNullException("device");
}
if (keyValues == null)
{
keyValues = new KeyValueCollection();
}
if (!(device.Station.CommuniPort != null
&& device.Station.CommuniPort.IsOpened ))
{
return ExecuteResult.CreateFailExecuteResult("not connected");
}
IOpera opera = device.Dpu.OperaFactory.Create(device.GetType().Name,
operaName);
foreach (KeyValue kv in keyValues)
{
opera.SendPart[kv.Key] = kv.Value;
}
TimeSpan timeout = TimeSpan.FromMilliseconds(device.Station.CommuniPortConfig.TimeoutMilliSecond );
this.Task = new Task(device, opera, Strategy.CreateImmediateStrategy(), timeout, 1);
device.TaskManager.Tasks.Enqueue(this.Task);
return ExecuteResult.CreateSuccessExecuteResult();
}
示例2: GetPropertyInfo
private IEnumerable<PropertyInfo> GetPropertyInfo(IDevice device)
{
var properties = device.GetType().GetProperties();
foreach (var property in properties)
{
var attribute = property.GetCustomAttribute<DevicePropertyAttribute>();
if (attribute == null)
{
continue;
}
yield return property;
}
}
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:15,代码来源:DevicePersistingService.cs
示例3: Log
/// <summary>
///
/// </summary>
/// <param name="device"></param>
/// <param name="cd"></param>
public static void Log(IDevice device, CommuniDetail cd)
{
if (Enabled)
{
string path = string.Format(
".\\CommuniLog\\{0}\\{1}_{2}.txt",
device.Station.Name,
device.GetType().Name,
device.Address);
path = PathUtils.MapToStartupPath(path);
StreamWriter sw = GetStreamWriter(path);
sw.WriteLine(cd.ToString());
sw.WriteLine();
sw.Flush();
sw.Close();
}
}
示例4: AddHeader
protected void AddHeader(Panel div, IDevice dev, int iNum)
{
string sNum = String.Format("{0:00}", iNum);
Panel divHeader = new Panel();
Image imgIcon = new Image();
Label devName = new Label();
LinkButton btnDelete = new LinkButton();
Image imgDelete = new Image();
divHeader.Attributes["name"] = "divHeader" + sNum;
divHeader.CssClass = "device-status-header";
imgIcon.Attributes["name"] = "imgIcon" + sNum;
imgIcon.ImageUrl = "Content/images/" + dev.GetType().Name + "_3.png";
imgIcon.CssClass = "device-status-icon";
devName.Attributes["name"] = "devName" + sNum;
devName.CssClass = "device-status-name";
devName.Text = dev.Name;
btnDelete.Attributes["name"] = "btnDelete" + sNum;
btnDelete.Click += new EventHandler(this.BtnDel_Click);
btnDelete.CssClass = "device-status-btn-del";
imgDelete.Attributes["name"] = "imgDelete" + sNum;
imgDelete.ImageUrl = "Content/images/del_green_2.png";
imgDelete.CssClass = "device-status-img-del";
btnDelete.Controls.Add(imgDelete);
divHeader.Controls.Add(imgIcon);
divHeader.Controls.Add(devName);
divHeader.Controls.Add(btnDelete);
div.Controls.Add(divHeader);
}
示例5: GetDeviceProperties
private IList<PropertyInfo> GetDeviceProperties(IDevice device)
{
var result = new List<PropertyInfo>();
if (device != null)
{
var pairs = new List<Tuple<int, PropertyInfo>>();
var properties = device.GetType().GetProperties();
foreach (var property in properties)
{
var attribute = property.GetCustomAttribute<DevicePropertyAttribute>(inherit: true);
if (attribute != null)
{
pairs.Add(Tuple.Create(attribute.SortOrder, property));
}
}
result.AddRange(pairs.OrderBy(p => p.Item1).Select(p => p.Item2));
}
return result;
}
示例6: Create
/// <summary>
///
/// </summary>
/// <returns></returns>
public TaskCollection Create(IDevice device)
{
TaskCollection tasks = new TaskCollection();
// TODO: not find
//
foreach (TaskDefine td in TaskDefines)
{
bool b = StringHelper.Equal(td.DeviceType, device.GetType().Name);
if (!b)
{
continue;
}
IOpera opera = this.OperaFactory.Create(td.DeviceType, td.OperaName);
Strategy strategy = td.StrategyDefine.Create();
TimeSpan timeout = TimeSpan.FromMilliseconds(device.Station.CommuniPortConfig.TimeoutMilliSecond);
Task t = new Task(device, opera, strategy, timeout, td.RetryTimes);
device.TaskManager.Tasks.Enqueue(t);
tasks.Add(t);
}
_log.Info("create '{0}' task count '{1}'", device.GetType().Name, tasks.Count);
return tasks;
}
示例7: GetFiltersFromCache
private FilterCollection GetFiltersFromCache(IDevice device)
{
Type type = device.GetType ();
if (_deviceTypeFiltersDict.ContainsKey(type))
{
FilterCollection r = _deviceTypeFiltersDict[device.GetType()];
return r;
}
else
{
string path = GetFilterConfigFile(device);
FilterCollection filters = new FilterCollection();
if (File.Exists(path))
{
filters = FilterFactory.CreateFromConfigFile(path);
}
_deviceTypeFiltersDict[type] = filters;
return filters;
}
}
示例8: GetFilterConfigFile
/// <summary>
///
/// </summary>
/// <returns></returns>
private string GetFilterConfigFile(IDevice device)
{
string path = device.GetType().Assembly.Location;
string directoryName = Path.GetDirectoryName(path);
return Path.Combine(directoryName, FILTER_RELATIVE_PATH);
}
示例9: OnProcessUpload
/// <summary>
///
/// </summary>
/// <param name="device"></param>
/// <param name="bs"></param>
/// <returns></returns>
//public override IUploadParseResult OnProcessUpload(IDevice device, byte[] bs)
public override void OnProcessUpload(IDevice device, IParseResult pr)
{
XGDevice xg = (XGDevice)device;
DateTime dt = (DateTime)pr.Results["DT"];
string cardSN = pr.Results["cardSN"].ToString();
//xg.DeviceDataManager.Last = new XGData(dt, cardSN);
SaveToDBAndUpdateLast(xg, dt, cardSN);
IOpera op = device.Dpu.OperaFactory.Create(device.GetType().Name,
XGOperaNames.RemoveUpload);
TimeSpan timeout = TimeSpan.FromMilliseconds(device.Station.CommuniPortConfig.TimeoutMilliSecond);
Task task = new Task(device, op, Strategy.CreateImmediateStrategy(), timeout,1);
device.TaskManager.Tasks.Enqueue(task);
}