Skip to content

Commit

Permalink
ComplexTypes Improvements (#1383)
Browse files Browse the repository at this point in the history
- Fixed typo in StructureDefinitionAttribute
- Adapt using of fixed StructureDefinitionAttribute
- Resolve method internal name conflict
- Enable TypeInfo.GetSystemType to support ExpandedNodeId
- Redirect request with absolute NodeIds an directly use the EncodableFactory.GetSystemType method
  • Loading branch information
SBaeumler committed Apr 28, 2021
1 parent 7a4a222 commit e8df315
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public static void DataMemberAttribute(this PropertyBuilder typeBuilder, string
}

/// <summary>
/// Build the StructureDefiniton attribute for a complex type.
/// Build the StructureDefinition attribute for a complex type.
/// </summary>
public static void StructureDefinitonAttribute(
public static void StructureDefinitionAttribute(
this TypeBuilder typeBuilder,
StructureDefinition structureDefinition)
{
var attributeType = typeof(StructureDefinitionAttribute);
var baseDataType = StructureDefinitionAttribute.FromBaseType(structureDefinition.BaseDataType);
var baseDataType = ComplexTypes.StructureDefinitionAttribute.FromBaseType(structureDefinition.BaseDataType);
ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes);
CustomAttributeBuilder builder = new CustomAttributeBuilder(
ctorInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public Type AddEnumType(QualifiedName typeName, LocalizedText[] enumDefinition)
TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Serializable,
baseType);
structureBuilder.DataContractAttribute(m_targetNamespace);
structureBuilder.StructureDefinitonAttribute(structureDefinition);
structureBuilder.StructureDefinitionAttribute(structureDefinition);
return new ComplexTypeFieldBuilder(structureBuilder, structureDefinition.StructureType);
}
#endregion
Expand Down
4 changes: 2 additions & 2 deletions Stack/Opc.Ua.Core/Types/Utils/TypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,14 @@ public static BuiltInType GetBuiltInType(NodeId datatypeId, ITypeTable typeTree)
/// <param name="datatypeId">The datatype id.</param>
/// <param name="factory">The factory used to store and retrieve underlying OPC UA system types.</param>
/// <returns>The system type for the <paramref name="datatypeId"/>.</returns>
public static Type GetSystemType(NodeId datatypeId, EncodeableFactory factory)
public static Type GetSystemType(ExpandedNodeId datatypeId, EncodeableFactory factory)
{
if (datatypeId == null)
{
return null;
}

if (datatypeId.NamespaceIndex != 0 || datatypeId.IdType != Opc.Ua.IdType.Numeric)
if (datatypeId.NamespaceIndex != 0 || datatypeId.IdType != Opc.Ua.IdType.Numeric || datatypeId.IsAbsolute)
{
return factory.GetSystemType(datatypeId);
}
Expand Down

0 comments on commit e8df315

Please sign in to comment.