예제 #1
0
        private void AnalyzeAssembly(Assembly assembly)
        {
            if (assembly.ReflectionOnly)
            {
                return;
            }

            IEnumerable <Type> nodeTypes = Enumerable.Empty <Type>();

            nodeTypes = assembly.GetTypes();
            nodeTypes = nodeTypes.Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(Node)) && t != typeof(Flow) && !t.IsSubclassOf(typeof(Flow)))
                        .Where(t => t.GetConstructor(Type.EmptyTypes) != null);

            foreach (Type type in nodeTypes)
            {
                NodeTypeInfo     nodeType     = NodeTypeInfo.From(type);
                NodeCategoryInfo nodeCategory = NodeCategories.FirstOrDefault(c => c.Category == nodeType.Category);

                if (nodeCategory == null)
                {
                    NodeCategories.Add(nodeCategory = new NodeCategoryInfo(nodeType.Category));
                }

                nodeCategory.Nodes.Add(nodeType);
            }
        }
예제 #2
0
        /// <summary>
        ///     Add a category, given a delimited name
        /// </summary>
        /// <param name="categoryName">The comma delimited name </param>
        /// <returns>The newly created item</returns>
        public BrowserItem AddCategory(string categoryName)
        {
            if (ContainsCategory(categoryName))
            {
                return(GetCategoryByName(categoryName));
            }

            if (!NodeCategories.ContainsKey(categoryName))
            {
                NodeCategories.Add(categoryName, new CategorySearchElement(categoryName));
            }

            // otherwise split the category name
            var splitCat = SplitCategoryName(categoryName);

            // attempt to add root element
            if (splitCat.Count == 1)
            {
                return(this.TryAddRootCategory(categoryName));
            }

            // attempt to add root category
            var currentCat = TryAddRootCategory(splitCat[0]);

            for (var i = 1; i < splitCat.Count; i++)
            {
                currentCat = TryAddChildCategory(currentCat, splitCat[i]);
            }

            return(currentCat);
        }
예제 #3
0
        private void ReloadNodesButton_Click(object sender, EventArgs e)
        {
            NodeCategories.Clear();

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                AnalyzeAssembly(assembly);
            }
        }
예제 #4
0
        public bool Equals(DestinyTalentGridDefinition input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     MaxGridLevel == input.MaxGridLevel ||
                     (MaxGridLevel.Equals(input.MaxGridLevel))
                     ) &&
                 (
                     GridLevelPerColumn == input.GridLevelPerColumn ||
                     (GridLevelPerColumn.Equals(input.GridLevelPerColumn))
                 ) &&
                 (
                     ProgressionHash == input.ProgressionHash ||
                     (ProgressionHash.Equals(input.ProgressionHash))
                 ) &&
                 (
                     Nodes == input.Nodes ||
                     (Nodes != null && Nodes.SequenceEqual(input.Nodes))
                 ) &&
                 (
                     ExclusiveSets == input.ExclusiveSets ||
                     (ExclusiveSets != null && ExclusiveSets.SequenceEqual(input.ExclusiveSets))
                 ) &&
                 (
                     IndependentNodeIndexes == input.IndependentNodeIndexes ||
                     (IndependentNodeIndexes != null && IndependentNodeIndexes.SequenceEqual(input.IndependentNodeIndexes))
                 ) &&
                 (
                     Groups == input.Groups ||
                     (Groups != null && Groups.SequenceEqual(input.Groups))
                 ) &&
                 (
                     NodeCategories == input.NodeCategories ||
                     (NodeCategories != null && NodeCategories.SequenceEqual(input.NodeCategories))
                 ) &&
                 (
                     Hash == input.Hash ||
                     (Hash.Equals(input.Hash))
                 ) &&
                 (
                     Index == input.Index ||
                     (Index.Equals(input.Index))
                 ) &&
                 (
                     Redacted == input.Redacted ||
                     (Redacted != null && Redacted.Equals(input.Redacted))
                 ));
        }
예제 #5
0
        public void Remove(string nodeName)
        {
            // get the node, return if not found
            var nodes = _browserLeaves.Where(x => x.Name == nodeName);

            if (!nodes.Any())
            {
                return;
            }

            // remove from search dictionary
            SearchDictionary.Remove((ele) => (ele).Name == nodeName);
            SearchDictionary.Remove((ele) => (ele).Name.EndsWith("." + nodeName));

            // remove from browser leaves
            _browserLeaves.Where(x => x.Name == nodeName).ToList().ForEach(x => _browserLeaves.Remove(x));

            // get the category if it doesn't exist, then remove it
            foreach (var node in nodes)
            {
                var categoryName       = ((SearchElementBase)node).FullCategoryName;
                var parentCategoryName = ((BrowserInternalElement)node).Parent.Name;

                if (!NodeCategories.ContainsKey(categoryName))
                {
                    return;
                }

                // first level category
                var pcategory = NodeCategories[parentCategoryName];
                pcategory.NumElements--;

                if (pcategory.NumElements == 0)
                {
                    this.RemoveCategory(pcategory.Name);
                }

                // immediate category
                var category = NodeCategories[categoryName];
                category.NumElements--;

                if (category.NumElements == 0)
                {
                    this.RemoveCategory(category.Name);
                }
            }
        }
