Exemplo n.º 1
0
 public static bool TryRemoveProperty(this Biota biota, PropertyBool property, out BiotaPropertiesBool entity, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterUpgradeableReadLock();
     try
     {
         entity = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);
         if (entity != null)
         {
             rwLock.EnterWriteLock();
             try
             {
                 biota.BiotaPropertiesBool.Remove(entity);
                 entity.Object = null;
                 return(true);
             }
             finally
             {
                 rwLock.ExitWriteLock();
             }
         }
         return(false);
     }
     finally
     {
         rwLock.ExitUpgradeableReadLock();
     }
 }
Exemplo n.º 2
0
        public SetBoolStat(PropertyBool stat, bool amount)

            : base(EmoteType.SetBoolStat)
        {
            Stat   = (int)stat;
            Amount = Convert.ToInt32(amount);
        }
 public GameMessageUpdatePropertyBool(WorldObject worldObject, PropertyBool property, bool value) : base(GameMessageOpcode.PublicUpdatePropertyBool, GameMessageGroup.UIQueue)
 {
     Writer.Write(worldObject.Sequences.GetNextSequence(Sequence.SequenceType.PrivateUpdatePropertyBool)); // This might need to change to GetCurrentSequence..
     Writer.Write(worldObject.Guid.Full);
     Writer.Write((uint)property);
     Writer.Write(Convert.ToUInt32(value));
 }
Exemplo n.º 4
0
        private bool TryCreatePreOrderItem(PropertyBool propertyBool, WeenieClassName weenieClassName)
        {
            var rcvdBlackmoorsFavor = GetProperty(propertyBool) ?? false;

            if (!rcvdBlackmoorsFavor)
            {
                if (GetInventoryItemsOfWCID((uint)weenieClassName).Count == 0)
                {
                    var cachedWeenie = Database.DatabaseManager.World.GetCachedWeenie((uint)weenieClassName);
                    if (cachedWeenie == null)
                    {
                        return(false);
                    }

                    var wo = Factories.WorldObjectFactory.CreateNewWorldObject(cachedWeenie);
                    if (wo == null)
                    {
                        return(false);
                    }

                    if (TryAddToInventory(wo))
                    {
                        SetProperty(propertyBool, true);
                        return(true);
                    }
                }
                else
                {
                    SetProperty(propertyBool, true); // already had the item, set the property to reflect item was received
                }
            }

            return(false);
        }
Exemplo n.º 5
0
 public void RemoveProperty(PropertyBool property)
 {
     if (Biota.TryRemoveProperty(property, BiotaDatabaseLock, biotaPropertyBools))
     {
         ChangesDetected = true;
     }
 }
 public GameMessagePublicUpdatePropertyBool(SequenceManager sequences, PropertyBool property, bool value)
     : base(GameMessageOpcode.PublicUpdatePropertyBool, GameMessageGroup.UIQueue)
 {
     Writer.Write(sequences.GetNextSequence(SequenceType.PublicUpdatePropertyBool));
     Writer.Write((uint)property);
     Writer.Write(value);
 }
Exemplo n.º 7
0
 public static void SetProperty(this Biota biota, PropertyBool property, bool value, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterUpgradeableReadLock();
     try
     {
         var result = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);
         if (result != null)
         {
             result.Value = value;
         }
         else
         {
             rwLock.EnterWriteLock();
             try
             {
                 var entity = new BiotaPropertiesBool {
                     ObjectId = biota.Id, Type = (ushort)property, Value = value, Object = biota
                 };
                 biota.BiotaPropertiesBool.Add(entity);
             }
             finally
             {
                 rwLock.ExitWriteLock();
             }
         }
     }
     finally
     {
         rwLock.ExitUpgradeableReadLock();
     }
 }
Exemplo n.º 8
0
        public InqBoolStat(PropertyBool stat)

            : base(EmoteType.InqBoolStat)
        {
            Init();

            Stat = (int)stat;
        }
