本文整理汇总了C#中AttributeValue.setDataValue方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeValue.setDataValue方法的具体用法?C# AttributeValue.setDataValue怎么用?C# AttributeValue.setDataValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeValue
的用法示例。
在下文中一共展示了AttributeValue.setDataValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: initFromDataContractObj
/// <summary>
/// 将从数据总线获取的监控代理列表信息转化为对应的本地类型
/// </summary>
/// <param name="monAgentList">从数据总线获取的监控代理列表</param>
public void initFromDataContractObj(bus.MonAgentInfo[] monAgentArray)
{
this.monitorAgentList = new ObservableCollection<MonitorAgent>();
for (int i = 0; i < monAgentArray.Length; i++)
{
bus.MonAgentInfo monAgent = monAgentArray[i];//取出一个MonAgentInfo元素引用
//新建一个MonitorAgent对象
MonitorAgent monAgent_new = new MonitorAgent();
monAgent_new.ID = monAgent.Id;
monAgent_new.DeviceList = new ObservableCollection<Device>();
//依次初始化monAgent_new的每个设备
foreach (bus.MonDeviceInfo devInfo in monAgent.MonDevList)
{
//新建一个Device对象
Device device_new = new Device();
device_new.MonAgentBelongTo = monAgent_new;//添加设备对其所属监控代理的引用
//利用数据契约对应对象初始化
device_new.DevID = devInfo.Id;
device_new.DevType = devInfo.Type;
device_new.Name = devInfo.Name;
//初始化静态属性集合
device_new.StaticStateList = new ObservableCollection<StaticState>();
foreach (bus.StaticAttribute staticAttribute in devInfo.StaticAttrList)
{
//新建一个StaticState对象
StaticState sState_new = new StaticState();
sState_new.DeviceBelongTo = device_new;//添加状态对其所属设备的引用
sState_new.Name = staticAttribute.AttrName;
AttributeValue attrVal_new = new AttributeValue();
try
{
attrVal_new.setDataValue(AttributeValue.mapType(staticAttribute.AttrValueType),
staticAttribute.AttrValue);
sState_new.AttributeValue = attrVal_new;
}
catch (Exception e)
{
throw new ApplicationException("数据契约静态属性'" + staticAttribute.AttrName + "'转化为本地类型中,值转化出错:" + e.Message, e);
}
device_new.StaticStateList.Add(sState_new);//将新静态属性添加到新静态属性列表
}
//初始化动态属性集合
device_new.DynamicStateList = new ObservableCollection<DynamicState>();
foreach (bus.State dState in devInfo.StateList)
{
//新建一个StaticState对象
DynamicState dState_new = new DynamicState();
dState_new.DeviceBelongTo = device_new;//添加状态对其所属设备的引用
dState_new.Name = dState.DsName;
dState_new.Title = dState.DsTitle;
dState_new.Unit = dState.DsUnit;
dState_new.ViewType = dState.DsViewType;
dState_new.AttributeValue = new AttributeValue();
try
{
dState_new.AttributeValue.setDataValue(AttributeValue.mapType(dState.DsValueType),
dState.DsDefaultValue);
}
catch (Exception e)
{
throw new ApplicationException("数据契约动态属性'" + dState.DsName + "'转化为本地类型中,值转化出错:" + e.Message, e);
}
device_new.DynamicStateList.Add(dState_new);//将新静态属性添加到新静态属性列表
}
monAgent_new.DeviceList.Add(device_new);//将新设备添加到设备列表
}//devInfo
this.monitorAgentList.Add(monAgent_new);//将新监控代理添加到代理列表
}//monAgent
}