public void AddComponent(IComponentSourceCodeHandler sourceCodeHandler, string projectId, ComponentType componentType, string code = null, string prefixInModule = null, string componentName = null) { using (var newComponent = CreateComponent(projectId, componentType)) { if (newComponent == null) { return; } if (code != null) { using (var loadedComponent = sourceCodeHandler.SubstituteCode(newComponent, code)) { AddPrefix(loadedComponent, prefixInModule); RenameComponent(loadedComponent, componentName); ShowComponent(loadedComponent); } } else { AddPrefix(newComponent, prefixInModule); RenameComponent(newComponent, componentName); ShowComponent(newComponent); } } }
public void SubstituteCode(QualifiedModuleName module, string newCode) { var component = _projectsProvider.Component(module); if (component == null) { return; } using (_componentSourceCodeHandler.SubstituteCode(component, newCode)){} //We do nothing; we just need to guarantee that the returned SCW gets disposed. }