本文整理汇总了C#中BuiltInType类的典型用法代码示例。如果您正苦于以下问题:C# BuiltInType类的具体用法?C# BuiltInType怎么用?C# BuiltInType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuiltInType类属于命名空间,在下文中一共展示了BuiltInType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: UATypeInfo
/// <summary>
/// Initializes a new instance of the <see cref="UATypeInfo"/> class.
/// </summary>
/// <param name="builtInType">Type of the built in.</param>
/// <param name="valueRank">The value rank.</param>
/// <param name="arrayDimensions">The array dimensions.</param>
/// <exception cref="System.ArgumentOutOfRangeException">$for {nameof(valueRank)} == {valueRank} {nameof(ArrayDimensions)} must be provided.</exception>
public UATypeInfo(BuiltInType builtInType, int valueRank, int[] arrayDimensions)
{
if ((valueRank == 0 || valueRank > 1) && (arrayDimensions == null || arrayDimensions.Length == 0))
throw new ArgumentOutOfRangeException(nameof(valueRank), $"for {nameof(valueRank)} == {valueRank} {nameof(ArrayDimensions)} must be provided.");
m_builtInType = builtInType;
m_valueRank = valueRank;
m_ArrayDimensionsField = (arrayDimensions == null || arrayDimensions.Length == 0) ? null : (int[])arrayDimensions.Clone();
}
开发者ID:yuriik83,项目名称:OPC-UA-OOI,代码行数:15,代码来源:UATypeInfo.cs
示例2: ShowDialog
/// <summary>
/// Prompts the user to edit an array value.
/// </summary>
public Array ShowDialog(Array value, BuiltInType dataType, bool readOnly, string caption)
{
if (caption != null)
{
this.Text = caption;
}
// detect the data type.
if (dataType == BuiltInType.Null)
{
dataType = TypeInfo.Construct(value).BuiltInType;
}
m_dataType = dataType;
ArrayDV.AllowUserToAddRows = !readOnly;
ArrayDV.AllowUserToDeleteRows = !readOnly;
ArrayDV.RowHeadersVisible = !readOnly;
m_dataset.Tables[0].Clear();
if (value != null)
{
for (int ii = 0; ii < value.Length; ii++)
{
DataRow row = m_dataset.Tables[0].NewRow();
row[0] = new Variant(value.GetValue(ii)).ToString();
row[1] = ii;
m_dataset.Tables[0].Rows.Add(row);
}
}
m_dataset.AcceptChanges();
if (ShowDialog() != DialogResult.OK)
{
return null;
}
m_dataset.AcceptChanges();
if (!readOnly)
{
value = TypeInfo.CreateArray(dataType, m_dataset.Tables[0].Rows.Count);
for (int ii = 0; ii < m_dataset.Tables[0].DefaultView.Count; ii++)
{
string oldValue = m_dataset.Tables[0].DefaultView[ii].Row[0] as string;
object newValue = TypeInfo.Cast(oldValue, m_dataType);
value.SetValue(newValue, ii);
}
}
return value;
}
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:56,代码来源:EditArrayDlg.cs
示例3: GetConsumerBinding
/// <summary>
/// Helper method that creates the consumer binding.
/// </summary>
/// <param name="variableName">Name of the variable.</param>
/// <returns>IConsumerBinding.</returns>
/// <exception cref="System.ArgumentOutOfRangeException">variableName</exception>
public IConsumerBinding GetConsumerBinding(string variableName, BuiltInType encoding)
{
UATypeInfo _uaTypeInfo = new UATypeInfo(encoding);
if (variableName == "Value1")
{
Value1 = new ConsumerBindingMonitoredValue<string>(_uaTypeInfo);
return Value1;
}
else if (variableName == "Value2")
{
Value2 = new ConsumerBindingMonitoredValue<double>(_uaTypeInfo);
return Value2;
}
throw new ArgumentOutOfRangeException("variableName");
}
开发者ID:yuriik83,项目名称:OPC-UA-OOI,代码行数:21,代码来源:ScreeViewModel.cs
示例4: ShowDialog
public Variant? ShowDialog(Variant value, BuiltInType builtInType)
{
if (value != Variant.Null)
{
ValueTB.Text = value.ToString();
}
if (ShowDialog() != DialogResult.OK)
{
return null;
}
if (String.IsNullOrEmpty(ValueTB.Text))
{
return Variant.Null;
}
return new Variant(TypeInfo.Cast(ValueTB.Text, builtInType));
}
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:19,代码来源:SetValueDlg.cs
示例5: SetType
/// <summary>
/// Changes the data type.
/// </summary>
public void SetType(BuiltInType builtInType)
{
if (!CanChangeType)
{
return;
}
AccessInfo info = NavigationMENU.Items[NavigationMENU.Items.Count - 1].Tag as AccessInfo;
TypeInfo currentType = info.TypeInfo;
object currentValue = info.Value;
try
{
EndEdit();
currentValue = info.Value;
}
catch (Exception)
{
currentValue = TypeInfo.GetDefaultValue(currentType.BuiltInType);
}
if (info.Value is Variant)
{
Variant variant = (Variant)info.Value;
currentValue = variant.Value;
if (currentValue != null)
{
currentType = variant.TypeInfo;
if (currentType == null)
{
currentType = TypeInfo.Construct(currentValue);
}
}
}
TypeInfo targetType = new TypeInfo(builtInType, currentType.ValueRank);
object newValue = Convert(currentValue, currentType, targetType, true);
NavigationMENU.Items.RemoveAt(NavigationMENU.Items.Count - 1);
info.TypeInfo = targetType;
info.Value = newValue;
ShowValueNoNotify(info);
}
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:50,代码来源:EditComplexValueCtrl.cs
示例6: ToDouble
/// <summary>
/// Converts a value to a Double
/// </summary>
private static object ToDouble(object value, BuiltInType sourceType)
{
// check for array conversions.
Array array = value as Array;
if (array != null)
{
double[] output = new double[array.Length];
for (int ii = 0; ii < array.Length; ii++)
{
output[ii] = (double)Cast(array.GetValue(ii), BuiltInType.Double);
}
return output;
}
// handle for supported conversions.
switch (sourceType)
{
case BuiltInType.Double:
{
return (double)value;
}
case BuiltInType.Boolean: return Convert.ToDouble((bool)value);
case BuiltInType.SByte: return Convert.ToDouble((sbyte)value);
case BuiltInType.Byte: return Convert.ToDouble((byte)value);
case BuiltInType.Int16: return Convert.ToDouble((short)value);
case BuiltInType.UInt16: return Convert.ToDouble((ushort)value);
case BuiltInType.Int32: return Convert.ToDouble((int)value);
case BuiltInType.UInt32: return Convert.ToDouble((uint)value);
case BuiltInType.Int64: return Convert.ToDouble((long)value);
case BuiltInType.UInt64: return Convert.ToDouble((ulong)value);
case BuiltInType.Float: return Convert.ToDouble((float)value);
case BuiltInType.String:
{
return XmlConvert.ToDouble((string)value);
}
}
// conversion not supported.
return DBNull.Value;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:48,代码来源:ContentFilter.Evaluate.cs
示例7: CreateAnalogItemVariable
private DataItemState CreateAnalogItemVariable(NodeState parent, string path, string name, BuiltInType dataType, int valueRank, object initialValues, Range customRange)
{
return CreateAnalogItemVariable(parent, path, name, (uint)dataType, valueRank, initialValues, customRange);
}
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:4,代码来源:ReferenceNodeManager.cs
示例8: CreateVariableType
/// <summary>
/// Creates a new variable type.
/// </summary>
private BaseVariableTypeState CreateVariableType(NodeState parent, IDictionary<NodeId, IList<IReference>> externalReferences, string path, string name, BuiltInType dataType, int valueRank)
{
BaseDataVariableTypeState type = new BaseDataVariableTypeState();
type.SymbolicName = name;
type.SuperTypeId = VariableTypeIds.BaseDataVariableType;
type.NodeId = new NodeId(path, NamespaceIndex);
type.BrowseName = new QualifiedName(name, NamespaceIndex);
type.DisplayName = type.BrowseName.Name;
type.WriteMask = AttributeWriteMask.None;
type.UserWriteMask = AttributeWriteMask.None;
type.IsAbstract = false;
type.DataType = (uint)dataType;
type.ValueRank = valueRank;
type.Value = null;
IList<IReference> references = null;
if (!externalReferences.TryGetValue(VariableTypeIds.BaseDataVariableType, out references))
{
externalReferences[VariableTypeIds.BaseDataVariableType] = references = new List<IReference>();
}
references.Add(new NodeStateReference(ReferenceTypes.HasSubtype, false, type.NodeId));
if (parent != null)
{
parent.AddReference(ReferenceTypes.Organizes, false, type.NodeId);
type.AddReference(ReferenceTypes.Organizes, true, parent.NodeId);
}
AddPredefinedNode(SystemContext, type);
return type;
}
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:37,代码来源:ReferenceNodeManager.cs
示例9: GetDataTypePrecedence
/// <summary>
/// Returns the data type precedence for the value.
/// </summary>
private static int GetDataTypePrecedence(BuiltInType type)
{
switch (type)
{
case BuiltInType.Double: { return 18; }
case BuiltInType.Float: { return 17; }
case BuiltInType.Int64: { return 16; }
case BuiltInType.UInt64: { return 15; }
case BuiltInType.Int32: { return 14; }
case BuiltInType.UInt32: { return 13; }
case BuiltInType.StatusCode: { return 12; }
case BuiltInType.Int16: { return 11; }
case BuiltInType.UInt16: { return 10; }
case BuiltInType.SByte: { return 9; }
case BuiltInType.Byte: { return 8; }
case BuiltInType.Boolean: { return 7; }
case BuiltInType.Guid: { return 6; }
case BuiltInType.String: { return 5; }
case BuiltInType.ExpandedNodeId: { return 4; }
case BuiltInType.NodeId: { return 3; }
case BuiltInType.LocalizedText: { return 2; }
case BuiltInType.QualifiedName: { return 1; }
}
return 0;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:29,代码来源:ContentFilter.Evaluate.cs
示例10: IsBuiltInType
/// <summary>
/// Checks if the datatype id is a built-in type.
/// </summary>
private bool IsBuiltInType(ExpandedNodeId nodeId, out BuiltInType builtinType)
{
builtinType = BuiltInType.Null;
if (nodeId.IsAbsolute || nodeId.NamespaceIndex != 0 || nodeId.IdType != IdType.Numeric)
{
return false;
}
uint id = (uint)nodeId.Identifier;
if (id > 0 && id <= DataTypes.BaseDataType)
{
builtinType = (BuiltInType)(int)id;
return true;
}
switch (id)
{
case DataTypes.Enumeration: { builtinType = BuiltInType.Int32; break; }
case DataTypes.Number: { builtinType = BuiltInType.Double; break; }
case DataTypes.Integer: { builtinType = BuiltInType.Int64; break; }
case DataTypes.UInteger: { builtinType = BuiltInType.UInt64; break; }
default:
{
return false;
}
}
return true;
}
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:35,代码来源:Com.Da.Server.cs
示例11: ToExpandedNodeId
/// <summary>
/// Converts a value to a ExpandedNodeId
/// </summary>
private static object ToExpandedNodeId(object value, BuiltInType sourceType)
{
// check for array conversions.
Array array = value as Array;
if (array != null)
{
ExpandedNodeId[] output = new ExpandedNodeId[array.Length];
for (int ii = 0; ii < array.Length; ii++)
{
output[ii] = (ExpandedNodeId)Cast(array.GetValue(ii), BuiltInType.ExpandedNodeId);
}
return output;
}
// handle for supported conversions.
switch (sourceType)
{
case BuiltInType.ExpandedNodeId:
{
return (ExpandedNodeId)value;
}
case BuiltInType.NodeId:
{
return (ExpandedNodeId)(NodeId)value;
}
case BuiltInType.String:
{
return ExpandedNodeId.Parse((string)value);
}
}
// conversion not supported.
return null;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:42,代码来源:ContentFilter.Evaluate.cs
示例12: CreateVariable
/// <summary>
/// Creates a new variable.
/// </summary>
private BaseDataVariableState CreateVariable(NodeState parent, string path, string name, BuiltInType dataType, int valueRank)
{
return CreateVariable(parent, path, name, (uint)dataType, valueRank);
}
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:7,代码来源:ReferenceNodeManager.cs
示例13: ReadVariantArrayBody
private Variant ReadVariantArrayBody(string fieldName, BuiltInType type)
{
switch (type)
{
case BuiltInType.Boolean: { return new Variant(ReadBooleanArray(fieldName), TypeInfo.Arrays.Boolean); }
case BuiltInType.SByte: { return new Variant(ReadSByteArray(fieldName), TypeInfo.Arrays.SByte); }
case BuiltInType.Byte: { return new Variant(ReadByteArray(fieldName), TypeInfo.Arrays.Byte); }
case BuiltInType.Int16: { return new Variant(ReadInt16Array(fieldName), TypeInfo.Arrays.Int16); }
case BuiltInType.UInt16: { return new Variant(ReadUInt16Array(fieldName), TypeInfo.Arrays.UInt16); }
case BuiltInType.Int32: { return new Variant(ReadInt32Array(fieldName), TypeInfo.Arrays.Int32); }
case BuiltInType.UInt32: { return new Variant(ReadUInt32Array(fieldName), TypeInfo.Arrays.UInt32); }
case BuiltInType.Int64: { return new Variant(ReadInt64Array(fieldName), TypeInfo.Arrays.Int64); }
case BuiltInType.UInt64: { return new Variant(ReadUInt64Array(fieldName), TypeInfo.Arrays.UInt64); }
case BuiltInType.Float: { return new Variant(ReadFloatArray(fieldName), TypeInfo.Arrays.Float); }
case BuiltInType.Double: { return new Variant(ReadDoubleArray(fieldName), TypeInfo.Arrays.Double); }
case BuiltInType.String: { return new Variant(ReadStringArray(fieldName), TypeInfo.Arrays.String); }
case BuiltInType.ByteString: { return new Variant(ReadByteStringArray(fieldName), TypeInfo.Arrays.ByteString); }
case BuiltInType.DateTime: { return new Variant(ReadDateTimeArray(fieldName), TypeInfo.Arrays.DateTime); }
case BuiltInType.Guid: { return new Variant(ReadGuidArray(fieldName), TypeInfo.Arrays.Guid); }
case BuiltInType.NodeId: { return new Variant(ReadNodeIdArray(fieldName), TypeInfo.Arrays.NodeId); }
case BuiltInType.ExpandedNodeId: { return new Variant(ReadExpandedNodeIdArray(fieldName), TypeInfo.Arrays.ExpandedNodeId); }
case BuiltInType.QualifiedName: { return new Variant(ReadQualifiedNameArray(fieldName), TypeInfo.Arrays.QualifiedName); }
case BuiltInType.LocalizedText: { return new Variant(ReadLocalizedTextArray(fieldName), TypeInfo.Arrays.LocalizedText); }
case BuiltInType.StatusCode: { return new Variant(ReadStatusCodeArray(fieldName), TypeInfo.Arrays.StatusCode); }
case BuiltInType.XmlElement: { return new Variant(ReadXmlElementArray(fieldName), TypeInfo.Arrays.XmlElement); }
case BuiltInType.ExtensionObject: { return new Variant(ReadExtensionObjectArray(fieldName), TypeInfo.Arrays.ExtensionObject); }
case BuiltInType.Variant: { return new Variant(ReadVariantArray(fieldName), TypeInfo.Arrays.Variant); }
}
return Variant.Null;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:31,代码来源:JsonDecoder.cs
示例14: ToDateTime
/// <summary>
/// Converts a value to a DateTime
/// </summary>
private static object ToDateTime(object value, BuiltInType sourceType)
{
// check for array conversions.
Array array = value as Array;
if (array != null)
{
DateTime[] output = new DateTime[array.Length];
for (int ii = 0; ii < array.Length; ii++)
{
output[ii] = (DateTime)Cast(array.GetValue(ii), BuiltInType.DateTime);
}
return output;
}
// handle for supported conversions.
switch (sourceType)
{
case BuiltInType.DateTime:
{
return (DateTime)value;
}
case BuiltInType.String:
{
return XmlConvert.ToDateTimeOffset((string) value);
}
}
// conversion not supported.
return null;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:37,代码来源:ContentFilter.Evaluate.cs
示例15: ToQualifiedName
/// <summary>
/// Converts a value to a QualifiedName
/// </summary>
private static object ToQualifiedName(object value, BuiltInType sourceType)
{
// check for array conversions.
Array array = value as Array;
if (array != null)
{
QualifiedName[] output = new QualifiedName[array.Length];
for (int ii = 0; ii < array.Length; ii++)
{
output[ii] = (QualifiedName)Cast(array.GetValue(ii), BuiltInType.QualifiedName);
}
return output;
}
// handle for supported conversions.
switch (sourceType)
{
case BuiltInType.QualifiedName:
{
return (QualifiedName)value;
}
case BuiltInType.String:
{
return QualifiedName.Parse((string)value);
}
}
// conversion not supported.
return null;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:37,代码来源:ContentFilter.Evaluate.cs
示例16: ToByteString
/// <summary>
/// Converts a value to a ByteString
/// </summary>
private static object ToByteString(object value, BuiltInType sourceType)
{
// check for array conversions.
Array array = value as Array;
if (array != null)
{
byte[][] output = new byte[array.Length][];
for (int ii = 0; ii < array.Length; ii++)
{
output[ii] = (byte[])Cast(array.GetValue(ii), BuiltInType.ByteString);
}
return output;
}
// handle for supported conversions.
switch (sourceType)
{
case BuiltInType.ByteString:
{
return (byte[])value;
}
case BuiltInType.Guid:
{
return ((Guid)value).ToByteArray();
}
}
// conversion not supported.
return null;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:37,代码来源:ContentFilter.Evaluate.cs
示例17: Cast
/// <summary>
/// Casts a value to the specified target type.
/// </summary>
private static object Cast(object source, BuiltInType targetType)
{
BuiltInType sourceType = GetBuiltInType(source);
if (sourceType == BuiltInType.Null)
{
return null;
}
return Cast(source, sourceType, targetType);
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:14,代码来源:ContentFilter.Evaluate.cs
示例18: ToStatusCode
/// <summary>
/// Converts a value to a StatusCode
/// </summary>
private static object ToStatusCode(object value, BuiltInType sourceType)
{
// check for array conversions.
Array array = value as Array;
if (array != null)
{
StatusCode[] output = new StatusCode[array.Length];
for (int ii = 0; ii < array.Length; ii++)
{
output[ii] = (StatusCode)Cast(array.GetValue(ii), BuiltInType.StatusCode);
}
return output;
}
// handle for supported conversions.
switch (sourceType)
{
case BuiltInType.StatusCode:
{
return (StatusCode)value;
}
case BuiltInType.UInt16:
{
uint code = Convert.ToUInt32((ushort)value);
code <<= 16;
return (StatusCode)code;
}
case BuiltInType.Int32:
{
return (StatusCode)Convert.ToUInt32((int)value);
}
case BuiltInType.UInt32:
{
return (StatusCode)(uint)value;
}
case BuiltInType.Int64:
{
return (StatusCode)Convert.ToUInt32((long)value);
}
case BuiltInType.UInt64:
{
return (StatusCode)Convert.ToUInt32((ulong)value);
}
}
// conversion not supported.
return null;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:59,代码来源:ContentFilter.Evaluate.cs
示例19: CreateDynamicVariables
private BaseDataVariableState[] CreateDynamicVariables(NodeState parent, string path, string name, BuiltInType dataType, int valueRank, uint numVariables)
{
return CreateDynamicVariables(parent, path, name, (uint)dataType, valueRank, numVariables);
}
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:5,代码来源:ReferenceNodeManager.cs
示例20: ToLocalizedText
/// <summary>
/// Converts a value to a LocalizedText
/// </summary>
private static object ToLocalizedText(object value, BuiltInType sourceType)
{
// check for array conversions.
Array array = value as Array;
if (array != null)
{
LocalizedText[] output = new LocalizedText[array.Length];
for (int ii = 0; ii < array.Length; ii++)
{
output[ii] = (LocalizedText)Cast(array.GetValue(ii), BuiltInType.LocalizedText);
}
return output;
}
// handle for supported conversions.
switch (sourceType)
{
case BuiltInType.LocalizedText:
{
return (LocalizedText)value;
}
case BuiltInType.String:
{
return new LocalizedText((string)value);
}
}
// conversion not supported.
return null;
}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:37,代码来源:ContentFilter.Evaluate.cs
注:本文中的BuiltInType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论