예제 #1
0
파일: DataModel.cs 프로젝트: tashby/roslyn
        public DataModel()
        {
            var functions = from f in typeof(FunctionId).GetFields()
                            where !f.IsSpecialName
                            select f;

            var count = functions.Count();

            _activities = new ActivityLevel[count];

            var features = new Dictionary <string, ActivityLevel>();
            var root     = new ActivityLevel("All");

            foreach (var function in functions)
            {
                var value        = (int)function.GetRawConstantValue();
                var name         = function.Name;
                var featureNames = name.Split('_');
                var featureName  = featureNames.Length > 1 ? featureNames[0] : "Uncategorized";

                ActivityLevel parent;
                if (!features.TryGetValue(featureName, out parent))
                {
                    parent = new ActivityLevel(featureName, root, createChildList: true);
                    features[featureName] = parent;
                }

                _activities[value - 1] = new ActivityLevel(name, parent, createChildList: false);
            }

            root.SortChildren();
            this.RootNode = root;
        }
예제 #2
0
        public DataModel()
        {
            var fields = from field in typeof(FunctionId).GetFields()
                         where !field.IsSpecialName
                         select field;

            var builder = new ArrayBuilder <ActivityLevel?>();

            var features = new Dictionary <string, ActivityLevel>();
            var root     = new ActivityLevel("All");

            foreach (var field in fields)
            {
                var value        = (int)field.GetRawConstantValue();
                var name         = field.Name;
                var featureNames = name.Split('_');
                var featureName  = featureNames.Length > 1 ? featureNames[0] : "Uncategorized";

                if (!features.TryGetValue(featureName, out var parent))
                {
                    parent = new ActivityLevel(featureName, root, createChildList: true);
                    features[featureName] = parent;
                }

                builder.SetItem(value, new ActivityLevel(name, parent, createChildList: false));
            }

            _activities = builder.ToImmutable();
            root.SortChildren();
            RootNode = root;
        }
예제 #3
0
        public DataModel()
        {
            var functions = from f in typeof(FunctionId).GetFields()
                            where !f.IsSpecialName
                            select f;

            var count = functions.Count();
            this.activities = new ActivityLevel[count];

            var features = new Dictionary<string, ActivityLevel>();
            var root = new ActivityLevel("All");

            foreach (var function in functions)
            {
                var value = (int)function.GetRawConstantValue();
                var name = function.Name;
                var featureNames = name.Split('_');
                var featureName = featureNames.Length > 1 ? featureNames[0] : "Uncategorized";

                ActivityLevel parent;
                if (!features.TryGetValue(featureName, out parent))
                {
                    parent = new ActivityLevel(featureName, root, createChildList: true);
                    features[featureName] = parent;
                }

                activities[value - 1] = new ActivityLevel(name, parent, createChildList: false);
            }

            root.SortChildren();
            this.RootNode = root;
        }