internal Transition(ITaskDefinitionSymbol containingTask, 
                            TransitionDefinitionSyntax syntax, 
                            NodeReferenceSymbol source, 
                            EdgeModeSymbol edgeMode, 
                            NodeReferenceSymbol target, 
                            SymbolCollection<TriggerSymbol> triggers)  {

            if (containingTask == null) {
                throw new ArgumentNullException(nameof(containingTask));
            }

            if (syntax == null) {
                throw new ArgumentNullException(nameof(syntax));
            }

            ContainingTask = containingTask;
            Syntax   = syntax;
            Source   = source;
            EdgeMode = edgeMode;
            Target   = target;
            Triggers = triggers??new SymbolCollection<TriggerSymbol>();

            foreach (var trigger in Triggers) {
                trigger.Transition = this;
            }
        }
        public CodeGenerationResult(ITaskDefinitionSymbol taskDefinition) {

            if(taskDefinition == null) {
                throw new ArgumentNullException(nameof(taskDefinition));
            }

            TaskDefinition = taskDefinition;
        }
        public BeginWfsCodeModel(ITaskDefinitionSymbol taskDefinition) {

            if (taskDefinition == null) {
                throw new ArgumentNullException(nameof(taskDefinition));
            }

            _taskDefinition  = taskDefinition;
            _taskCodeModel = new TaskCodeModel(taskDefinition);
        }
        public TaskCodeModel(ITaskDefinitionSymbol taskDefinitionSymbol) {

            if (taskDefinitionSymbol == null) {
                throw new ArgumentNullException(nameof(taskDefinitionSymbol));
            }

            var task = taskDefinitionSymbol;

            var name = task.Name;
            var baseNamespace = (task.Syntax.SyntaxTree.GetRoot() as CodeGenerationUnitSyntax)?.CodeNamespace?.Namespace?.ToString();

            WflNamespace    = $"{baseNamespace}.WFL";
            WfsBaseTypeName = $"{name}WFSBase";
            WfsTypeName     = $"{name}WFS";
        }
        public override void VisitTaskDefinitionSymbol(ITaskDefinitionSymbol taskDefinitionSymbol) {
            #if ShowMemberCombobox
            foreach (var symbol in taskDefinitionSymbol.Transitions.SelectMany(trans => trans.Symbols())) {
                Visit(symbol);
            }
            #endif

            NavigationItems.Add(new NavigationItem(
                displayName    : taskDefinitionSymbol.Name, 
                imageIndex     : NavigationBarImages.Index.TaskDefinition, 
                location       : taskDefinitionSymbol.Syntax.GetLocation(), 
                navigationPoint: taskDefinitionSymbol.Location.Start,
                children       : MemberItems.ToImmutableList()));

            MemberItems.Clear();
        }
        CodeGenerationResult Generate(ITaskDefinitionSymbol taskDefinition) {

            // TODO Diagnostic check

            var result = new CodeGenerationResult(taskDefinition);

            if (_options.GenerateIBeginWfsInterface) {

                var model = new BeginWfsCodeModel(taskDefinition);
                var group = new TemplateGroupString(Resources.IBeginWFS);
                var st    = group.GetInstanceOf("IBeginWFS");

                st.Add("model", model);
                // TODO Add Context?

                result.BeginWfsInterface = st.Render();
            }

            return result;
        }