コード例 #1
0
    private bool UpdateModified(GitObjectDb.Models.IModelObject old, GitObjectDb.Models.IModelObject @new, System.Collections.Generic.IDictionary <string, System.Collections.Generic.ISet <string> > result)
    {
        var oldKeys = new System.Collections.Generic.SortedSet <string>();
        var newKeys = new System.Collections.Generic.SortedSet <string>();

        ComputeKeys(old, oldKeys);
        ComputeKeys(@new, newKeys);
        var path = new Lazy <string>(() => GitObjectDb.Models.IModelObjectExtensions.GetFolderPath(old));

        var anyUpdate = false;

        foreach (var key in System.Linq.Enumerable.Except(oldKeys, newKeys))
        {
            if (key == null)
            {
                continue;
            }
            var set = GetIndexValues(key, result, create: false);
            anyUpdate |= set?.Remove(path.Value) ?? false;
        }
        foreach (var key in System.Linq.Enumerable.Except(newKeys, oldKeys))
        {
            var set = GetIndexValues(key, result, create: true);
            anyUpdate |= set.Add(path.Value);
        }
        return(anyUpdate);
    }
コード例 #2
0
    private bool UpdateAdded(GitObjectDb.Models.IModelObject node, System.Collections.Generic.IDictionary <string, System.Collections.Generic.ISet <string> > result)
    {
        var path = new Lazy <string>(() => GitObjectDb.Models.IModelObjectExtensions.GetFolderPath(node));
        var keys = new System.Collections.Generic.SortedSet <string>();

        ComputeKeys(node, keys);

        var anyUpdate = false;

        foreach (var key in keys)
        {
            var set = GetIndexValues(key, result, create: true);
            anyUpdate |= set.Add(path.Value);
        }
        return(anyUpdate);
    }
コード例 #3
0
    /// <inheritdoc />
    public GitObjectDb.Models.IModelObject TryGetFromGitPath(string path)
    {
        if (path == null)
        {
            throw new ArgumentNullException(nameof(path));
        }
        if (path.Length == 0)
        {
            return(this);
        }

        if (path.Equals(GitObjectDb.FileSystemStorage.DataFile, StringComparison.OrdinalIgnoreCase))
        {
            return(this);
        }

        var chunks = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

        if (chunks.Length < 2)
        {
            return(null);
        }

        GitObjectDb.Models.IModelObject result = this;
        for (int i = 0; result != null && i < chunks.Length - 1; i += 2)
        {
            var propertyInfo = System.Linq.IEnumerableExtensions.TryGetWithValue(
                result.DataAccessor.ChildProperties,
                p => p.FolderName,
                chunks[i]);
            if (propertyInfo == null)
            {
                return(null);
            }

            var children = propertyInfo.Accessor(result);
            result = GitObjectDb.Models.UniqueId.TryParse(chunks[i + 1], out var id) ?
                     System.Linq.Enumerable.FirstOrDefault(children, c => c.Id == id) :
                     null;
        }
        return(result);
    }
コード例 #4
0
 /// <summary>
 /// Computes the key sequence for a <paramref name="node"/>.
 /// </summary>
 /// <param name="node">The node to be analyzed.</param>
 /// <param name="result">The key values.</param>
 partial void ComputeKeys(GitObjectDb.Models.IModelObject node, System.Collections.Generic.ISet <string> result);