internal MultilingualContent GetContentStore(string Lang, bool createNew = false) { MultilingualContent content = null; if (!string.IsNullOrEmpty(Lang)) { content = this.Contents.Find(o => o.Lang == Lang); } if (content == null && this.Contents.Count() > 0) { content = this.Contents.Find(o => string.IsNullOrEmpty(o.Lang)); } if (content == null && this.Contents.Count() > 0 && !string.IsNullOrEmpty(Lang)) { string lower = Lang.ToLower(); if (lower.Length > 2) { lower = lower.Substring(0, 2); } foreach (var item in this.Contents) { if (item.Lang.ToLower().StartsWith(lower)) { return(item); } } } if (content == null) { if (createNew) { content = new MultilingualContent(); content.Lang = Lang; this.Contents.Add(content); } else if (this.Contents.Count() > 0) { return(this.Contents.First()); } } return(content); }
public object GetValue(string FieldName, string Lang = null) { if (FieldName == null) { return(null); } string lower = FieldName.ToLower(); if (lower == "userkey") { return(this.UserKey); } else if (lower == "id") { return(this.Id); } else if (lower == "order" || lower == "sequence") { return(this.Order); } MultilingualContent content = GetContentStore(Lang); if (content != null && content.FieldValues.ContainsKey(FieldName)) { return(content.FieldValues[FieldName]); } if (lower == "folderid") { return(this.FolderId); } else if (lower == "parentid") { return(this.ParentId); } else if (lower == "contenttypeid") { return(this.ContentTypeId); } else if (lower == "online") { return(this.Online); } else if (lower == "lastmodify" || lower == "lastmodified") { return(this.LastModified); } foreach (var item in this.Contents) { if (item.FieldValues.ContainsKey(FieldName)) { return(item.FieldValues[FieldName]); } } return(null); }