public void FireOnCodeGenerated(object sender, CodeGeneratorResponse response) { _log.Info("OnCodeGenerated"); if (null != OnCodeGenerated) OnCodeGenerated(sender, new CodeGeneratedEventArgs { Response = response }); }
public void FireOnCodeGenerated(object sender, CodeGeneratorResponse response) { OnCodeGenerated(sender, new CodeGeneratedEventArgs{Response = response}); }
public void FireOnCodeGenerated(object sender, CodeGeneratorResponse response) { OnCodeGenerated(sender, new CodeGeneratedEventArgs { Response = response }); }
public void WriteCodeGeneratorResponse(CodeGeneratorResponse response) { try { if (null == response.CodeGeneratorContext || response.Errors.Any()) return; var codeBehindFileName = _codeBehindFileHelper.GetOrAddCodeBehindFile( response.CodeGeneratorContext.Source.FileName); if (codeBehindFileName.IsNullOrEmpty()) { _log.Error("Code Behind File Helper returned a null or empty CodeBehindFileName. Can not write file."); return; } _log.InfoFormat("Updating [{0}]", codeBehindFileName); if (_fileWrapper.Exists(codeBehindFileName)) { _log.DebugFormat("Deleting file [{0}]", codeBehindFileName); _fileWrapper.Delete(codeBehindFileName); } var codeBehindFileSource = response.GeneratedCodeSyntaxTree.GetText(); if (string.IsNullOrEmpty(codeBehindFileSource)) _log.WarnFormat("Writing Empty Code Behind File for [{0}]", codeBehindFileName); _fileWrapper.WriteAllText(codeBehindFileName, codeBehindFileSource); _fileReader.EvictFromCache(codeBehindFileName); var openWindow = _visualStudioOpenDocumentManager.GetOpenDocument(codeBehindFileName); if (null != openWindow) openWindow.WriteText(codeBehindFileSource); } catch (Exception e) { _log.Error( string.Format("Exception writing Generated Code for Source Class [{0}]: {1}", response.CodeGeneratorContext.Source.FileName, e.Message), e); } }