Exemplo n.º 9
0
 public void SetProperty(PropertyBool property, bool value)
 {
     Biota.SetProperty(property, value, BiotaDatabaseLock, biotaPropertyBools, out var biotaChanged);
     if (biotaChanged)
     {
         ChangesDetected = true;
     }
 }
 /// <summary>
 /// Public Update of PropertyBool
 /// </summary>
 /// <param name="worldObject"></param>
 /// <param name="property"></param>
 /// <param name="value"></param>
 public GameMessagePublicUpdatePropertyBool(WorldObject worldObject, PropertyBool property, bool value)
     : base(GameMessageOpcode.PublicUpdatePropertyBool, GameMessageGroup.UIQueue)
 {
     Writer.Write(worldObject.Sequences.GetNextSequence(SequenceType.UpdatePropertyBool, property));
     Writer.WriteGuid(worldObject.Guid);
     Writer.Write((uint)property);
     Writer.Write(Convert.ToUInt32(value));
 }
Exemplo n.º 11
0
        public static void RemoveProperty(this Biota biota, PropertyBool property)
        {
            var result = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);

            if (result != null)
            {
                biota.BiotaPropertiesBool.Remove(result);
                DatabaseManager.Shard.RemoveEntity(result, null);
            }
        }
Exemplo n.º 12
0
 public static bool TryRemoveProperty(this Biota biota, PropertyBool property, out BiotaPropertiesBool entity)
 {
     entity = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);
     if (entity != null)
     {
         biota.BiotaPropertiesBool.Remove(entity);
         entity.Object = null;
         return(true);
     }
     return(false);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Utility function which updates the value of a PropertyBool. (Not intended for external use)
        /// </summary>
        /// <remarks>If the property value has changed and the properties are not locked (PropertiesLock()
        /// called more recently than PropertiesUnlock()), publication of an update is scheduled</remarks>
        /// <param name="aProperty">Property to be updated</param>
        /// <param name="aValue">New value for the property</param>
        /// <returns>true if the property's value has changed (aValue was different to the previous value)</returns>
        protected bool SetPropertyBool(PropertyBool aProperty, bool aValue)
        {
            uint changed;
            uint val = (aValue ? 1u : 0u);
            int  err = DvProviderSetPropertyBool(iHandle, aProperty.Handle(), val, out changed);

            if (err != 0)
            {
                throw new PropertyUpdateError();
            }
            return(changed != 0);
        }
Exemplo n.º 14
0
 public static bool?GetProperty(this Biota biota, PropertyBool property, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterReadLock();
     try
     {
         return(biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property)?.Value);
     }
     finally
     {
         rwLock.ExitReadLock();
     }
 }
