Example #1
0
        /// <summary>
        /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data. </param><param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization. </param><exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
        public new void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            switch (Type)
            {
            case ConnectorTypes.USB:
            {
                UsbConnectorParameters usbConnectorParameters = _parameter as UsbConnectorParameters;
                if (usbConnectorParameters != null)
                {
                    usbConnectorParameters.GetObjectData(info, context);
                    info.AddValue("Type", ConnectorTypes.USB.ToString());
                }
                break;
            }

            case ConnectorTypes.KnxIpRouting:
            {
                var knxIpRoutingConnectorParameters = _parameter as KnxIpSecureRoutingConnectorParameters;
                if (knxIpRoutingConnectorParameters != null)
                {
                    knxIpRoutingConnectorParameters.GetObjectData(info, context);
                    info.AddValue("Type", ConnectorTypes.KnxIpRouting.ToString());
                }
                break;
            }

            case ConnectorTypes.KnxIpTunneling:
            {
                KnxIpTunnelingConnectorParameters knxIpTunnelingConnectorParameters = _parameter as KnxIpTunnelingConnectorParameters;
                if (knxIpTunnelingConnectorParameters != null)
                {
                    knxIpTunnelingConnectorParameters.GetObjectData(info, context);
                    info.AddValue("Type", ConnectorTypes.KnxIpTunneling.ToString());
                }
                break;
            }
            }
            info.AddValue("DisplayName", _displayName);
            info.AddValue("MacAddress", _macAddress);
            info.AddValue("isInProgMode", _isInProgMode);
        }
Example #2
0
        /// <summary>
        /// Dependent on the discovery result the needed parameters can be collected.
        /// In this case KnxIpTunnelingConnectorParameters are needed.
        /// </summary>
        public static ObservableCollection <DemoParameter> GetTunnelingParameters(DiscoveryResult[] discoveryResult)
        {
            if (discoveryResult != null)
            {
                ObservableCollection <DemoParameter> tunnelingConnectorParameters =
                    new ObservableCollection <DemoParameter>();
                foreach (DiscoveryResult result in discoveryResult)
                {
                    if (result.SupportedServiceFamilies.Any(fam => fam.ServiceFamily == ServiceFamilies.Tunneling))
                    {
                        KnxIpTunnelingConnectorParameters parameter =
                            new KnxIpTunnelingConnectorParameters(result.IpAddress.ToString(),
                                                                  result.IpPort, false);

                        parameter.Name = result.IsInProgMode ? string.Format("(P) {0}", result.FriendlyName) : result.FriendlyName;
                        tunnelingConnectorParameters.Add(new DemoParameter(parameter, result.FriendlyName, result.MacAddress.ToString(), result.IsInProgMode));
                    }
                }
                return(tunnelingConnectorParameters);
            }
            return(null);
        }