Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventFieldDefinition"/> class.
        /// </summary>
        /// <param name="parentField">The parent field.</param>
        /// <param name="reference">The reference to the instance declaration node.</param>
        public EventFieldDefinition(EventFieldDefinition parentField, ReferenceDescription reference)
        {
            DeclarationNode = reference;

            Operand = new SimpleAttributeOperand();

            // setting the typedefinition id to null ignores the event type when evaluating the operand.
            Operand.TypeDefinitionId = null;

            // event filters only support the NodeId attribute for objects and the Value attribute for Variables.
            Operand.AttributeId = (reference.NodeClass == NodeClass.Variable) ? Attributes.Value : Attributes.NodeId;

            // prefix the browse path with the parent browse path.
            if (parentField != null)
            {
                Operand.BrowsePath = new QualifiedNameCollection(parentField.Operand.BrowsePath);
            }

            // add the child browse name.
            Operand.BrowsePath.Add(reference.BrowseName);

            // may select sub-sets of array values. Not used in this sample.
            Operand.IndexRange = null;

            // construct the display name.
            StringBuilder buffer = new StringBuilder();

            for (int ii = 0; ii < Operand.BrowsePath.Count; ii++)
            {
                if (buffer.Length > 0)
                {
                    buffer.Append('/');
                }

                buffer.Append(Operand.BrowsePath[ii].Name);
            }

            DisplayName = buffer.ToString();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EventFieldDefinition"/> class.
        /// </summary>
        /// <param name="parentField">The parent field.</param>
        /// <param name="reference">The reference to the instance declaration node.</param>
        public EventFieldDefinition(EventFieldDefinition parentField, ReferenceDescription reference)
        {
            DeclarationNode = reference;

            Operand = new SimpleAttributeOperand();

            // setting the typedefinition id to null ignores the event type when evaluating the operand.
            Operand.TypeDefinitionId = null;

            // event filters only support the NodeId attribute for objects and the Value attribute for Variables.
            Operand.AttributeId = (reference.NodeClass == NodeClass.Variable) ? Attributes.Value : Attributes.NodeId;

            // prefix the browse path with the parent browse path.
            if (parentField != null)
            {
                Operand.BrowsePath = new QualifiedNameCollection(parentField.Operand.BrowsePath);
            }

            // add the child browse name.
            Operand.BrowsePath.Add(reference.BrowseName);

            // may select sub-sets of array values. Not used in this sample.
            Operand.IndexRange = null;

            // construct the display name.
            StringBuilder buffer = new StringBuilder();

            for (int ii = 0; ii < Operand.BrowsePath.Count; ii++)
            {
                if (buffer.Length > 0)
                {
                    buffer.Append('/');
                }

                buffer.Append(Operand.BrowsePath[ii].Name);
            }

            DisplayName = buffer.ToString();
        }