๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void METHOD_SCENARIO_EXPECTATION() | |
{ | |
var path = @"..\..\..\View.spark"; | |
var code = File.ReadAllLines(path); | |
for (int lineNumber = 0; lineNumber < code.Length; lineNumber++) | |
{ | |
var line = code[lineNumber]; | |
var classControlLabel = "class=\"control-label\""; | |
if(line.Contains(classControlLabel)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Easier to just pull the file collection and edit the files documents, just be careful, example: | |
public void SaveMetadata(string id, MetadataJson metadata) | |
{ | |
var gridFs = FilesContext.GetGridFs(); | |
var files = gridFs.Database.GetCollection(gridFs.Settings.FilesCollectionName); | |
var file = files.FindOneById(new BsonObjectId(id)); | |
var metadataDocument = file["metadata"].AsBsonDocument; | |
metadataDocument.Set("comment", metadata.comment ?? string.Empty); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I run across this type of code often (note ASP.Net MVC) | |
[HttpPost] | |
public string Delete(ObjectId id) | |
{ | |
var record = _Database.Get<Record>(id); | |
if (record == null) | |
{ | |
return "No matching record!"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Approved | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual IEnumerable<Entry> Entries { get; set; } | |
} | |
public class Entry | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual Guid Description { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Approved | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual IEnumerable<Guid> EntryIds { get; set; } | |
} | |
// Mapping, Table specifies the table name to use, element specifies the column the Guid is stored in, KeyColumn specifies the foreign key in the table to link back to the parent Approved item | |
HasMany(x => x.EntryIds) | |
.Table("ApprovedEntryIds") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sometimes it's easier to make assumptions about performance as a trade off for simplified code, but why not make it easy to notify us when that assumption is violated? Next step might be StopAndNotify | |
// Usage | |
using (new NotifyIfTakesMoreThan(TimeSpan.FromMinutes(5), "XYZ Import - checking all data instead of more complex code to optimize it")) | |
{ | |
//operation | |
} | |
// Implementation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Setup dependencies for nuget packages" | |
task :dep do | |
package_folder = File.expand_path('src\\packages') | |
packages = FileList["**/packages.config"].map{|f| File.expand_path(f)} | |
packages.each do |file| | |
sh %Q{nuget install #{file} /OutputDirectory #{package_folder}} | |
end | |
end |
NewerOlder