Exemple #1
0
        public ResultCode UpdateLatest <T>(DatabaseSessionMetadata metadata, IStoredData <T> oldMiiData, SourceFlag flag, IStoredData <T> newMiiData) where T : unmanaged
        {
            if (!flag.HasFlag(SourceFlag.Database))
            {
                return(ResultCode.NotFound);
            }

            if (metadata.IsInterfaceVersionSupported(1) && !oldMiiData.IsValid())
            {
                return(oldMiiData.InvalidData);
            }

            ResultCode result = _miiDatabase.FindIndex(metadata, out int index, oldMiiData.CreateId);

            if (result == ResultCode.Success)
            {
                _miiDatabase.Get(metadata, index, out StoreData storeData);

                if (storeData.Type != oldMiiData.Type)
                {
                    return(ResultCode.NotFound);
                }

                newMiiData.SetFromStoreData(storeData);

                if (oldMiiData == newMiiData)
                {
                    return(ResultCode.NotUpdated);
                }
            }

            return(result);
        }
Exemple #2
0
        public uint GetCount(DatabaseSessionMetadata metadata, SourceFlag flag)
        {
            int count = 0;

            if (flag.HasFlag(SourceFlag.Default))
            {
                count += DefaultMii.TableLength;
            }

            if (flag.HasFlag(SourceFlag.Database))
            {
                count += _miiDatabase.GetCount(metadata);
            }

            return((uint)count);
        }
Exemple #3
0
        public ResultCode Get <T>(DatabaseSessionMetadata metadata, SourceFlag flag, out int count, Span <T> elements) where T : struct, IElement
        {
            count = 0;

            if (!flag.HasFlag(SourceFlag.Database))
            {
                return(GetDefault(flag, ref count, elements));
            }

            int databaseCount = _miiDatabase.GetCount(metadata);

            for (int i = 0; i < databaseCount; i++)
            {
                if (count >= elements.Length)
                {
                    return(ResultCode.BufferTooSmall);
                }

                _miiDatabase.Get(metadata, i, out StoreData storeData);

                elements[count] = default;
                elements[count].SetFromStoreData(storeData);
                elements[count].SetSource(Source.Database);

                count++;
            }

            return(GetDefault(flag, ref count, elements));
        }
Exemple #4
0
        public bool IsUpdated(DatabaseSessionMetadata metadata, SourceFlag flag)
        {
            if (flag.HasFlag(SourceFlag.Database))
            {
                return(_miiDatabase.IsUpdated(metadata));
            }

            return(false);
        }
Exemple #5
0
        private ResultCode GetDefault <T>(SourceFlag flag, ref int count, Span <T> elements) where T : struct, IElement
        {
            if (!flag.HasFlag(SourceFlag.Default))
            {
                return(ResultCode.Success);
            }

            for (uint i = 0; i < DefaultMii.TableLength; i++)
            {
                if (count >= elements.Length)
                {
                    return(ResultCode.BufferTooSmall);
                }

                elements[count] = default;
                elements[count].SetFromStoreData(StoreData.BuildDefault(_utilityImpl, i));
                elements[count].SetSource(Source.Default);

                count++;
            }

            return(ResultCode.Success);
        }