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