/// <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); }
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; }
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 }; }
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); }