示例#1
0
        private bool TryParseAddLine(string line, out long key, out GVFltCallbacks.BackgroundGitUpdate value, out string error)
        {
            // Expected: <ID>\0<Background Update>
            int idx = line.IndexOf(ValueTerminator);

            if (idx < 0)
            {
                key   = 0;
                value = default(GVFltCallbacks.BackgroundGitUpdate);
                error = "Add line missing ID terminator: " + line;
                return(false);
            }

            if (!long.TryParse(line.Substring(0, idx), out key))
            {
                value = default(GVFltCallbacks.BackgroundGitUpdate);
                error = "Could not parse ID for add line: " + line;
                return(false);
            }

            if (!this.TryDeserialize(line.Substring(idx + 1), out value))
            {
                value = default(GVFltCallbacks.BackgroundGitUpdate);
                error = "Could not parse BackgroundGitUpdate for add line: " + line;
                return(false);
            }

            error = null;
            return(true);
        }
示例#2
0
        public void DequeueAndFlush(GVFltCallbacks.BackgroundGitUpdate expectedValue)
        {
            try
            {
                KeyValuePair <long, GVFltCallbacks.BackgroundGitUpdate> kvp;
                if (this.data.TryDequeue(out kvp))
                {
                    if (!expectedValue.Equals(kvp.Value))
                    {
                        throw new InvalidOperationException(string.Format("Dequeued value is expected to be the same as input value. Expected: '{0}' Actual: '{1}'", expectedValue, kvp.Value));
                    }

                    this.WriteRemoveEntry(kvp.Key.ToString());

                    this.DeleteDataFileIfCondition(() => this.data.Count == 0);
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Dequeued value is expected to be the same as input value. Expected: '{0}' Actual: 'None. List is empty.'", expectedValue));
                }
            }
            catch (Exception e)
            {
                throw new FileBasedCollectionException(e);
            }
        }
示例#3
0
 private void AddParsedEntry(long key, GVFltCallbacks.BackgroundGitUpdate value)
 {
     this.data.Enqueue(new KeyValuePair <long, GVFltCallbacks.BackgroundGitUpdate>(key, value));
     if (this.entryCounter < key + 1)
     {
         this.entryCounter = key;
     }
 }
示例#4
0
        public virtual void Enqueue(GVFltCallbacks.BackgroundGitUpdate backgroundOperation)
        {
            this.backgroundOperations.EnqueueAndFlush(backgroundOperation);

            if (!this.isStopping)
            {
                this.wakeUpThread.Set();
            }
        }
示例#5
0
        public void EnqueueAndFlush(GVFltCallbacks.BackgroundGitUpdate value)
        {
            try
            {
                KeyValuePair <long, GVFltCallbacks.BackgroundGitUpdate> kvp = new KeyValuePair <long, GVFltCallbacks.BackgroundGitUpdate>(
                    Interlocked.Increment(ref this.entryCounter),
                    value);

                this.WriteAddEntry(
                    kvp.Key + ValueTerminator + this.Serialize(kvp.Value),
                    () => this.data.Enqueue(kvp));
            }
            catch (Exception e)
            {
                throw new FileBasedCollectionException(e);
            }
        }
示例#6
0
        public bool TryPeek(out GVFltCallbacks.BackgroundGitUpdate value)
        {
            try
            {
                KeyValuePair <long, GVFltCallbacks.BackgroundGitUpdate> kvp;
                if (this.data.TryPeek(out kvp))
                {
                    value = kvp.Value;
                    return(true);
                }

                value = default(GVFltCallbacks.BackgroundGitUpdate);
                return(false);
            }
            catch (Exception e)
            {
                throw new FileBasedCollectionException(e);
            }
        }
示例#7
0
        private bool TryDeserialize(string line, out GVFltCallbacks.BackgroundGitUpdate value)
        {
            // Expected: <Operation>\0<Virtual Path>\0<Old Virtual Path>
            string[] parts = line.Split(ValueTerminatorChar);
            if (parts.Length != 3)
            {
                value = default(GVFltCallbacks.BackgroundGitUpdate);
                return(false);
            }

            GVFltCallbacks.BackgroundGitUpdate.OperationType operationType;
            if (!Enum.TryParse(parts[0], out operationType))
            {
                value = default(GVFltCallbacks.BackgroundGitUpdate);
                return(false);
            }

            value = new GVFltCallbacks.BackgroundGitUpdate(
                operationType,
                parts[1],
                parts[2]);

            return(true);
        }
示例#8
0
 private string Serialize(GVFltCallbacks.BackgroundGitUpdate input)
 {
     return(((int)input.Operation) + ValueTerminator + input.VirtualPath + ValueTerminator + input.OldVirtualPath);
 }