/// <summary>
 /// Initializes a new instance of the <see cref="UANodeContext" /> class.
 /// </summary>
 /// <param name="addressSpaceContext">The address space context.</param>
 /// <param name="modelContext">The model context.</param>
 /// <param name="nodeId">An object of <see cref="NodeId"/> that stores an identifier for a node in a server's address space.</param>
 internal UANodeContext(AddressSpaceContext addressSpaceContext, UAModelContext modelContext, NodeId nodeId)
 {
     this.m_AddressSpaceContext = addressSpaceContext;
     this.NodeIdContext         = nodeId;
     this.m_ModelContext        = modelContext;
     this.InRecursionChain      = false;
 }
        public void EqualsTest()
        {
            IUAModelContext _mc     = new UAModelContext();
            UANodeContext   _first  = new UANodeContext(new AddressSpaceBuildContext(), _mc, NodeId.Parse("ns=1;i=11"));
            UANodeContext   _second = new UANodeContext(new AddressSpaceBuildContext(), _mc, NodeId.Parse("ns=1;i=11"));

            Assert.IsTrue(_first.Equals(_second));
        }
Пример #3
0
        /// <summary>
        /// Gets the parameters.
        /// </summary>
        /// <param name="arguments">The <see cref="XmlElement"/> encapsulates the arguments.</param>
        /// <returns>Parameter[].</returns>
        public Parameter[] GetParameters(XmlElement arguments)
        {
            List <Parameter> _parameters = new List <Parameter>();

            foreach (DataSerialization.Argument _item in arguments.GetParameters())
            {
                _parameters.Add(UAModelContext.ExportArgument(_item));
            }
            return(_parameters.ToArray());
        }
Пример #4
0
        internal UANodeContext GetOrCreateNodeContext(NodeId nodeId, UAModelContext modelContext, Action <TraceMessage> traceEvent)
        {
            UANodeContext _ret;
            string        _idKey = nodeId.ToString();

            if (!m_NodesDictionary.TryGetValue(_idKey, out _ret))
            {
                _ret = new UANodeContext(this, modelContext, nodeId);
                m_NodesDictionary.Add(_idKey, _ret);
            }
            return(_ret);
        }
        public void ConstructorTest()
        {
            IUAModelContext _mc     = new UAModelContext();
            UANodeContext   _toTest = new UANodeContext(new AddressSpaceBuildContext(), _mc, NodeId.Parse("ns=1;i=11"));

            Assert.IsNotNull(_toTest.BrowseName);
            Assert.IsTrue(new QualifiedName() == _toTest.BrowseName);
            Assert.IsFalse(_toTest.InRecursionChain);
            Assert.IsFalse(_toTest.IsProperty);
            Assert.IsFalse(_toTest.IsPropertyVariableType);
            Assert.IsFalse(_toTest.ModelingRule.HasValue);
            Assert.IsNotNull(_toTest.NodeIdContext);
            Assert.IsTrue(_toTest.NodeIdContext.ToString() == "ns=1;i=11");
            Assert.AreSame(_mc, _toTest.UAModelContext);
            Assert.IsNull(_toTest.UANode);
        }
Пример #6
0
        /// <summary>
        /// Updates this instance in case the wrapped <see cref="UANode"/> is recognized in the model.
        /// </summary>
        /// <param name="node">The node <see cref="UANode"/> containing definition to be added to the model.</param>
        void IUANodeContext.Update(UANode node)
        {
            if (node == null)
            {
                return;
            }
            UANode = node;
            QualifiedName _broseName = node.BrowseName.Parse(BuildErrorsHandling.Log.TraceEvent);

            Debug.Assert(BrowseName != null);
            if (QualifiedName.IsNull(_broseName))
            {
                NodeId _id = NodeId.Parse(UANode.NodeId);
                _broseName = new QualifiedName(string.Format("EmptyBrowseName{0}", _id.IdentifierPart), _id.NamespaceIndex);
                BuildErrorsHandling.Log.TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.EmptyBrowseName, string.Format("New identifier {0} is generated to proceed.", _broseName)));
            }
            BrowseName = UAModelContext.ImportQualifiedName(_broseName);
        }
        internal static UAReferenceContext NewReferenceStub
            (Reference reference, AddressSpaceContext addressSpaceContext, UAModelContext modelContext, UANodeContext parentNode, Action <TraceMessage> traceEvent)
        {
            UANodeContext      targetNode = modelContext.GetOrCreateNodeContext(reference.Value, true, traceEvent);
            UAReferenceContext _stb       = new UAReferenceContext()
            {
                m_Context  = addressSpaceContext,
                ParentNode = parentNode,
                SourceNode = reference.IsForward ? parentNode : targetNode,
                ModelNode  = reference,
                TargetNode = reference.IsForward ? targetNode : parentNode,
                TypeNode   = modelContext.GetOrCreateNodeContext(reference.ReferenceType, true, traceEvent),
            };

            if (_stb.TypeNode != null && _stb.TypeNode.NodeIdContext.NamespaceIndex == 0)
            {
                _stb.ReferenceKind = _stb.GetReferenceKind(_stb.TypeNode);
            }
            return(_stb);
        }
