Esempio n. 1
0
        public static BlockUsedBy[] CreateUsedBys(InstanceDefinition definition)
        {
            var containers = definition.GetContainers();

            // check null containers
            if (containers.Length == 0)
            {
                return new[] { new BlockUsedBy {
                                   Name = definition.Name
                               } }
            }
            ;

            var usedBys = new BlockUsedBy[containers.Length];

            usedBys[0] = new BlockUsedBy {
                Name = definition.Name, UsedBy = containers[0].Name
            };

            if (containers.Length > 1)
            {
                for (int i = 1; i < containers.Length; i++)
                {
                    usedBys[i] = new BlockUsedBy {
                        UsedBy = containers[i].Name
                    };
                }
            }

            return(usedBys);
        }
    }
Esempio n. 2
0
        public static int GetNestedCount(this InstanceDefinition definition)
        {
            var containers = definition.GetContainers();
            int count      = 0;

            foreach (var container in containers)
            {
                foreach (var instance in container.GetPartInstances())
                {
                    if (instance.InstanceDefinition.Equals(definition))
                    {
                        count += 1;
                    }
                }
            }

            return(count);
        }