Exemplo n.º 1
0
 private Group CreateGroupHierarchy(
     Bam.Core.TokenizedString path)
 {
     Group group = null;
     lock (this.Project)
     {
         var found = this.Project.GroupMap.Where(item => item.Key == path.Parse()).FirstOrDefault();
         if (!found.Equals(default(System.Collections.Generic.KeyValuePair<string, Group>)))
         {
             return found.Value;
         }
         var basename = this.Module.CreateTokenizedString("@basename($(0))", path).Parse();
         group = new Group(basename);
         this.Project.Groups.Add(group);
         this.Project.GroupMap.Add(path.Parse(), group);
         if (path.Parse().Contains(System.IO.Path.DirectorySeparatorChar))
         {
             var parent = this.Module.CreateTokenizedString("@dir($(0))", path);
             var parentGroup = this.CreateGroupHierarchy(parent);
             parentGroup.AddChild(group);
         }
     }
     return group;
 }
Exemplo n.º 2
0
        public void Requires(
            Target other)
        {
            lock (this)
            {
                var existingTargetDep = this.TargetDependencies.Where(item => item.Dependency == other).FirstOrDefault();
                if (null != existingTargetDep)
                {
                    return;
                }
                if (this.Project == other.Project)
                {
                    var itemProxy = this.Project.ContainerItemProxies.Where(item => (item.ContainerPortal == this.Project) && (item.Remote == other)).FirstOrDefault();
                    if (null == itemProxy)
                    {
                        itemProxy = new ContainerItemProxy(this.Project, this.Project, other, false);
                    }

                    var dependency = this.TargetDependencies.Where(item => (item.Dependency == other) && (item.Proxy == itemProxy)).FirstOrDefault();
                    if (null == dependency)
                    {
                        dependency = new TargetDependency(this.Project, other, itemProxy);
                        this.TargetDependencies.AddUnique(dependency);
                    }
                }
                else
                {
                    var fileRef = this.Project.EnsureFileReferenceExists(
                        other.Project.ProjectDir,
                        FileReference.EFileType.Project,
                        explicitType: false,
                        sourceTree: FileReference.ESourceTree.Absolute);
                    this.Project.MainGroup.AddChild(fileRef);

                    var itemProxy = this.Project.ContainerItemProxies.Where(item => (item.ContainerPortal == fileRef) && (item.Remote == other)).FirstOrDefault();
                    if (null == itemProxy)
                    {
                        itemProxy = new ContainerItemProxy(this.Project, fileRef, other, false);
                    }

                    var refProxy = this.Project.ReferenceProxies.Where(item => item.RemoteRef == itemProxy).FirstOrDefault();
                    if (null == refProxy)
                    {
                        refProxy = new ReferenceProxy(
                            this.Project,
                            other.FileReference.Type,
                            other.FileReference.Path,
                            itemProxy,
                            other.FileReference.SourceTree);
                    }

                    var productRefGroup = this.Project.Groups.Where(item => item.Children.Contains(refProxy)).FirstOrDefault();
                    if (null == productRefGroup)
                    {
                        productRefGroup = new Group("Products");
                        productRefGroup.AddChild(refProxy);
                        this.Project.Groups.Add(productRefGroup);
                    }

                    var productRef = this.Project.ProjectReferences.Where(item => item.Key == productRefGroup).FirstOrDefault();
                    if (productRef.Equals(default(System.Collections.Generic.Dictionary<Group, FileReference>)))
                    {
                        this.Project.ProjectReferences.Add(productRefGroup, fileRef);
                    }

                    var dependency = this.TargetDependencies.Where(item => (item.Dependency == null) && (item.Proxy == itemProxy)).FirstOrDefault();
                    if (null == dependency)
                    {
                        dependency = new TargetDependency(this.Project, null, itemProxy);
                        this.TargetDependencies.AddUnique(dependency);
                    }
                }
            }
        }