本文整理汇总了C#中ErrorLogger类的典型用法代码示例。如果您正苦于以下问题:C# ErrorLogger类的具体用法?C# ErrorLogger怎么用?C# ErrorLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorLogger类属于命名空间,在下文中一共展示了ErrorLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public static void Configure()
{
ILog logger = new ConsoleLogger();
ILog errorLogger = new ErrorLogger();
LogManager.GetLog = type => type == typeof(ActionMessage) ? logger : errorLogger;
}
示例2: WebProjectManager
public WebProjectManager(IPackageRepository source, string siteRoot, IWebMatrixHost host)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (String.IsNullOrEmpty(siteRoot))
{
throw new ArgumentException("siteRoot");
}
_siteRoot = siteRoot;
string webRepositoryDirectory = GetWebRepositoryDirectory(siteRoot);
Logger = new ErrorLogger(host);
var project = new WebProjectSystem(siteRoot);
project.Logger = Logger;
_projectManager = new ProjectManager(sourceRepository: source,
pathResolver: new DefaultPackagePathResolver(webRepositoryDirectory),
localRepository: PackageRepositoryFactory.Default.CreateRepository(webRepositoryDirectory),
project: project);
}
示例3: checkBSP
//checks for boxes with only 1 possible input
public ErrorLogger checkBSP(ref bool madeChange)
{
ErrorLogger RV = new ErrorLogger();
bool noChange = false;
List<short> curList = new List<short>();
while (!noChange)
{
noChange = true;
for (int i = 0; i < 81; i++)
{
if (numBoxes[i].getValue() == 0)
{
curList.Clear();
curList.AddRange(numBoxes[i].getPV());
if (curList.Count == 1)
{
RV = RV + insertNum(numBoxes[i], curList[0]);
Console.WriteLine("Single Box Insert: " + i.ToString() + " inserting value: " + curList[0].ToString());
noChange = false;
madeChange = true;
}
else if (curList.Count == 0)
{
RV = RV + new ErrorLogger(-1, "Box " + i + " has no possible values");
}
}
if (RV.hasError()) break;
}
if (RV.hasError()) break;
}
return RV;
}
示例4: FwDataFixer
/// <summary>
/// Constructor. Reads the file and stores any data needed for corrections later on.
/// </summary>
public FwDataFixer(string filename, IProgress progress, ErrorLogger logger, ErrorCounter counter)
{
m_filename = filename;
m_progress = progress;
errorLogger = logger;
errorCounter = counter;
m_progress.Minimum = 0;
m_progress.Maximum = 1000;
m_progress.Position = 0;
m_progress.Message = String.Format(Strings.ksReadingTheInputFile, m_filename);
m_crt = 0;
// The following fixers will be run on each rt element during FixErrorsAndSave()
// Note: every change to the file MUST log an error. This is used in FixFwData to set a return code indicating whether anything changed.
// This in turn is used in Send/Receive to determine whether we need to re-split the file before committing.
// N.B.: Order is important here!!!!!!!
m_rtLevelFixers.Add(new DuplicateStyleFixer());
m_rtLevelFixers.Add(new OriginalFixer());
m_rtLevelFixers.Add(new CustomPropertyFixer());
m_rtLevelFixers.Add(new BasicCustomPropertyFixer());
var senseFixer = new GrammaticalSenseFixer();
m_rtLevelFixers.Add(senseFixer);
m_rtLevelFixers.Add(new MorphBundleFixer(senseFixer)); // after we've possibly removed MSAs in GrammaticalSenseFixer
m_rtLevelFixers.Add(new SequenceFixer());
m_rtLevelFixers.Add(new HomographFixer());
m_rtLevelFixers.Add(new DuplicateWordformFixer());
m_rtLevelFixers.Add(new CustomListNameFixer());
InitializeFixers(m_filename);
}
示例5: deleteItem
public static string deleteItem(string itemId)
{
ErrorLogger log = new ErrorLogger();
log.ErrorLog(HttpContext.Current.Server.MapPath("Logs/Delete"), "Item with ID " + itemId + " deleted from database.");
bool success = CatalogAccess.DeleteItem(itemId);
return success ? "Item deleted successfully." : "There was an error processing your request.";
}
示例6: RunInteractiveCore
/// <summary>
/// csi.exe and vbi.exe entry point.
/// </summary>
private int RunInteractiveCore(ErrorLogger errorLogger)
{
Debug.Assert(_compiler.Arguments.IsScriptRunner);
var sourceFiles = _compiler.Arguments.SourceFiles;
if (sourceFiles.IsEmpty && _compiler.Arguments.DisplayLogo)
{
_compiler.PrintLogo(_console.Out);
if (!_compiler.Arguments.DisplayHelp)
{
_console.Out.WriteLine(ScriptingResources.HelpPrompt);
}
}
if (_compiler.Arguments.DisplayHelp)
{
_compiler.PrintHelp(_console.Out);
return 0;
}
SourceText code = null;
var diagnosticsInfos = new List<DiagnosticInfo>();
if (!sourceFiles.IsEmpty)
{
if (sourceFiles.Length > 1 || !sourceFiles[0].IsScript)
{
diagnosticsInfos.Add(new DiagnosticInfo(_compiler.MessageProvider, _compiler.MessageProvider.ERR_ExpectedSingleScript));
}
else
{
code = _compiler.ReadFileContent(sourceFiles[0], diagnosticsInfos);
}
}
var scriptPathOpt = sourceFiles.IsEmpty ? null : sourceFiles[0].Path;
var scriptOptions = GetScriptOptions(_compiler.Arguments, scriptPathOpt, _compiler.MessageProvider, diagnosticsInfos);
var errors = _compiler.Arguments.Errors.Concat(diagnosticsInfos.Select(Diagnostic.Create));
if (_compiler.ReportErrors(errors, _console.Out, errorLogger))
{
return CommonCompiler.Failed;
}
var cancellationToken = new CancellationToken();
if (_compiler.Arguments.InteractiveMode)
{
RunInteractiveLoop(scriptOptions, code?.ToString(), cancellationToken);
return CommonCompiler.Succeeded;
}
else
{
return RunScript(scriptOptions, code.ToString(), errorLogger, cancellationToken);
}
}
示例7: RunInteractiveCore
/// <summary>
/// csi.exe and vbi.exe entry point.
/// </summary>
private static int RunInteractiveCore(CommonCompiler compiler, TextWriter consoleOutput, ErrorLogger errorLogger)
{
Debug.Assert(compiler.Arguments.IsInteractive);
var hasScriptFiles = compiler.Arguments.SourceFiles.Any(file => file.IsScript);
if (compiler.Arguments.DisplayLogo && !hasScriptFiles)
{
compiler.PrintLogo(consoleOutput);
}
if (compiler.Arguments.DisplayHelp)
{
compiler.PrintHelp(consoleOutput);
return 0;
}
// TODO (tomat):
// When we have command line REPL enabled we'll launch it if there are no input files.
IEnumerable<Diagnostic> errors = compiler.Arguments.Errors;
if (!hasScriptFiles)
{
errors = errors.Concat(new[] { Diagnostic.Create(compiler.MessageProvider, compiler.MessageProvider.ERR_NoScriptsSpecified) });
}
if (compiler.ReportErrors(errors, consoleOutput, errorLogger))
{
return CommonCompiler.Failed;
}
// arguments are always available when executing script code:
Debug.Assert(compiler.Arguments.ScriptArguments != null);
var compilation = compiler.CreateCompilation(consoleOutput, touchedFilesLogger: null, errorLogger: errorLogger);
if (compilation == null)
{
return CommonCompiler.Failed;
}
byte[] compiledAssembly;
using (MemoryStream output = new MemoryStream())
{
EmitResult emitResult = compilation.Emit(output);
if (compiler.ReportErrors(emitResult.Diagnostics, consoleOutput, errorLogger))
{
return CommonCompiler.Failed;
}
compiledAssembly = output.ToArray();
}
var assembly = Assembly.Load(compiledAssembly);
return Execute(assembly, compiler.Arguments.ScriptArguments.ToArray());
}
示例8: RunInteractiveCore
/// <summary>
/// csi.exe and vbi.exe entry point.
/// </summary>
private int RunInteractiveCore(ErrorLogger errorLogger)
{
Debug.Assert(_compiler.Arguments.IsInteractive);
var sourceFiles = _compiler.Arguments.SourceFiles;
if (sourceFiles.IsEmpty && _compiler.Arguments.DisplayLogo)
{
_compiler.PrintLogo(_console.Out);
}
if (_compiler.Arguments.DisplayHelp)
{
_compiler.PrintHelp(_console.Out);
return 0;
}
SourceText code = null;
IEnumerable<Diagnostic> errors = _compiler.Arguments.Errors;
if (!sourceFiles.IsEmpty)
{
if (sourceFiles.Length > 1 || !sourceFiles[0].IsScript)
{
errors = errors.Concat(new[] { Diagnostic.Create(_compiler.MessageProvider, _compiler.MessageProvider.ERR_ExpectedSingleScript) });
}
else
{
var diagnostics = new List<DiagnosticInfo>();
code = _compiler.ReadFileContent(sourceFiles[0], diagnostics);
errors = errors.Concat(diagnostics.Select(Diagnostic.Create));
}
}
if (_compiler.ReportErrors(errors, _console.Out, errorLogger))
{
return CommonCompiler.Failed;
}
var cancellationToken = new CancellationToken();
var hostObject = new CommandLineHostObject(_console.Out, _objectFormatter, cancellationToken);
hostObject.Args = _compiler.Arguments.ScriptArguments.ToArray();
var scriptOptions = GetScriptOptions(_compiler.Arguments);
if (sourceFiles.IsEmpty)
{
RunInteractiveLoop(scriptOptions, hostObject);
}
else
{
RunScript(scriptOptions, code.ToString(), sourceFiles[0].Path, hostObject, errorLogger);
}
return hostObject.ExitCode;
}
示例9: Compile
public CompileResult Compile(string source, CompileContext context)
{
var sourceFile = context.RootDirectory.GetFile(context.SourceFilePath);
importedFilePaths = new HashedSet<string>();
var parser = new Parser
{
Importer = new Importer(new CassetteLessFileReader(sourceFile.Directory, importedFilePaths))
};
var errorLogger = new ErrorLogger();
var engine = new LessEngine(
parser,
errorLogger,
configuration.MinifyOutput,
configuration.Debug,
configuration.DisableVariableRedefines,
configuration.DisableColorCompression,
configuration.KeepFirstSpecialComment,
configuration.Plugins);
string css;
try
{
css = engine.TransformToCss(source, sourceFile.FullPath);
}
catch (Exception ex)
{
throw new LessCompileException(
string.Format("Error compiling {0}{1}{2}", context.SourceFilePath, Environment.NewLine, ex.Message),
ex
);
}
if (errorLogger.HasErrors)
{
var exceptionMessage = string.Format(
"Error compiling {0}{1}{2}",
context.SourceFilePath,
Environment.NewLine,
errorLogger.ErrorMessage
);
throw new LessCompileException(exceptionMessage);
}
else
{
return new CompileResult(css, importedFilePaths);
}
}
示例10: GetPostedSector
protected static Sector GetPostedSector(HttpRequest request, ErrorLogger errors)
{
Sector sector = null;
if (request.Files["file"] != null && request.Files["file"].ContentLength > 0)
{
HttpPostedFile hpf = request.Files["file"];
sector = new Sector(hpf.InputStream, hpf.ContentType, errors);
}
else if (!String.IsNullOrEmpty(request.Form["data"]))
{
string data = request.Form["data"];
sector = new Sector(data.ToStream(), MediaTypeNames.Text.Plain, errors);
}
else if (new ContentType(request.ContentType).MediaType == MediaTypeNames.Text.Plain)
{
sector = new Sector(request.InputStream, MediaTypeNames.Text.Plain, errors);
}
else
{
return null;
}
if (request.Files["metadata"] != null && request.Files["metadata"].ContentLength > 0)
{
HttpPostedFile hpf = request.Files["metadata"];
string type = SectorMetadataFileParser.SniffType(hpf.InputStream);
Sector meta = SectorMetadataFileParser.ForType(type).Parse(hpf.InputStream);
sector.Merge(meta);
}
else if (!String.IsNullOrEmpty(request.Form["metadata"]))
{
string metadata = request.Form["metadata"];
string type = SectorMetadataFileParser.SniffType(metadata.ToStream());
var parser = SectorMetadataFileParser.ForType(type);
using (var reader = new StringReader(metadata))
{
Sector meta = parser.Parse(reader);
sector.Merge(meta);
}
}
return sector;
}
示例11: Compile
public string Compile(string source, IFile sourceFile)
{
var parser = new Parser
{
Importer = new Importer(new CassetteLessFileReader(sourceFile.Directory))
};
var errorLogger = new ErrorLogger();
var engine = new LessEngine(parser, errorLogger, false);
var css = engine.TransformToCss(source, sourceFile.FullPath);
if (errorLogger.HasErrors)
{
throw new LessCompileException(errorLogger.ErrorMessage);
}
else
{
return css;
}
}
示例12: ExecuteNonQuery
// Execute an update, delete, or insert command
// and return the number of affect rows
public static int ExecuteNonQuery(DbCommand command)
{
// the number of affected rows
int affectedRows = -1;
// Execute the command making sure the connection gets closed in the end
try {
command.Connection.Open();
// Execute the command and get the number of affected rows
affectedRows = command.ExecuteNonQuery();
} catch (Exception ex) {
// Log eventual errors and rethrow them
ErrorLogger error = new ErrorLogger();
error.ErrorLog(HttpContext.Current.Server.MapPath("Logs/ExecuteNonQueryErrorLog"), ex.Message);
throw;
} finally {
// Close the connection
command.Connection.Close();
}
return affectedRows;
}
示例13: Parse
public override void Parse(TextReader reader, WorldCollection worlds, ErrorLogger errors)
{
int lineNumber = 0;
for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
{
++lineNumber;
if (line.Length == 0)
continue;
switch (line[0])
{
case '#': break; // comment
case '$': break; // route
case '@': break; // subsector
default:
ParseWorld(worlds, line, lineNumber, errors ?? worlds.ErrorList);
break;
}
}
}
示例14: CreateCompilation
public override Compilation CreateCompilation(TextWriter consoleOutput, TouchedFileLogger touchedFilesLogger, ErrorLogger errorLogger)
{
Compilation = base.CreateCompilation(consoleOutput, touchedFilesLogger, errorLogger);
return Compilation;
}
示例15: ReloadScripts
/// <summary>
///
/// </summary>
public static bool ReloadScripts()
{
if (SceneManager.GameProject == null) return false;
lock (locker)
{
try
{
if (File.Exists(SceneManager.GameProject.ProjectPath + @"\_Scripts.csproj"))
File.Delete(SceneManager.GameProject.ProjectPath + @"\_Scripts.csproj");
//search for .sln and .csproj files
foreach (string filename in Directory.GetFiles(SceneManager.GameProject.ProjectPath))
{
if (System.IO.Path.GetExtension(filename).ToLower().Equals(".csproj"))
{
UserPreferences.Instance.ProjectCsProjFilePath = filename;
}
else if (System.IO.Path.GetExtension(filename).ToLower().Equals(".sln"))
{
UserPreferences.Instance.ProjectSlnFilePath = filename;
}
}
// Check if scripts were removed:
bool removed = false;
string projectFileName = UserPreferences.Instance.ProjectCsProjFilePath;
XmlDocument doc = new XmlDocument();
doc.Load(projectFileName);
while (doc.GetElementsByTagName("ItemGroup").Count < 2)
doc.GetElementsByTagName("Project").Item(0).AppendChild(doc.CreateElement("ItemGroup"));
foreach (XmlNode _node in doc.GetElementsByTagName("ItemGroup").Item(1).ChildNodes)
{
if (_node.Name.ToLower().Equals("compile"))
{
if (!File.Exists(SceneManager.GameProject.ProjectPath + "\\" + _node.Attributes.GetNamedItem("Include").Value))
{
doc.GetElementsByTagName("ItemGroup").Item(1).RemoveChild(_node);
removed = true;
}
}
}
if (removed)
doc.Save(projectFileName);
string tmpProjectFileName = SceneManager.GameProject.ProjectPath + @"\_Scripts.csproj";
string hash = string.Empty;
hash = GibboHelper.EncryptMD5(DateTime.Now.ToString());
//try
//{
/* Change the assembly Name */
doc = new XmlDocument();
doc.Load(projectFileName);
doc.GetElementsByTagName("Project").Item(0).ChildNodes[0]["AssemblyName"].InnerText = hash;
doc.Save(tmpProjectFileName);
//}
//catch (Exception ex)
//{
// Console.WriteLine(ex.Message);
//}
/* Compile project */
ProjectCollection projectCollection = new ProjectCollection();
Dictionary<string, string> GlobalProperty = new Dictionary<string, string>();
GlobalProperty.Add("Configuration", SceneManager.GameProject.Debug ? "Debug" : "Release");
GlobalProperty.Add("Platform", "x86");
//FileLogger logger = new FileLogger() { Parameters = @"logfile=C:\gibbo_log.txt" };
logger = new ErrorLogger();
BuildRequestData buildRequest = new BuildRequestData(tmpProjectFileName, GlobalProperty, null, new string[] { "Build" }, null);
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(
new BuildParameters(projectCollection)
{
BuildThreadPriority = System.Threading.ThreadPriority.AboveNormal,
Loggers = new List<ILogger>() { logger }
},
buildRequest);
//foreach (var tr in logger.Errors)
//{
// Console.WriteLine(tr.ToString());
//}
//Console.WriteLine(buildResult.OverallResult);
string cPath = SceneManager.GameProject.ProjectPath + @"\bin\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + hash + ".dll";
if (File.Exists(cPath))
{
/* read assembly to memory without locking the file */
//.........这里部分代码省略.........