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
using( var reader = new CsvReader(new StringReader(data))) | |
{ | |
while (reader.Read()) | |
{ | |
var rec = reader.CurrentRecord; | |
} | |
} |
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 int LastIndexOf(string value) | |
{ | |
return this.LastIndexOf(value, this.Length - 1, this.Length, string.LegacyMode ? StringComparison.Ordinal : StringComparison.CurrentCulture); | |
} | |
// What is LegacyMode ? | |
internal static bool LegacyMode | |
{ | |
get |
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
// Problematic short example | |
var q = db.X.All().Join(db.Y, XId: db.X.Id).WithY(); | |
// Problematic real example | |
var q = db.List.All().Join(db.Question, ListId: db.List.Id).WithQuestion(); | |
// Suggested short example | |
var q = db.X.All().Join(db.Y, XId: db.X.Id ).With(db.X.Y); |
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
private HttpContext _context; | |
public void ProcessRequest(HttpContext context) | |
{ | |
_context = context; | |
context.Response.ContentType = "text/plain"; | |
context.Response.Buffer = false; | |
foreach (var d in Document.GetRootDocuments()) |
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 interface IBaseItem | |
{ | |
int Id { get; set; } | |
string Name { get; set; } | |
} | |
public class ItemsIndex : AbstractIndexCreationTask<IBaseItem> | |
{ | |
public ItemsIndex() | |
{ |
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
@{ | |
var root = Model.Content.AncestorOrSelf(1); | |
var repository = root.Sibling("Repository"); | |
} |
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
// It's properly more correct to search on NodeTypeAlias (or DocumentTypeAlias as it's called in the new API) | |
var criteria = ExamineManager.Instance.DefaultSearchProvider.CreateSearchCriteria().NodeTypeAlias("Testimonial").Compile(); | |
var testimonials = Model.Content.AncestorOrSelf(1) | |
.Sibling("Repository") | |
.Search(criteria); | |
// Or perhaps even just this, no traversing is need, performance should be the same, as nodes in Lucene aren't hierarchically stored | |
var criteria = ExamineManager.Instance.DefaultSearchProvider.CreateSearchCriteria().NodeTypeAlias("Testimonial").Compile(); | |
var testimonials = Model.Content.Search(criteria); |
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
// Typed | |
var ids = Model.Content.GetPropertyValue<string>("mNTP", true, "").Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries); | |
var items = Umbraco.TypedContent(ids); | |
// Dynamic | |
@if (CurrentPage.HasValue("mNTP", true)) | |
{ | |
var ids = CurrentPage._mNTP.Split(','); | |
var items = Umbraco.Content(ids); | |
foreach (var item in items) |
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
/* From web.config or some other config place */ | |
<add key="CreateContentSortOrder" value="Content page,Section page,some other page type name" /> | |
/* In /umbraco/create/content.ascx - put the code in the bottom */ | |
<% | |
var createContentSortOrder = ConfigurationManager.AppSettings["CreateContentSortOrder"]; | |
if (!String.IsNullOrWhiteSpace(createContentSortOrder)) | |
{ %> | |
<script type="text/javascript"> | |
$(function () { |
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 Global : UmbracoApplication | |
{ | |
protected override void OnApplicationStarting(object sender, EventArgs e) | |
{ | |
base.OnApplicationStarting(sender, e); | |
DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(ListingPageController)); | |
} | |
} |