Пример #8
0
 private void ImportUANode(UANode node, UAModelContext modelContext, Action <TraceMessage> traceEvent)
 {
     try
     {
         if (node == null)
         {
             m_TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NodeCannotBeNull, "At Importing UANode."));
         }
         NodeId        nodeId    = modelContext.ImportNodeId(node.NodeId, false, m_TraceEvent);
         UANodeContext _newNode  = null;
         string        nodeIdKey = nodeId.ToString();
         if (!m_NodesDictionary.TryGetValue(nodeIdKey, out _newNode))
         {
             _newNode = new UANodeContext(this, modelContext, nodeId);
             _newNode.Update(node, traceEvent);
             m_NodesDictionary.Add(nodeIdKey, _newNode);
         }
         else
         {
             if (_newNode.UANode != null)
             {
                 m_TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NodeIdDuplicated, String.Format("The {0} is already defined.", node.NodeId.ToString())));
             }
             _newNode.Update(node, traceEvent);
         }
         foreach (Reference _rf in node.References)
         {
             UAReferenceContext _rs = UAReferenceContext.NewReferenceStub(_rf, this, modelContext, _newNode, m_TraceEvent);
             if (!m_References.ContainsKey(_rs.Key))
             {
                 m_References.Add(_rs.Key, _rs);
             }
         }
     }
     catch (Exception _ex)
     {
         string _msg = String.Format("ImportUANode {1} is interrupted by exception {0}", _ex.Message, node.NodeId);
         m_TraceEvent(TraceMessage.DiagnosticTraceMessage(_msg));
     }
 }
Пример #9
0
        //methods
        private void ImportNodeSet(UANodeSet model)
        {
            if (model.ServerUris != null)
            {
                m_TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NotSupportedFeature, "ServerUris is omitted during the import"));
            }
            if (model.Extensions != null)
            {
                m_TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NotSupportedFeature, "Extensions is omitted during the import"));
            }
            string _namespace = model.NamespaceUris == null?m_NamespaceTable.GetString(0) : model.NamespaceUris[0];

            m_TraceEvent(TraceMessage.DiagnosticTraceMessage(String.Format("Entering AddressSpaceContext.ImportNodeSet - starting import {0}.", _namespace)));
            UAModelContext _modelContext = new UAModelContext(model.Aliases, model.NamespaceUris, this);

            m_TraceEvent(TraceMessage.DiagnosticTraceMessage("AddressSpaceContext.ImportNodeSet - context for imported model is created and starting import nodes."));
            foreach (UANode _nd in model.Items)
            {
                this.ImportUANode(_nd, _modelContext, m_TraceEvent);
            }
            m_TraceEvent(TraceMessage.DiagnosticTraceMessage(String.Format("Finishing AddressSpaceContext.ImportNodeSet - imported {0} nodes.", model.Items.Length)));
        }
Пример #10
0
 internal UANodeContext GetOrCreateNodeContext(NodeId nodeId, UAModelContext modelContext, Action<TraceMessage> traceEvent)
 {
     UANodeContext _ret;
       string _idKey = nodeId.ToString();
       if (!m_NodesDictionary.TryGetValue(_idKey, out _ret))
       {
     _ret = new UANodeContext(this, modelContext, nodeId);
     m_NodesDictionary.Add(_idKey, _ret);
       }
       return _ret;
 }
Пример #11
0
 internal static UAReferenceContext NewReferenceStub(Reference reference, AddressSpaceContext addressSpaceContext, UAModelContext modelContext, UANodeContext parentNode, Action<TraceMessage> traceEvent)
 {
     UANodeContext targetNode = modelContext.GetOrCreateNodeContext(reference.Value, true, traceEvent);
       UAReferenceContext _stb = new UAReferenceContext()
       {
     m_Context = addressSpaceContext,
     ParentNode = parentNode,
     SourceNode = reference.IsForward ? parentNode : targetNode,
     ModelNode = reference,
     TargetNode = reference.IsForward ? targetNode : parentNode,
     TypeNode = modelContext.GetOrCreateNodeContext(reference.ReferenceType, true, traceEvent),
       };
       if (_stb.TypeNode != null && _stb.TypeNode.NodeIdContext.NamespaceIndex == 0)
     _stb.ReferenceKind = _stb.GetReferenceKind(_stb.TypeNode);
       return _stb;
 }
Пример #12
0
 private static void Update(IDataTypeFactory nodeDesign, UADataType nodeSet, UAModelContext modelContext, Action <TraceMessage> traceEvent)
 {
     nodeSet.Definition.GetParameters(nodeDesign.NewDefinition(), modelContext, traceEvent);
 }