Exemplo n.º 15
0
        // =====================================
        // Set
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static void SetProperty(this Biota biota, PropertyBool property, bool value)
        {
            var result = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);

            if (result != null)
                result.Value = value;
            else
            {
                var entity = new BiotaPropertiesBool { ObjectId = biota.Id, Type = (ushort)property, Value = value, Object = biota };

                biota.BiotaPropertiesBool.Add(entity);
            }
        }
        // =====================================
        // Get
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static bool?GetProperty(this Weenie weenie, PropertyBool property)
        {
            if (weenie.PropertiesBool == null)
            {
                return(null);
            }

            if (weenie.PropertiesBool.TryGetValue(property, out var value))
            {
                return(value);
            }

            return(null);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>Use CpProxy::[Un]Subscribe() to enable/disable querying of state variable and reporting of their changes.</remarks>
        /// <param name="aDevice">The device to use</param>
        public CpProxyLinnCoUkCloud1(ICpDevice aDevice)
            : base("linn-co-uk", "Cloud", 1, aDevice)
        {
            OpenHome.Net.Core.Parameter param;
            List <String> allowedValues = new List <String>();

            iActionGetChallengeResponse = new OpenHome.Net.Core.Action("GetChallengeResponse");
            param = new ParameterString("Challenge", allowedValues);
            iActionGetChallengeResponse.AddInputParameter(param);
            param = new ParameterString("Response", allowedValues);
            iActionGetChallengeResponse.AddOutputParameter(param);

            iActionSetAssociated = new OpenHome.Net.Core.Action("SetAssociated");
            param = new ParameterBinary("AesKeyRsaEncrypted");
            iActionSetAssociated.AddInputParameter(param);
            param = new ParameterBinary("InitVectorRsaEncrypted");
            iActionSetAssociated.AddInputParameter(param);
            param = new ParameterBinary("TokenAesEncrypted");
            iActionSetAssociated.AddInputParameter(param);
            param = new ParameterBool("Associated");
            iActionSetAssociated.AddInputParameter(param);

            iActionSetControlEnabled = new OpenHome.Net.Core.Action("SetControlEnabled");
            param = new ParameterBool("Enabled");
            iActionSetControlEnabled.AddInputParameter(param);

            iActionGetControlEnabled = new OpenHome.Net.Core.Action("GetControlEnabled");
            param = new ParameterBool("Enabled");
            iActionGetControlEnabled.AddOutputParameter(param);

            iActionGetConnected = new OpenHome.Net.Core.Action("GetConnected");
            param = new ParameterBool("Connected");
            iActionGetConnected.AddOutputParameter(param);

            iActionGetPublicKey = new OpenHome.Net.Core.Action("GetPublicKey");
            param = new ParameterString("PublicKey", allowedValues);
            iActionGetPublicKey.AddOutputParameter(param);

            iAssociationStatus = new PropertyString("AssociationStatus", AssociationStatusPropertyChanged);
            AddProperty(iAssociationStatus);
            iControlEnabled = new PropertyBool("ControlEnabled", ControlEnabledPropertyChanged);
            AddProperty(iControlEnabled);
            iConnected = new PropertyBool("Connected", ConnectedPropertyChanged);
            AddProperty(iConnected);
            iPublicKey = new PropertyString("PublicKey", PublicKeyPropertyChanged);
            AddProperty(iPublicKey);

            iPropertyLock = new Mutex();
        }
Exemplo n.º 18
0
        public static void SetProperty(this Biota biota, PropertyBool property, bool value)
        {
            var result = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);

            if (result != null)
            {
                result.Value = value;
            }
            else
            {
                biota.BiotaPropertiesBool.Add(new BiotaPropertiesBool {
                    Type = (ushort)property, Value = value
                });
            }
        }
Exemplo n.º 19
0
 public bool?GetProperty(PropertyBool property)
 {
     BiotaDatabaseLock.EnterReadLock();
     try
     {
         if (biotaPropertyBools.TryGetValue(property, out var record))
         {
             return(record.Value);
         }
         return(null);
     }
     finally
     {
         BiotaDatabaseLock.ExitReadLock();
     }
 }
