private void RenderConditions(IEnumerable <Item> items) { System.Web.UI.HtmlTextWriter innerOutput = new System.Web.UI.HtmlTextWriter(new System.IO.StringWriter()); foreach (var item in items) { string itemText = GetItemText(item); if (!string.IsNullOrEmpty(itemText)) { var type = ItemScripts.GetGenericType <RuleContext>(item); var rule = ReflectionUtil.CreateObject(type) as IPersonalisationRule; if (rule != null) { var currentValue = global::Sitecore.Context.ClientPage.Request.Cookies[PersonalisationConstants.RequestPrefix + rule.RequestName]; innerOutput.Write("<div style=\"padding:0px 0px 4px 24px\">"); innerOutput.Write(string.Format("<input type=\"checkbox\" id=\"check_{0}\" {1} /> ", item.ID.Guid, currentValue == null ? string.Empty : "checked")); innerOutput.Write(string.Format("<input type=\"hidden\" id=\"request_{0}\" value=\"{1}\" />", item.ID.Guid, rule.RequestName)); RenderText(innerOutput, item.ID.Guid.ToString(), itemText, currentValue == null ? string.Empty : currentValue.Value); innerOutput.Write("</div>"); } } } this.Conditions.InnerHtml = innerOutput.InnerWriter.ToString(); }
private IMultiVariateTestStrategy GetStrategy(Item multiVariateTest) { Assert.ArgumentNotNull(multiVariateTest, "multiVariateTest"); string str = multiVariateTest["Test Strategy"]; if (string.IsNullOrEmpty(str)) { return(this); } Item item = multiVariateTest.Database.GetItem(str); if (item == null) { Log.Error("Multivariate Test Strategy with id {0} not found. Using Random strategy instead.".FormatWith(new object[] { str }), base.GetType()); return(this); } if (!ItemScripts.HasScript(item)) { return(this); } var strategy = ItemScripts.CreateObject(item) as IMultiVariateTestStrategy; if (strategy == null) { Log.Error("Multivariate Test Strategy with id {0} is invalid (returns null). Using Random strategy instead.".FormatWith(new object[] { str }), base.GetType()); strategy = this; } return(strategy); }
public Parser() { foreach (var fileName in fileNames) { string filePath = Path.Combine(Application.streamingAssetsPath, fileName); if (File.Exists(filePath)) { string dataAsJson; switch (fileName) { case @"ItemScript.json": dataAsJson = File.ReadAllText(filePath); loadedDataForItemScripts = JsonUtility.FromJson <ItemScripts>(dataAsJson); break; case @"ScriptOnclick.json": dataAsJson = File.ReadAllText(filePath); loadedDataForScriptOnclicks = JsonUtility.FromJson <ScriptOnclicks>(dataAsJson); break; } } else { Debug.LogError("File Not Exsits"); } } }
public virtual IRuleMacro GetMacro(Type type) { var macroItem = Sitecore.Client.ContentDatabase.GetItem(RuleIds.MacrosesFolder).Axes.SelectSingleItem(this.MacroName); if (macroItem == null) { return(null); } var macro = ItemScripts.CreateObject(macroItem) as IRuleMacro; return(macro); }