Example #1
0
        public IEnumerable <IUnitHashSetStatus> GetAllHashSetStatus()
        {
            if (_streamReader == null)
            {
                throw new InvalidOperationException($"Please invoke {nameof(BeginOpen)} before invoking this method.");
            }

            _streamReader.BaseStream.Position = 0;

            UnitHashSetStatus status = null;

            while (true)
            {
                try {
                    if (_streamReader.EndOfStream)
                    {
                        yield break;
                    }
                    if (_streamReader.BaseStream.Position == _streamReader.BaseStream.Length - 1)
                    {
                        continue;
                    }
                    status = (UnitHashSetStatus)_formatter.Deserialize(_streamReader.BaseStream);
                }
                catch (Exception ex) {
                    LoggerService.WriteException(ex);
                }

                if (status != null)
                {
                    yield return(status);
                }
                else
                {
                    yield break;
                }

                status = null;
            }
        }
Example #2
0
        public void SetUnitHashSetStatus(string unitName, string[] hashSetGUIDs, string hashSetStatusType)
        {
            if (unitName == null)
            {
                throw new ArgumentNullException(nameof(unitName));
            }
            if (hashSetGUIDs == null)
            {
                throw new ArgumentNullException(nameof(hashSetGUIDs));
            }
            if (_streamWriter == null)
            {
                throw new InvalidOperationException($"Please invoke {nameof(BeginEdit)} before invoking this method.");
            }

            var hashSetStatus = new UnitHashSetStatus(unitName)
            {
                HashSetGuids = hashSetGUIDs,
                StatusType   = hashSetStatusType
            };

            _formatter.Serialize(_streamWriter.BaseStream, hashSetStatus);
        }