Exemplo n.º 1
0
        private void AddInterfaceClass(ExtractInterfaceModel model)
        {
            var targetProjectId = model.TargetDeclaration.ProjectId;
            var interfaceCode   = InterfaceCode(model);
            var interfaceName   = model.InterfaceName;

            if (model.InterfaceInstancing == ClassInstancing.Public)
            {
                _addComponentService.AddComponentWithAttributes(targetProjectId, ComponentType.ClassModule, interfaceCode, componentName: interfaceName);
            }
            else
            {
                _addComponentService.AddComponent(targetProjectId, ComponentType.ClassModule, interfaceCode, componentName: interfaceName);
            }
        }
Exemplo n.º 2
0
        public void AddComponentWithAttributes(CodeExplorerItemViewModel node, ComponentType componentType, string code, string additionalPrefixInModule = null)
        {
            var projectId = ProjectId(node);

            if (projectId == null)
            {
                return;
            }

            var folderAnnotation = FolderAnnotation(node);
            var optionCompare    = OptionCompareStatement();

            var modulePrefix = new StringBuilder(folderAnnotation);

            if (optionCompare != null)
            {
                modulePrefix.Append(Environment.NewLine).Append(optionCompare);
            }
            if (additionalPrefixInModule != null)
            {
                modulePrefix.Append(Environment.NewLine).Append(additionalPrefixInModule);
            }
            var prefixInModule = modulePrefix.ToString();

            var suspensionResult = _parseManager.OnSuspendParser(
                this,
                Enum.GetValues(typeof(ParserState)).Cast <ParserState>(),
                () => _addComponentService.AddComponentWithAttributes(projectId, componentType, code, prefixInModule));

            if (suspensionResult.Outcome == SuspensionOutcome.UnexpectedError &&
                suspensionResult.EncounteredException != null)
            {
                //This rethrows with the original stack trace.
                ExceptionDispatchInfo.Capture(suspensionResult.EncounteredException).Throw();
            }
        }