Exemplo n.º 20
0
        // =====================================
        // Set
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static void SetProperty(this Biota biota, PropertyBool property, bool value, ReaderWriterLockSlim rwLock)
        {
            rwLock.EnterWriteLock();
            try
            {
                if (biota.PropertiesBool == null)
                {
                    biota.PropertiesBool = new Dictionary <PropertyBool, bool>();
                }

                biota.PropertiesBool[property] = value;
            }
            finally
            {
                rwLock.ExitWriteLock();
            }
        }
        // =====================================
        // Remove
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static bool TryRemoveProperty(this Biota biota, PropertyBool property, ReaderWriterLockSlim rwLock)
        {
            if (biota.PropertiesBool == null)
            {
                return(false);
            }

            rwLock.EnterWriteLock();
            try
            {
                return(biota.PropertiesBool.Remove(property));
            }
            finally
            {
                rwLock.ExitWriteLock();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>Use CpProxy::[Un]Subscribe() to enable/disable querying of state variable and reporting of their changes.</remarks>
        /// <param name="aDevice">The device to use</param>
        public CpProxyAvOpenhomeOrgSender1(CpDevice aDevice)
            : base("av-openhome-org", "Sender", 1, aDevice)
        {
            OpenHome.Net.Core.Parameter param;
            List <String> allowedValues = new List <String>();

            iActionPresentationUrl = new OpenHome.Net.Core.Action("PresentationUrl");
            param = new ParameterString("Value", allowedValues);
            iActionPresentationUrl.AddOutputParameter(param);

            iActionMetadata = new OpenHome.Net.Core.Action("Metadata");
            param           = new ParameterString("Value", allowedValues);
            iActionMetadata.AddOutputParameter(param);

            iActionAudio = new OpenHome.Net.Core.Action("Audio");
            param        = new ParameterBool("Value");
            iActionAudio.AddOutputParameter(param);

            iActionStatus = new OpenHome.Net.Core.Action("Status");
            allowedValues.Add("Enabled");
            allowedValues.Add("Disabled");
            allowedValues.Add("Blocked");
            param = new ParameterString("Value", allowedValues);
            iActionStatus.AddOutputParameter(param);
            allowedValues.Clear();

            iActionAttributes = new OpenHome.Net.Core.Action("Attributes");
            param             = new ParameterString("Value", allowedValues);
            iActionAttributes.AddOutputParameter(param);

            iPresentationUrl = new PropertyString("PresentationUrl", PresentationUrlPropertyChanged);
            AddProperty(iPresentationUrl);
            iMetadata = new PropertyString("Metadata", MetadataPropertyChanged);
            AddProperty(iMetadata);
            iAudio = new PropertyBool("Audio", AudioPropertyChanged);
            AddProperty(iAudio);
            iStatus = new PropertyString("Status", StatusPropertyChanged);
            AddProperty(iStatus);
            iAttributes = new PropertyString("Attributes", AttributesPropertyChanged);
            AddProperty(iAttributes);

            iPropertyLock = new Mutex();
        }
        // =====================================
        // Set
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static void SetProperty(this Biota biota, PropertyBool property, bool value, ReaderWriterLockSlim rwLock, out bool changed)
        {
            rwLock.EnterWriteLock();
            try
            {
                if (biota.PropertiesBool == null)
                {
                    biota.PropertiesBool = new Dictionary <PropertyBool, bool>();
                }

                changed = (!biota.PropertiesBool.TryGetValue(property, out var existing) || value != existing);

                if (changed)
                {
                    biota.PropertiesBool[property] = value;
                }
            }
            finally
            {
                rwLock.ExitWriteLock();
            }
        }
        // =====================================
        // Get
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static bool?GetProperty(this Biota biota, PropertyBool property, ReaderWriterLockSlim rwLock)
        {
            if (biota.PropertiesBool == null)
            {
                return(null);
            }

            rwLock.EnterReadLock();
            try
            {
                if (biota.PropertiesBool.TryGetValue(property, out var value))
                {
                    return(value);
                }

                return(null);
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>Use CpProxy::[Un]Subscribe() to enable/disable querying of state variable and reporting of their changes.</remarks>
        /// <param name="aDevice">The device to use</param>
        public CpProxyUpnpOrgSwitchPower1(ICpDevice aDevice)
            : base("schemas-upnp-org", "SwitchPower", 1, aDevice)
        {
            OpenHome.Net.Core.Parameter param;


            iActionSetTarget = new OpenHome.Net.Core.Action("SetTarget");
            param            = new ParameterBool("newTargetValue");
            iActionSetTarget.AddInputParameter(param);

            iActionGetTarget = new OpenHome.Net.Core.Action("GetTarget");
            param            = new ParameterBool("RetTargetValue");
            iActionGetTarget.AddOutputParameter(param);

            iActionGetStatus = new OpenHome.Net.Core.Action("GetStatus");
            param            = new ParameterBool("ResultStatus");
            iActionGetStatus.AddOutputParameter(param);

            iStatus = new PropertyBool("Status", StatusPropertyChanged);
            AddProperty(iStatus);

            iPropertyLock = new Mutex();
        }
Exemplo n.º 26
0
 public static bool?GetProperty(this Weenie weenie, PropertyBool property)
 {
     return(weenie.WeeniePropertiesBool.FirstOrDefault(x => x.Type == (uint)property)?.Value);
 }
Exemplo n.º 27
0
        public static string GetDescription(this PropertyBool prop)
        {
            var description = prop.GetAttributeOfType <DescriptionAttribute>();

            return(description?.Description ?? prop.ToString());
        }
Exemplo n.º 28
0
 public byte[] GetNextSequence(SequenceType type, PropertyBool property)
 {
     return(GetSequence(type, (uint)property).NextBytes);
 }
Exemplo n.º 29
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>Use CpProxy::[Un]Subscribe() to enable/disable querying of state variable and reporting of their changes.</remarks>
        /// <param name="aDevice">The device to use</param>
        public CpProxyAvOpenhomeOrgInfo1(CpDevice aDevice)
            : base("av-openhome-org", "Info", 1, aDevice)
        {
            OpenHome.Net.Core.Parameter param;
            List <String> allowedValues = new List <String>();

            iActionCounters = new OpenHome.Net.Core.Action("Counters");
            param           = new ParameterUint("TrackCount");
            iActionCounters.AddOutputParameter(param);
            param = new ParameterUint("DetailsCount");
            iActionCounters.AddOutputParameter(param);
            param = new ParameterUint("MetatextCount");
            iActionCounters.AddOutputParameter(param);

            iActionTrack = new OpenHome.Net.Core.Action("Track");
            param        = new ParameterString("Uri", allowedValues);
            iActionTrack.AddOutputParameter(param);
            param = new ParameterString("Metadata", allowedValues);
            iActionTrack.AddOutputParameter(param);

            iActionDetails = new OpenHome.Net.Core.Action("Details");
            param          = new ParameterUint("Duration");
            iActionDetails.AddOutputParameter(param);
            param = new ParameterUint("BitRate");
            iActionDetails.AddOutputParameter(param);
            param = new ParameterUint("BitDepth");
            iActionDetails.AddOutputParameter(param);
            param = new ParameterUint("SampleRate");
            iActionDetails.AddOutputParameter(param);
            param = new ParameterBool("Lossless");
            iActionDetails.AddOutputParameter(param);
            param = new ParameterString("CodecName", allowedValues);
            iActionDetails.AddOutputParameter(param);

            iActionMetatext = new OpenHome.Net.Core.Action("Metatext");
            param           = new ParameterString("Value", allowedValues);
            iActionMetatext.AddOutputParameter(param);

            iTrackCount = new PropertyUint("TrackCount", TrackCountPropertyChanged);
            AddProperty(iTrackCount);
            iDetailsCount = new PropertyUint("DetailsCount", DetailsCountPropertyChanged);
            AddProperty(iDetailsCount);
            iMetatextCount = new PropertyUint("MetatextCount", MetatextCountPropertyChanged);
            AddProperty(iMetatextCount);
            iUri = new PropertyString("Uri", UriPropertyChanged);
            AddProperty(iUri);
            iMetadata = new PropertyString("Metadata", MetadataPropertyChanged);
            AddProperty(iMetadata);
            iDuration = new PropertyUint("Duration", DurationPropertyChanged);
            AddProperty(iDuration);
            iBitRate = new PropertyUint("BitRate", BitRatePropertyChanged);
            AddProperty(iBitRate);
            iBitDepth = new PropertyUint("BitDepth", BitDepthPropertyChanged);
            AddProperty(iBitDepth);
            iSampleRate = new PropertyUint("SampleRate", SampleRatePropertyChanged);
            AddProperty(iSampleRate);
            iLossless = new PropertyBool("Lossless", LosslessPropertyChanged);
            AddProperty(iLossless);
            iCodecName = new PropertyString("CodecName", CodecNamePropertyChanged);
            AddProperty(iCodecName);
            iMetatext = new PropertyString("Metatext", MetatextPropertyChanged);
            AddProperty(iMetatext);

            iPropertyLock = new Mutex();
        }
Exemplo n.º 30
0
 public void SetPropertyBool(PropertyBool property, bool value)
 {
     Debug.Assert(property < PropertyBool.Count, "Invalid Property.");
     propertiesBool[property] = value;
 }