예제 #6
0
        /// <summary>
        ///     Add a category, given a delimited name
        /// </summary>
        /// <param name="categoryName">The comma delimited name </param>
        /// <returns>The newly created item</returns>
        internal BrowserItem AddCategory(string categoryName)
        {
            if (string.IsNullOrEmpty(categoryName))
            {
                return(this.TryAddRootCategory("Uncategorized"));
            }

            if (ContainsCategory(categoryName))
            {
                return(GetCategoryByName(categoryName));
            }

            if (!NodeCategories.ContainsKey(categoryName))
            {
                var cat = new CategorySearchElement(categoryName);
                cat.Executed += this.OnExecuted;

                NodeCategories.Add(categoryName, cat);
            }

            // otherwise split the category name
            var splitCat = SplitCategoryName(categoryName);

            // attempt to add root element
            if (splitCat.Count == 1)
            {
                return(this.TryAddRootCategory(categoryName));
            }

            if (splitCat.Count == 0)
            {
                return(null);
            }

            // attempt to add root category
            var currentCat = TryAddRootCategory(splitCat[0]);

            for (var i = 1; i < splitCat.Count; i++)
            {
                currentCat = TryAddChildCategory(currentCat, splitCat[i]);
            }

            return(currentCat);
        }
예제 #7
0
 public bool DeepEquals(DestinyTalentGridDefinition other)
 {
     return(other != null &&
            ExclusiveSets.DeepEqualsReadOnlyCollections(other.ExclusiveSets) &&
            CalcMaxGridLevel == other.CalcMaxGridLevel &&
            CalcProgressToMaxLevel == other.CalcProgressToMaxLevel &&
            GridLevelPerColumn == other.GridLevelPerColumn &&
            Groups.DeepEqualsReadOnlyDictionaryWithSimpleKeyAndEquatableValue(other.Groups) &&
            IndependentNodeIndexes.DeepEqualsReadOnlySimpleCollection(other.IndependentNodeIndexes) &&
            MaxGridLevel == other.MaxGridLevel &&
            MaximumRandomMaterialRequirements == other.MaximumRandomMaterialRequirements &&
            NodeCategories.DeepEqualsReadOnlyCollections(other.NodeCategories) &&
            Nodes.DeepEqualsReadOnlyCollections(other.Nodes) &&
            Progression.DeepEquals(other.Progression) &&
            Blacklisted == other.Blacklisted &&
            Hash == other.Hash &&
            Index == other.Index &&
            Redacted == other.Redacted);
 }
예제 #8
0
        /// <summary>
        ///     Attempt to add a new category to the browser and an item as one of its children
        /// </summary>
        /// <param name="category">The name of the category - a string possibly separated with one period </param>
        /// <param name="item">The item to add as a child of that category</param>
        public void TryAddCategoryAndItem(string category, BrowserInternalElement item)
        {
            if (!NodeCategories.ContainsKey(category))
            {
                NodeCategories.Add(category, new CategorySearchElement(category));
            }

            var cat = this.AddCategory(category);

            cat.AddChild(item);

            item.FullCategoryName = category;

            var searchEleItem = item as SearchElementBase;

            if (searchEleItem != null)
            {
                _browserLeaves.Add(searchEleItem);
            }
        }
예제 #9
0
        /// <summary>
        ///     Attempts to remove all traces of a particular custom node from Dynamo, assuming the node is not in a loaded workspace.
        /// </summary>
        /// <param name="guid"></param>
        public void Remove(Guid guid)
        {
            if (loadedNodes.ContainsKey(guid))
            {
                loadedNodes.Remove(guid);
            }
            if (nodePaths.ContainsKey(guid))
            {
                nodePaths.Remove(guid);
            }
            if (NodeCategories.ContainsKey(guid))
            {
                NodeCategories.Remove(guid);
            }
            var nodeName = NodeNames.Where((x) => x.Value == guid).ToList();

            nodeName.ForEach((pair) =>
            {
                NodeNames.Remove(pair.Key);
                dynSettings.Controller.SearchViewModel.Remove(pair.Key);
            });
            dynSettings.Controller.SearchViewModel.SearchAndUpdateResults();
            dynSettings.Controller.FSchemeEnvironment.RemoveSymbol(guid.ToString());
        }