Пример #13
0
 internal static void GetParameters(this DataTypeDefinition dataTypeDefinition, IDataTypeDefinitionFactory definition, UAModelContext modelContext, Action <TraceMessage> traceEvent)
 {
     if (dataTypeDefinition == null || dataTypeDefinition.Field == null || dataTypeDefinition.Field.Length == 0)
     {
         return;
     }
     foreach (DataTypeField _item in dataTypeDefinition.Field)
     {
         IDataTypeFieldFactory _nP = definition.NewField();
         _nP.DataType = modelContext.ExportBrowseName(_item.DataType, DataTypes.BaseDataType, traceEvent);
         _item.Description.ExportLocalizedTextArray(_nP.AddDescription);
         _nP.Identifier   = _item.Value;
         _nP.Name         = _item.Name;
         _nP.ValueRank    = _item.ValueRank.GetValueRank(traceEvent);
         _nP.SymbolicName = _item.SymbolicName;
         _nP.Value        = _item.Value;
         if (_item.Definition == null)
         {
             continue;
         }
         IDataTypeDefinitionFactory _new = _nP.NewDefinition();
         _item.Definition.GetParameters(_new, modelContext, traceEvent);
     }
 }
Пример #14
0
 /// <summary>
 /// Converts the <paramref name="nodeId" /> representing instance of <see cref="NodeId" /> and returns <see cref="XmlQualifiedName" />
 /// representing the BrowseName name of the <see cref="UANode" /> pointed out by it.
 /// </summary>
 /// <param name="nodeId">The node identifier.</param>
 /// <param name="defaultValue">The default value.</param>
 /// <returns>An object of <see cref="XmlQualifiedName" /> representing the BrowseName of <see cref="UANode" /> of the node indexed by <paramref name="nodeId" /></returns>
 public XmlQualifiedName ExportBrowseName(string nodeId, NodeId defaultValue)
 {
     return(UAModelContext.ExportBrowseName(nodeId, defaultValue));
 }
Пример #15
0
 //methods
 private void ImportNodeSet(UANodeSet model)
 {
     if (model.ServerUris != null)
     m_TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NotSupportedFeature, "ServerUris is omitted during the import"));
       if (model.Extensions != null)
     m_TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NotSupportedFeature, "Extensions is omitted during the import"));
       string _namespace = model.NamespaceUris == null ? m_NamespaceTable.GetString(0) : model.NamespaceUris[0];
       m_TraceEvent(TraceMessage.DiagnosticTraceMessage(String.Format("Entering AddressSpaceContext.ImportNodeSet - starting import {0}.", _namespace)));
       UAModelContext _modelContext = new UAModelContext(model.Aliases, model.NamespaceUris, this);
       m_TraceEvent(TraceMessage.DiagnosticTraceMessage("AddressSpaceContext.ImportNodeSet - context for imported model is created and starting import nodes."));
       foreach (UANode _nd in model.Items)
     this.ImportUANode(_nd, _modelContext, m_TraceEvent);
       m_TraceEvent(TraceMessage.DiagnosticTraceMessage(String.Format("Finishing AddressSpaceContext.ImportNodeSet - imported {0} nodes.", model.Items.Length)));
 }
Пример #16
0
 private void ImportUANode(UANode node, UAModelContext modelContext, Action<TraceMessage> traceEvent)
 {
     try
       {
     if (node == null)
       m_TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NodeCannotBeNull, "At Importing UANode."));
     NodeId nodeId = modelContext.ImportNodeId(node.NodeId, false, m_TraceEvent);
     UANodeContext _newNode = null;
     string nodeIdKey = nodeId.ToString();
     if (!m_NodesDictionary.TryGetValue(nodeIdKey, out _newNode))
     {
       _newNode = new UANodeContext(this, modelContext, nodeId);
       _newNode.Update(node, traceEvent);
       m_NodesDictionary.Add(nodeIdKey, _newNode);
     }
     else
     {
       if (_newNode.UANode != null)
     m_TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NodeIdDuplicated, String.Format("The {0} is already defined.", node.NodeId.ToString())));
       _newNode.Update(node, traceEvent);
     }
     foreach (Reference _rf in node.References)
     {
       UAReferenceContext _rs = UAReferenceContext.NewReferenceStub(_rf, this, modelContext, _newNode, m_TraceEvent);
       if (!m_References.ContainsKey(_rs.Key))
     m_References.Add(_rs.Key, _rs);
     }
       }
       catch (Exception _ex)
       {
     string _msg = String.Format("ImportUANode {1} is interrupted by exception {0}", _ex.Message, node.NodeId);
     m_TraceEvent(TraceMessage.DiagnosticTraceMessage(_msg));
       }
 }
Пример #17
0
 /// <summary>
 /// Exports the browse name of the wrapped node by this instance.
 /// </summary>
 /// <returns>An instance of <see cref="XmlQualifiedName" /> representing the BrowseName of the node.</returns>
 public XmlQualifiedName ExportNodeBrowseName()
 {
     return(UAModelContext.ExportQualifiedName(BrowseName));
 }