Exemplo n.º 1
0
 /// <summary>
 /// Creates a new <see cref="CpStateVariable"/> instance.
 /// </summary>
 /// <param name="connection">Device connection instance which attends the connection with the server side.</param>
 /// <param name="parentService">Instance of the service which contains the new state variable.</param>
 /// <param name="name">Name of the state variable.</param>
 /// <param name="dataType">Data type of the state variable.</param>
 public CpStateVariable(DeviceConnection connection, CpService parentService, string name, CpDataType dataType)
 {
     _connection    = connection;
     _parentService = parentService;
     _name          = name;
     _dataType      = dataType;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new <see cref="CpStateVariable"/> instance.
 /// </summary>
 /// <param name="connection">Device connection instance which attends the connection with the server side.</param>
 /// <param name="parentService">Instance of the service which contains the new state variable.</param>
 /// <param name="name">Name of the state variable.</param>
 /// <param name="dataType">Data type of the state variable.</param>
 public CpStateVariable(DeviceConnection connection, CpService parentService, string name, CpDataType dataType)
 {
   _connection = connection;
   _parentService = parentService;
   _name = name;
   _dataType = dataType;
 }
Exemplo n.º 3
0
        internal static CpStateVariable ConnectStateVariable(DeviceConnection connection, CpService parentService,
                                                             XPathNavigator svIt, IXmlNamespaceResolver nsmgr, DataTypeResolverDlgt dataTypeResolver)
        {
            string            name = ParserHelper.SelectText(svIt, "s:name/text()", nsmgr);
            XPathNodeIterator dtIt = svIt.Select("s:dataType", nsmgr);

            if (!dtIt.MoveNext())
            {
                throw new ArgumentException("Error evaluating data type element");
            }
            CpDataType        dataType = CpDataType.CreateDataType(dtIt.Current, nsmgr, dataTypeResolver);
            CpStateVariable   result   = new CpStateVariable(connection, parentService, name, dataType);
            XPathNodeIterator dvIt     = svIt.Select("s:defaultValue", nsmgr);

            if (dvIt.MoveNext())
            {
                XmlReader reader = dvIt.Current.ReadSubtree();
                reader.MoveToContent();
                result.DefaultValue = dataType.SoapDeserializeValue(reader, true); // Default value is always simple value (see DevArch)
            }
            XPathNodeIterator avlIt = svIt.Select("s:allowedValueList/s:allowedValue", nsmgr);

            if (avlIt.Count > 0)
            {
                IList <string> allowedValueList = new List <string>();
                while (avlIt.MoveNext())
                {
                    allowedValueList.Add(ParserHelper.SelectText(avlIt.Current, "text()", null));
                }
                result.AllowedValueList = allowedValueList;
            }
            XPathNodeIterator avrIt = svIt.Select("s:allowedValueRange", nsmgr);

            if (avrIt.MoveNext())
            {
                result.AllowedValueRange = CpAllowedValueRange.CreateAllowedValueRange(avrIt.Current, nsmgr);
            }
            return(result);
        }