refactor: apply default vs transform to xproj

refactor(spa-services): clean code

refactor(node-services): clean code, extract classes nto separate files

refactor(angular-services): prime cache cleanup
This commit is contained in:
Andrei Tserakhau
2016-05-23 11:28:42 +03:00
parent 2c35945562
commit 95cba7f5dd
32 changed files with 621 additions and 448 deletions

View File

@@ -2,16 +2,20 @@ using System;
using System.IO;
using System.Reflection;
namespace Microsoft.AspNetCore.NodeServices {
public static class EmbeddedResourceReader {
public static string Read(Type assemblyContainingType, string path) {
namespace Microsoft.AspNetCore.NodeServices
{
public static class EmbeddedResourceReader
{
public static string Read(Type assemblyContainingType, string path)
{
var asm = assemblyContainingType.GetTypeInfo().Assembly;
var embeddedResourceName = asm.GetName().Name + path.Replace("/", ".");
using (var stream = asm.GetManifestResourceStream(embeddedResourceName))
using (var sr = new StreamReader(stream)) {
using (var sr = new StreamReader(stream))
{
return sr.ReadToEnd();
}
}
}
}
}

View File

@@ -1,39 +1,45 @@
using System;
using System.IO;
namespace Microsoft.AspNetCore.NodeServices {
namespace Microsoft.AspNetCore.NodeServices
{
// Makes it easier to pass script files to Node in a way that's sure to clean up after the process exits
public sealed class StringAsTempFile : IDisposable {
public string FileName { get; private set; }
public sealed class StringAsTempFile : IDisposable
{
private bool _disposedValue;
public StringAsTempFile(string content) {
this.FileName = Path.GetTempFileName();
File.WriteAllText(this.FileName, content);
}
private void DisposeImpl(bool disposing)
public StringAsTempFile(string content)
{
if (!_disposedValue) {
if (disposing) {
// TODO: dispose managed state (managed objects).
}
File.Delete(this.FileName);
_disposedValue = true;
}
FileName = Path.GetTempFileName();
File.WriteAllText(FileName, content);
}
public string FileName { get; }
public void Dispose()
{
DisposeImpl(true);
GC.SuppressFinalize(this);
}
~StringAsTempFile() {
DisposeImpl(false);
private void DisposeImpl(bool disposing)
{
if (!_disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects).
}
File.Delete(FileName);
_disposedValue = true;
}
}
~StringAsTempFile()
{
DisposeImpl(false);
}
}
}
}