Ejemplo n.º 1
0
        /// <summary>
        /// Updates or creates new IProjectItemTree node
        /// </summary>
        private IProjectTree CreateOrUpdateProjectItemTreeNode(
            IProjectTree node,
            IDependencyViewModel viewModel,
            IRule rule,
            ProjectTreeFlags?additionalFlags = null,
            ProjectTreeFlags?excludedFlags   = null)
        {
            if (node == null)
            {
                var flags = FilterFlags(viewModel.Flags, additionalFlags, excludedFlags);

                var itemContext = ProjectPropertiesContext.GetContext(
                    CommonServices.Project,
                    file: viewModel.FilePath,
                    itemType: viewModel.SchemaItemType,
                    itemName: viewModel.FilePath);

                node = TreeServices.CreateTree(
                    caption: viewModel.Caption,
                    itemContext: itemContext,
                    propertySheet: null,
                    visible: true,
                    browseObjectProperties: rule,
                    flags: viewModel.Flags,
                    icon: viewModel.Icon.ToProjectSystemType(),
                    expandedIcon: viewModel.ExpandedIcon.ToProjectSystemType());
            }
            else
            {
                node = UpdateTreeNode(node, viewModel, rule);
            }

            return(node);
        }
        private IProjectTree CreateProjectItemTreeNode(
            IDependencyViewModel viewModel,
            IRule rule,
            ProjectTreeFlags?additionalFlags = null,
            ProjectTreeFlags?excludedFlags   = null)
        {
            ProjectTreeFlags flags    = FilterFlags(viewModel.Flags, additionalFlags, excludedFlags);
            string           filePath = (viewModel.OriginalModel != null && viewModel.OriginalModel.TopLevel &&
                                         viewModel.OriginalModel.Resolved)
                ? viewModel.OriginalModel.GetTopLevelId()
                : viewModel.FilePath;

            var itemContext = ProjectPropertiesContext.GetContext(
                CommonServices.Project,
                file: filePath,
                itemType: viewModel.SchemaItemType,
                itemName: filePath);

            return(TreeServices.CreateTree(
                       caption: viewModel.Caption,
                       itemContext: itemContext,
                       propertySheet: null,
                       browseObjectProperties: rule,
                       icon: viewModel.Icon.ToProjectSystemType(),
                       expandedIcon: viewModel.ExpandedIcon.ToProjectSystemType(),
                       visible: true,
                       flags: flags));
        }
        private IProjectTree CreateProjectTreeNode(
            IDependencyViewModel viewModel,
            IRule rule,
            ProjectTreeFlags?additionalFlags = null,
            ProjectTreeFlags?excludedFlags   = null)
        {
            // For IProjectTree remove ProjectTreeFlags.Common.Reference flag, otherwise CPS would fail to
            // map this node to graph node and GraphProvider would be never called.
            // Only IProjectItemTree can have this flag
            ProjectTreeFlags flags = FilterFlags(viewModel.Flags.Except(DependencyTreeFlags.BaseReferenceFlags),
                                                 additionalFlags,
                                                 excludedFlags);
            string filePath = (viewModel.OriginalModel != null && viewModel.OriginalModel.TopLevel &&
                               viewModel.OriginalModel.Resolved)
                ? viewModel.OriginalModel.GetTopLevelId()
                : viewModel.FilePath;

            return(TreeServices.CreateTree(
                       caption: viewModel.Caption,
                       filePath: filePath,
                       visible: true,
                       browseObjectProperties: rule,
                       flags: flags,
                       icon: viewModel.Icon.ToProjectSystemType(),
                       expandedIcon: viewModel.ExpandedIcon.ToProjectSystemType()));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates or creates new IProjectTree node
        /// </summary>
        private IProjectTree CreateOrUpdateProjectTreeNode(
            IProjectTree node,
            IDependencyViewModel viewModel,
            IRule rule,
            ProjectTreeFlags?additionalFlags = null,
            ProjectTreeFlags?excludedFlags   = null)
        {
            if (node == null)
            {
                // For IProjectTree remove ProjectTreeFlags.Common.Reference flag, otherwise CPS would fail to
                // map this node to graph node and GraphProvider would be never called.
                // Only IProjectItemTree can have this flag
                var flags = FilterFlags(viewModel.Flags.Except(DependencyTreeFlags.BaseReferenceFlags),
                                        additionalFlags,
                                        excludedFlags);

                node = TreeServices.CreateTree(
                    caption: viewModel.Caption,
                    filePath: viewModel.FilePath,
                    visible: true,
                    browseObjectProperties: rule,
                    flags: flags,
                    icon: viewModel.Icon.ToProjectSystemType(),
                    expandedIcon: viewModel.ExpandedIcon.ToProjectSystemType());
            }
            else
            {
                node = UpdateTreeNode(node, viewModel, rule);
            }

            return(node);
        }
        public static IProjectDependenciesSubTreeProvider2 Implement(
            string?providerType = null,
            IDependencyModel?createRootDependencyNode = null,
            MockBehavior mockBehavior       = MockBehavior.Strict,
            ProjectTreeFlags?groupNodeFlags = null)
        {
            var mock = new Mock <IProjectDependenciesSubTreeProvider2>(mockBehavior);

            if (providerType != null)
            {
                mock.Setup(x => x.ProviderType).Returns(providerType);
            }

            if (createRootDependencyNode != null)
            {
                mock.Setup(x => x.CreateRootDependencyNode()).Returns(createRootDependencyNode);
            }

            if (groupNodeFlags != null)
            {
                mock.SetupGet(x => x.GroupNodeFlag).Returns(groupNodeFlags.Value);
            }

            return(mock.Object);
        }
Ejemplo n.º 6
0
        public IDependency SetProperties(
            string caption         = null,
            bool?resolved          = null,
            ProjectTreeFlags?flags = null,
            IImmutableList <string> dependencyIDs = null)
        {
            var clone = new Dependency(this, _modelId);

            if (caption != null)
            {
                clone.Caption = caption;
            }

            if (resolved != null)
            {
                clone.Resolved = resolved.Value;
            }

            if (flags != null)
            {
                clone.Flags = flags.Value;
            }

            if (dependencyIDs != null)
            {
                clone.DependencyIDs = dependencyIDs;
            }

            return(clone);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Private constructor used to clone Dependency
        /// </summary>
        private Dependency(
            Dependency dependency,
            string?caption,
            bool?resolved,
            ProjectTreeFlags?flags,
            string?schemaName,
            ImmutableArray <string> dependencyIDs,
            DependencyIconSet?iconSet,
            bool?isImplicit)
        {
            // Copy values as necessary to create a clone with any properties overridden

            _id                    = dependency._id;
            _modelId               = dependency._modelId;
            _fullPath              = dependency._fullPath;
            TargetFramework        = dependency.TargetFramework;
            _containingProjectPath = dependency._containingProjectPath;
            ProviderType           = dependency.ProviderType;
            Name                   = dependency.Name;
            OriginalItemSpec       = dependency.OriginalItemSpec;
            Path                   = dependency.Path;
            _schemaItemType        = dependency.SchemaItemType;
            TopLevel               = dependency.TopLevel;
            Visible                = dependency.Visible;
            Priority               = dependency.Priority;
            BrowseObjectProperties = dependency.BrowseObjectProperties;
            Caption                = caption ?? dependency.Caption; // TODO if Properties contains "Folder.IdentityProperty" should we update it? (see public ctor)
            Resolved               = resolved ?? dependency.Resolved;
            Flags                  = flags ?? dependency.Flags;
            SchemaName             = schemaName ?? dependency.SchemaName;
            DependencyIDs          = dependencyIDs.IsDefault ? dependency.DependencyIDs : dependencyIDs;
            IconSet                = iconSet != null?DependencyIconSetCache.Instance.GetOrAddIconSet(iconSet) : dependency.IconSet;

            Implicit = isImplicit ?? dependency.Implicit;
        }
        /// <summary>
        /// Updates or creates new node
        /// </summary>
        private async Task <IProjectTree> CreateOrUpdateNodeAsync(
            IProjectTree node,
            IDependency dependency,
            ITargetedDependenciesSnapshot targetedSnapshot,
            IProjectCatalogSnapshot catalogs,
            bool isProjectItem,
            ProjectTreeFlags?additionalFlags = null,
            ProjectTreeFlags?excludedFlags   = null)
        {
            IRule rule = null;

            if (dependency.Flags.Contains(DependencyTreeFlags.SupportsRuleProperties))
            {
                rule = await TreeServices.GetRuleAsync(dependency, catalogs)
                       .ConfigureAwait(false);
            }

            return(CreateOrUpdateNode(
                       node,
                       dependency.ToViewModel(targetedSnapshot),
                       rule,
                       isProjectItem,
                       additionalFlags,
                       excludedFlags));
        }
Ejemplo n.º 9
0
 public IProjectTree CreateTree(
     string caption,
     IProjectPropertiesContext itemContext,
     IPropertySheet?propertySheet     = null,
     IRule?browseObjectProperties     = null,
     ProjectImageMoniker?icon         = null,
     ProjectImageMoniker?expandedIcon = null,
     bool visible           = true,
     ProjectTreeFlags?flags = default)
 {
     // Note that all the parameters are specified so we can force this call to an
     // overload of NewTree available prior to 15.5 versions of CPS. Once a 15.5 build
     // is publicly available we can move this to an overload with default values for
     // most of the parameters, and we'll only need to pass the interesting ones.
     return(NewTree(
                caption: caption,
                item: itemContext,
                propertySheet: propertySheet,
                browseObjectProperties: browseObjectProperties,
                icon: icon,
                expandedIcon: expandedIcon,
                visible: visible,
                flags: flags,
                isLinked: false));
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Private constructor used to clone Dependency
        /// </summary>
        private Dependency(
            Dependency dependency,
            string?caption,
            bool?resolved,
            ProjectTreeFlags?flags,
            string?schemaName,
            DependencyIconSet?iconSet,
            bool?isImplicit,
            DiagnosticLevel?diagnosticLevel)
        {
            // Copy values as necessary to create a clone with any properties overridden

            Id                     = dependency.Id;
            ProviderType           = dependency.ProviderType;
            OriginalItemSpec       = dependency.OriginalItemSpec;
            FilePath               = dependency.FilePath;
            _schemaItemType        = dependency._schemaItemType;
            Visible                = dependency.Visible;
            BrowseObjectProperties = dependency.BrowseObjectProperties; // NOTE we explicitly do not update Identity in these properties if caption changes
            Caption                = caption ?? dependency.Caption;     // TODO if Properties contains "Folder.IdentityProperty" should we update it? (see public ctor)
            Resolved               = resolved ?? dependency.Resolved;
            Flags                  = flags ?? dependency.Flags;
            SchemaName             = schemaName ?? dependency.SchemaName;
            IconSet                = iconSet != null?DependencyIconSetCache.Instance.GetOrAddIconSet(iconSet) : dependency.IconSet;

            Implicit        = isImplicit ?? dependency.Implicit;
            DiagnosticLevel = diagnosticLevel ?? dependency.DiagnosticLevel;
        }
        public static TestDependencyModel FromJson(
            string jsonString,
            ProjectTreeFlags?flags                 = null,
            ImageMoniker?icon                      = null,
            ImageMoniker?expandedIcon              = null,
            ImageMoniker?unresolvedIcon            = null,
            ImageMoniker?unresolvedExpandedIcon    = null,
            Dictionary <string, string> properties = null,
            IEnumerable <string> dependenciesIds   = null)
        {
            if (string.IsNullOrEmpty(jsonString))
            {
                return(null);
            }

            var json = JObject.Parse(jsonString);
            var data = json.ToObject <TestDependencyModel>();

            if (flags.HasValue)
            {
                data.Flags += flags.Value;
            }

            data.Flags += data.Resolved
                ? DependencyTreeFlags.ResolvedFlags
                : DependencyTreeFlags.UnresolvedFlags;

            if (icon.HasValue)
            {
                data.Icon = icon.Value;
            }

            if (expandedIcon.HasValue)
            {
                data.ExpandedIcon = expandedIcon.Value;
            }

            if (unresolvedIcon.HasValue)
            {
                data.UnresolvedIcon = unresolvedIcon.Value;
            }

            if (unresolvedExpandedIcon.HasValue)
            {
                data.UnresolvedExpandedIcon = unresolvedExpandedIcon.Value;
            }

            if (properties != null)
            {
                data.Properties = ImmutableStringDictionary <string> .EmptyOrdinal.AddRange(properties);
            }

            if (dependenciesIds != null)
            {
                data.DependencyIDs = ImmutableList <string> .Empty.AddRange(dependenciesIds);
            }

            return(data);
        }
Ejemplo n.º 12
0
 public IDependency SetProperties(
     string caption         = null,
     bool?resolved          = null,
     ProjectTreeFlags?flags = null,
     IImmutableList <string> dependencyIDs = null)
 {
     return(this);
 }
Ejemplo n.º 13
0
 public IDependency SetProperties(
     string?caption            = null,
     bool?resolved             = null,
     ProjectTreeFlags?flags    = null,
     string?schemaName         = null,
     DependencyIconSet?iconSet = null,
     bool?isImplicit           = null)
 {
     return(new Dependency(this, caption, resolved, flags, schemaName, iconSet, isImplicit));
 }
Ejemplo n.º 14
0
 public IDependency SetProperties(
     string caption         = null,
     bool?resolved          = null,
     ProjectTreeFlags?flags = null,
     string schemaName      = null,
     IImmutableList <string> dependencyIDs = null,
     DependencyIconSet iconSet             = null,
     bool?isImplicit = null)
 {
     return(this);
 }
Ejemplo n.º 15
0
        public IDependency SetProperties(
            string caption         = null,
            bool?resolved          = null,
            ProjectTreeFlags?flags = null,
            string schemaName      = null,
            IImmutableList <string> dependencyIDs = null,
            ImageMoniker icon         = default(ImageMoniker),
            ImageMoniker expandedIcon = default(ImageMoniker),
            bool?isImplicit           = null)
        {
            var clone = new Dependency(this, _modelId);

            if (caption != null)
            {
                clone.Caption = caption;
            }

            if (resolved != null)
            {
                clone.Resolved = resolved.Value;
            }

            if (flags != null)
            {
                clone.Flags = flags.Value;
            }

            if (schemaName != null)
            {
                clone.SchemaName = schemaName;
            }

            if (dependencyIDs != null)
            {
                clone.DependencyIDs = dependencyIDs;
            }

            if (icon.Id != 0 && icon.Guid != Guid.Empty)
            {
                clone.Icon = icon;
            }

            if (expandedIcon.Id != 0 && expandedIcon.Guid != Guid.Empty)
            {
                clone.ExpandedIcon = expandedIcon;
            }

            if (isImplicit != null)
            {
                clone.Implicit = isImplicit.Value;
            }

            return(clone);
        }
Ejemplo n.º 16
0
 public IDependency SetProperties(
     string caption         = null,
     bool?resolved          = null,
     ProjectTreeFlags?flags = null,
     string schemaName      = null,
     ImmutableArray <string> dependencyIDs = default,
     DependencyIconSet iconSet             = null,
     bool?isImplicit = null)
 {
     return(new Dependency(this, caption, resolved, flags, schemaName, dependencyIDs, iconSet, isImplicit));
 }
Ejemplo n.º 17
0
 public IDependency SetProperties(
     string caption         = null,
     bool?resolved          = null,
     ProjectTreeFlags?flags = null,
     string schemaName      = null,
     IImmutableList <string> dependencyIDs = null,
     ImageMoniker icon         = default,
     ImageMoniker expandedIcon = default,
     bool?isImplicit           = null)
 {
     return(this);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Updates or creates new node
 /// </summary>
 private IProjectTree CreateOrUpdateNode(
     IProjectTree node,
     IDependencyViewModel viewModel,
     IRule rule,
     bool isProjectItem,
     ProjectTreeFlags?additionalFlags = null,
     ProjectTreeFlags?excludedFlags   = null)
 {
     return(isProjectItem
         ? CreateOrUpdateProjectItemTreeNode(node, viewModel, rule, additionalFlags, excludedFlags)
         : CreateOrUpdateProjectTreeNode(node, viewModel, rule, additionalFlags, excludedFlags));
 }
Ejemplo n.º 19
0
        public IProjectTree SetProperties(string caption           = null, string filePath = null, IRule browseObjectProperties = null,
                                          ProjectImageMoniker icon = null, ProjectImageMoniker expandedIcon = null, bool?
                                          visible = null, ProjectTreeFlags?flags                   = null, IProjectPropertiesContext context = null,
                                          IPropertySheet propertySheet     = null, bool?isLinked   = null, bool resetFilePath                = false,
                                          bool resetBrowseObjectProperties = false, bool resetIcon = false, bool resetExpandedIcon           = false)
        {
            Icon                   = icon ?? Icon;
            ExpandedIcon           = expandedIcon ?? ExpandedIcon;
            BrowseObjectProperties = browseObjectProperties ?? BrowseObjectProperties;
            Caption                = caption ?? Caption;

            return(this);
        }
Ejemplo n.º 20
0
        public IDependency SetProperties(
            string caption         = null,
            bool?resolved          = null,
            ProjectTreeFlags?flags = null,
            string schemaName      = null,
            IImmutableList <string> dependencyIDs = null,
            DependencyIconSet iconSet             = null,
            bool?isImplicit = null)
        {
            var clone = new Dependency(this, _modelId);

            if (caption != null)
            {
                clone.Caption = caption;
            }

            if (resolved != null)
            {
                clone.Resolved = resolved.Value;
            }

            if (flags != null)
            {
                clone.Flags = flags.Value;
            }

            if (schemaName != null)
            {
                clone.SchemaName = schemaName;
            }

            if (dependencyIDs != null)
            {
                clone.DependencyIDs = dependencyIDs;
            }

            if (iconSet != null)
            {
                clone.IconSet = s_iconSetCache.GetOrAddIconSet(iconSet);
            }

            if (isImplicit != null)
            {
                clone.Implicit = isImplicit.Value;
            }

            return(clone);
        }
Ejemplo n.º 21
0
        public static IDependencyNode FromJson(string jsonString, ProjectTreeFlags?flags = null)
        {
            if (string.IsNullOrEmpty(jsonString))
            {
                return(null);
            }

            var json = JObject.Parse(jsonString);
            var data = json.ToObject <DependencyNode>();

            if (flags != null && flags.HasValue)
            {
                data.Flags = data.Flags.Union(flags.Value);
            }
            return(data);
        }
        /// <summary>
        /// Updates or creates new node
        /// </summary>
        private IProjectTree CreateOrUpdateNode(
            IProjectTree node,
            IDependency dependency,
            IProjectCatalogSnapshot catalogs,
            bool isProjectItem,
            ProjectTreeFlags?additionalFlags = null,
            ProjectTreeFlags?excludedFlags   = null)
        {
            IRule rule = null;

            if (dependency.Flags.Contains(DependencyTreeFlags.SupportsRuleProperties))
            {
                rule = TreeServices.GetRule(dependency, catalogs);
            }

            return(CreateOrUpdateNode(node, dependency.ToViewModel(), rule, isProjectItem, additionalFlags, excludedFlags));
        }
        private static ProjectTreeFlags FilterFlags(
            ProjectTreeFlags flags,
            ProjectTreeFlags?additionalFlags,
            ProjectTreeFlags?excludedFlags)
        {
            if (additionalFlags.HasValue)
            {
                flags = flags.Union(additionalFlags.Value);
            }

            if (excludedFlags.HasValue)
            {
                flags = flags.Except(excludedFlags.Value);
            }

            return(flags);
        }
Ejemplo n.º 24
0
 public IProjectTree CreateTree(
     string caption,
     string?filePath,
     IRule?browseObjectProperties     = null,
     ProjectImageMoniker?icon         = null,
     ProjectImageMoniker?expandedIcon = null,
     bool visible           = true,
     ProjectTreeFlags?flags = default)
 {
     return(NewTree(
                caption: caption,
                filePath: filePath,
                browseObjectProperties: browseObjectProperties,
                icon: icon,
                expandedIcon: expandedIcon,
                visible: visible,
                flags: flags));
 }
Ejemplo n.º 25
0
        public static IDependency FromJson(
            string jsonString,
            ProjectTreeFlags?flags    = null,
            DependencyIconSet iconSet = null,
            Dictionary <string, string> properties = null,
            IEnumerable <string> dependenciesIds   = null,
            ITargetFramework targetFramework       = null)
        {
            if (string.IsNullOrEmpty(jsonString))
            {
                return(null);
            }

            var json = JObject.Parse(jsonString);
            var data = json.ToObject <TestDependency>();

            if (flags.HasValue)
            {
                data.Flags = data.Flags.Union(flags.Value);
            }

            if (iconSet != null)
            {
                data.IconSet = iconSet;
            }

            if (properties != null)
            {
                data.Properties = ImmutableStringDictionary <string> .EmptyOrdinal.AddRange(properties);
            }

            if (dependenciesIds != null)
            {
                data.DependencyIDs = ImmutableArray.CreateRange(dependenciesIds);
            }

            if (targetFramework != null)
            {
                data.TargetFramework = targetFramework;
            }

            return(data);
        }
 public IProjectTree CreateTree(
     string caption,
     string?filePath,
     IRule?browseObjectProperties     = null,
     ProjectImageMoniker?icon         = null,
     ProjectImageMoniker?expandedIcon = null,
     bool visible           = true,
     ProjectTreeFlags?flags = null)
 {
     return(new TestProjectTree
     {
         Caption = caption,
         BrowseObjectProperties = browseObjectProperties,
         Icon = icon,
         ExpandedIcon = expandedIcon,
         Visible = visible,
         Flags = flags ?? ProjectTreeFlags.Empty,
         IsProjectItem = false
     });
 }
Ejemplo n.º 27
0
        private async Task <IProjectTree> CreateOrUpdateNodeAsync(
            IProjectTree?node,
            IDependency dependency,
            TargetedDependenciesSnapshot targetedSnapshot,
            bool isProjectItem,
            ProjectTreeFlags?additionalFlags = null,
            ProjectTreeFlags?excludedFlags   = null)
        {
            IRule?browseObjectProperties = dependency.Flags.Contains(DependencyTreeFlags.SupportsRuleProperties)
                ? await _treeServices.GetBrowseObjectRuleAsync(dependency, targetedSnapshot.Catalogs)
                : null;

            return(CreateOrUpdateNode(
                       node,
                       dependency.ToViewModel(targetedSnapshot),
                       browseObjectProperties,
                       isProjectItem,
                       additionalFlags,
                       excludedFlags));
        }
 public IProjectTree CreateTree(
     string caption,
     IProjectPropertiesContext itemContext,
     IPropertySheet?propertySheet     = null,
     IRule?browseObjectProperties     = null,
     ProjectImageMoniker?icon         = null,
     ProjectImageMoniker?expandedIcon = null,
     bool visible           = true,
     ProjectTreeFlags?flags = null)
 {
     return(NewTree(
                caption: caption,
                item: itemContext,
                propertySheet: propertySheet,
                browseObjectProperties: browseObjectProperties,
                icon: icon,
                expandedIcon: expandedIcon,
                visible: visible,
                flags: flags));
 }
 public IProjectTree CreateTree(
     string caption,
     IProjectPropertiesContext itemContext,
     IPropertySheet?propertySheet     = null,
     IRule?browseObjectProperties     = null,
     ProjectImageMoniker?icon         = null,
     ProjectImageMoniker?expandedIcon = null,
     bool visible           = true,
     ProjectTreeFlags?flags = null)
 {
     return(new TestProjectTree
     {
         Caption = caption,
         BrowseObjectProperties = browseObjectProperties,
         Icon = icon,
         ExpandedIcon = expandedIcon,
         Visible = visible,
         Flags = flags ?? ProjectTreeFlags.Empty,
         IsProjectItem = true
     });
 }
 public IProjectTree CreateTree(
     string caption,
     string filePath,
     IRule browseObjectProperties     = null,
     ProjectImageMoniker icon         = null,
     ProjectImageMoniker expandedIcon = null,
     bool visible           = true,
     ProjectTreeFlags?flags = default(ProjectTreeFlags?))
 {
     return(new TestProjectTree()
     {
         Caption = caption,
         FilePath = filePath,
         BrowseObjectProperties = browseObjectProperties,
         Icon = icon,
         ExpandedIcon = expandedIcon,
         Visible = visible,
         Flags = flags.Value,
         IsProjectItem = false
     });
 }