/// <summary> /// Flushes all parts in order /// </summary> public void Flush() { try { if (!Monitor.TryEnter(this)) { return; } foreach (var byteCounterStreamPart in Partials.ToArray()) { if (byteCounterStreamPart.State == ByteCounterStreamPartType.Closed) { using (var baseWriterBaseStream = byteCounterStreamPart.BaseStream()) { baseWriterBaseStream.CopyTo(RootPart.BaseStream()); } } Partials.RemoveAt(0); } } finally { if (Monitor.IsEntered(this)) { Monitor.Exit(this); } } }
public BaseController() { partialsVM = new Partials() { Category = db.Categories.ToList(), Contact = db.Contacts.ToList(), Menus = db.Menus.ToList() }; }
string RenderPartial(Token token, MustacheContext ctx, string indent) { string name = token.Name; if (Partials == null) { return(string.Empty); } var partial = string.Empty; if (!Partials.TryGetValue(name, out partial)) { return(string.Empty); } var key = "# partial #" + name + "#" + indent; if (!Cache.ContainsKey(key)) { if (string.IsNullOrEmpty(indent)) { Cache[key] = new MustacheParser().Parse(partial, Delimiter.Default()); } else { var replaced = Regex.Replace(partial, @"^(.+)$", indent + "$1", RegexOptions.Multiline); Cache[key] = new MustacheParser().Parse(replaced, Delimiter.Default()); } } return(RenderTokens(ctx, Cache[key])); }
/// <summary> /// Gets a new Part /// </summary> public IByteCounterStreamPart GetNewPart(Stream withStream) { var partialByteCounterStreamPart = new PartialByteCounterStreamPart(withStream, 2024, Options, this); Partials.Add(partialByteCounterStreamPart); return(partialByteCounterStreamPart); }
private static StringBuilder SetContainer(Partials partials, string resulthtml, bool hascontainer, Container DefaultContrainer = null) { var st = new StringBuilder(); var partialsContainer = partials.Container; if (DefaultContrainer != null) { partialsContainer = DefaultContrainer; } if (partialsContainer == null || !hascontainer) { st.Append(resulthtml); } else { if (partialsContainer.Html == null) { st.Append(resulthtml); } else { var htmltext = partialsContainer.Html; var html = htmltext.Replace("{Body}", resulthtml); st.Append(html.Replace("{title}", partials.Title)); } } return(st); }
/// <inheritdoc /> public MorestachioDocumentInfo GetPartial(string name, ParserOptions parserOptions) { if (Partials.TryGetValue(name, out var documentInfo)) { return(documentInfo); } return(null); }
/// <summary> /// Init partials with basic data /// </summary> private void InitPartials() { foreach (var key in EnumHelper.GetAllValuesAndDescriptions(typeof(DrumKey))) { var partial = new Partial.Partial((DrumKey)key.Value); partial.PropertyChanged += (sender, args) => NotifyOfPropertyChange(partial.Key.ToString()); Partials.Add((DrumKey)key.Value, partial); } }
public bool ModifySupportTypes(IConnectionHandler connectionHandler, IConnectionHandler contentManagerConnection, Guid congressId, SupportType supportType) { var configurationSupportTypeBo = new ConfigurationSupportTypeBO(); var byFilter = configurationSupportTypeBo.Get(connectionHandler, congressId, supportType.Id); if (byFilter == null) { var configurationSupportType = new ConfigurationSupportType { SupportTypeId = supportType.Id, CongressId = congressId }; if (!configurationSupportTypeBo.Insert(connectionHandler, configurationSupportType)) { throw new Exception(Resources.Congress.ErrorInSaveSupporterPartialInConfiguration); } } var partialsTransactionalFacade = ContentManagerComponent.Instance.PartialsTransactionalFacade(contentManagerConnection); var pl = new Partials { Enabled = true, Title = supportType.Title, Url = supportType.PartialUrl(), ContextName = "همایشات", Id = Guid.NewGuid(), OperationId = Radyn.Common.Constants.OperationId.CongressOperationId, RefId = congressId.ToString(), CurrentUICultureName = supportType.CurrentUICultureName }; var firstOrDefault = partialsTransactionalFacade.FirstOrDefault(x => x.Url.ToLower() == pl.Url.ToLower()); if (firstOrDefault != null) { pl.Id = firstOrDefault.Id; if (!partialsTransactionalFacade.Update(pl)) { throw new Exception(Resources.Congress.ErrorInSaveSupporterPartialInConfiguration); } return(true); } if (!partialsTransactionalFacade.Insert(pl)) { throw new Exception(Resources.Congress.ErrorInSaveSupporterPartialInConfiguration); } return(true); }
public static string GetPartialHtmlByUrl(this Controller outcontroller, Partials partials, bool hascontainer = true, Container DefaultContrainer = null) { var resulthtml = string.Empty; if (partials == null) { return(resulthtml); } if (!string.IsNullOrEmpty(partials.Url)) { resulthtml = outcontroller.RadynRenderActionUrl(partials.Url); } var st = SetContainer(partials, resulthtml, hascontainer, DefaultContrainer); return(st.ToString().Length < 10 ? string.Empty : st.ToString()); }
public ActionResult LookUpHtml(Enums.PartialTypes type, string partialId) { Partials partials = new Partials(); switch (type) { case Enums.PartialTypes.ContentManager: { partials.Html = ContentManagerComponent.Instance.ContentFacade.GetHtml(partialId.ToInt(), SessionParameters.Culture); partials.Type = Enums.PartialTypes.ContentManager; break; } case Enums.PartialTypes.Modual: { partials = ContentManagerComponent.Instance.PartialsFacade.Get(partialId); partials.Type = Enums.PartialTypes.Modual; break; } } return(PartialView("PVViewPartialHtml", partials)); }
public ActionResult Create(FormCollection collection) { var partials = new Partials(); try { this.RadynTryUpdateModel(partials); partials.CurrentUICultureName = collection["LanguageId"]; if (ContentManagerComponent.Instance.PartialsFacade.Insert(partials)) { ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Succeed); return(Redirect("~/ContentManager/Partials/Index?selectedId=" + partials.Id)); } ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error); return(Redirect("~/ContentManager/Partials/Index?selectedId=" + partials.Id)); } catch (Exception exception) { ShowExceptionMessage(exception); return(View(partials)); } }
private void TestPartial() { Partials p1 = new Partials (); Partials p2 = new Partials (); p1.Hoge (); p2.Mage (); }