Beispiel #1
0
        /// <summary>
        /// Make a copy of the feature with a different unique ID.
        /// <para>
        /// This will not duplicate StatusControls or StatusGraphics associated with the device.
        /// </para>
        /// </summary>
        /// <param name="featureRef">The new unique ID for the copy</param>
        /// <returns>A copy of the feature with a new reference ID</returns>
        public HsFeature Duplicate(int featureRef)
        {
            var dev = new HsFeature(featureRef)
            {
                _address       = Address,
                _assDevices    = AssociatedDevices,
                _typeInfo      = TypeInfo,
                _image         = Image,
                _interface     = Interface,
                _lastChange    = LastChange,
                _location      = Location,
                _location2     = Location2,
                _misc          = Misc,
                _name          = Name,
                _plugExtraData = PlugExtraData,
                _relationship  = Relationship,
                _status        = Status,
                _userAccess    = UserAccess,
                _userNote      = UserNote,
                _value         = Value,
                _voiceCommand  = VoiceCommand
            };

            return(dev);
        }
Beispiel #2
0
        internal NewFeatureData(HsFeature feature)
        {
            if (feature == null)
            {
                throw new ArgumentNullException(nameof(feature));
            }

            Feature = feature.Changes;

            if (!(Feature[EProperty.AssociatedDevices] is HashSet <int> assDevices) ||
                assDevices.Count == 0 || assDevices.Count >= 2 || assDevices.First() <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(feature),
                                                      "Invalid associated device ref");
            }

            Feature[EProperty.Relationship] = ERelationship.Feature;
        }
Beispiel #3
0
        internal NewFeatureData(int deviceRef, HsFeature feature)
        {
            if (feature == null)
            {
                throw new ArgumentNullException(nameof(feature));
            }

            if (deviceRef <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(deviceRef));
            }

            Feature = feature.Changes;
            Feature[EProperty.Relationship]      = ERelationship.Feature;
            Feature[EProperty.AssociatedDevices] = new HashSet <int>()
            {
                deviceRef
            };
        }
Beispiel #4
0
        public static FeatureFactory CreateFeature(string pluginId)
        {
            var ff      = new FeatureFactory();
            var feature = new HsFeature
            {
                Relationship = ERelationship.Feature,
                Interface    = pluginId
            };

            feature.Changes.Add(EProperty.Misc,
                                AbstractHsDevice.GetMiscForFlags(
                                    EMiscFlag.ShowValues,
                                    EMiscFlag.SetDoesNotChangeLastChange)
                                );
            feature.Changes.Add(EProperty.UserAccess, "Any");
            feature.Changes.Add(EProperty.Location2, "Plugin");
            feature.Changes.Add(EProperty.Location, pluginId);
            ff._feature = feature;

            return(ff);
        }