Example #1
0
        FeatureAccountContainer GetFeatureContainer(ushort featureId, bool add)
        {
            lock (this)
            {
                if (_accountFeatures.TryGetValue(featureId, out var accountContainer))
                {
                    return(accountContainer);
                }

                if (add)
                {
                    accountContainer = Feature.GetFeature(featureId)?.NewAccountContainer(this);
                    if (accountContainer != null)
                    {
                        _accountFeatures[featureId] = accountContainer;
                    }
                }

                return(accountContainer);
            }
        }
Example #2
0
        static void UnpackFeatures(Unpacker unpacker, SortedList <ushort, FeatureData> featureData, HashSet <ushort> unknownFeatures, FeatureOptions unpackOptions)
        {
            var count = unpacker.UnpackUshort();

            for (var i = 0; i < count; i++)
            {
                var featureId = unpacker.UnpackUshort();
                var size      = unpacker.UnpackUshort();

                var feature = Feature.GetFeature(featureId);
                if (feature != null)
                {
                    if (!featureData.TryGetValue(featureId, out var data))
                    {
                        data = feature.NewFeatureData();
                        featureData[featureId] = data;
                    }

                    var noData = ((feature.Options & FeatureOptions.HasTransactionData) == 0) && ((feature.Options & FeatureOptions.HasMetaData) == 0);
                    if (noData)
                    {
                        continue;
                    }

                    if ((unpackOptions & FeatureOptions.HasTransactionData) != 0)
                    {
                        data.UnpackTransactionData(unpacker, size);
                    }
                    if ((unpackOptions & FeatureOptions.HasMetaData) != 0)
                    {
                        data.UnpackMetaData(unpacker, size);
                    }
                }
                else
                {
                    unknownFeatures.Add(featureId);
                    unpacker.Position += size;
                }
            }
        }
Example #3
0
        public FeatureAccount(Unpacker unpacker)
        {
            unpacker.Unpack(out AccountId);

            var featureCount = unpacker.UnpackUshort();

            for (var i = 0; i < featureCount; i++)
            {
                var featureId = unpacker.UnpackUshort();
                var size      = unpacker.UnpackUshort();

                var feature = Feature.GetFeature(featureId);
                if (feature != null)
                {
                    var accountFeature = feature.RestoreAccountContainer(unpacker, size, this);
                    _accountFeatures[featureId] = accountFeature;
                }
                else
                {
                    var data = unpacker.UnpackByteArray(size);
                    _unkownAccountFeatures[featureId] = data;
                }
            }
        }