Opc.Ua.Com.Client.ComDaClient.FindProperty C# (CSharp) Method

FindProperty() public method

Finds the property metadata for the specified item id.
public FindProperty ( string itemId, int propertyId ) : DaProperty
itemId string The item id.
propertyId int The property id.
return DaProperty
        public DaProperty FindProperty(string itemId, int propertyId)
        {
            if (String.IsNullOrEmpty(itemId))
            {
                return null;
            }

            // check the cache.
            DaElement element = null;

            lock (m_cache)
            {
                if (m_cache.TryGetValue(itemId, out element))
                {
                    if (element.Properties != null)
                    {
                        for (int ii = 0; ii < element.Properties.Length; ii++)
                        {
                            if (element.Properties[ii].PropertyId == propertyId)
                            {
                                return element.Properties[ii];
                            }
                        }
                    }
                }
            }

            // check if the element has to be loaded.
            if (element == null)
            {
                element = FindElement(itemId);

                if (element == null)
                {
                    return null;
                }
            }
            
            // update the property list.
            element.Properties = ReadAvailableProperties(itemId, false);

            if (element.Properties != null)
            {
                for (int ii = 0; ii < element.Properties.Length; ii++)
                {
                    if (element.Properties[ii].PropertyId == propertyId)
                    {
                        return element.Properties[ii];
                    }
                }
            }

            // not found.
            return null;
        }