private static void ListReactive(IESpace module) //only for debugging and experimentation purposes, to be deleted { BlocksReative reactiveBlocks = new BlocksReative(); reactiveBlocks.ListBlocksAndScreens(module); }
protected override void CreateIf2(IContent p, ILink l, IESpace espace) { var name = GetDestinationName(l); var screens = espace.GetAllDescendantsOfType <IMobileScreen>(); foreach (IMobileScreen s in screens) { var exists = s.GetAllDescendantsOfType <ILink>().SingleOrDefault(k => k.ObjectKey.Equals(l.ObjectKey)); if (exists != default) { CreateDataActionScreen(espace, s, l); } } var blocks = espace.GetAllDescendantsOfType <IMobileBlock>(); foreach (IMobileBlock s in blocks) { var exists = s.GetAllDescendantsOfType <ILink>().SingleOrDefault(k => k.ObjectKey.Equals(l.ObjectKey)); if (exists != default) { CreateDataActionBlock(espace, s, l); } } var instanceIf = p.CreateWidget <OutSystems.Model.UI.Mobile.Widgets.IIfWidget>(); instanceIf.SetCondition($"GetToggles.IsDataFetched and GetToggles.FT_{name}"); instanceIf.Name = $"If_FT_{name}"; instanceIf.TrueBranch.Copy(l); l.Delete(); }
public void InsertIf(IESpace espace, List <IKey> keys) { var links = espace.GetAllDescendantsOfType <GLink>().Where(s => keys.Contains(GetDestination(s).ObjectKey)); links = InsertIfplus(espace, keys, links); ToggleEntities t = new ToggleEntities(); ToggleAction a = new ToggleAction(); var entity = t.GetTogglesEntity(espace); var action = a.GetToggleAction(espace); foreach (GLink l in links.ToList()) { if (l.Parent is GParent1) { var parent = (GParent1)l.Parent; var rec = t.CreateRecord(entity, $"FT_{espace.Name}_{GetDestinationName(l)}", $"FT_{GetDestinationName(l)}", espace); CreateIf(parent, l, espace); } else if (l.Parent is GParent2) { var parent = (GParent2)l.Parent; var rec = t.CreateRecord(entity, $"FT_{espace.Name}_{GetDestinationName(l)}", $"FT_{GetDestinationName(l)}", espace); CreateIf2(parent, l, espace); } else { Console.WriteLine($"Bypass Link {l} because parent is not IPlaceholderContentWidget or IContainerWidget. Parent is {l.Parent}"); } } }
private static void ListTraditional(IESpace module) //only for debugging and experimentation purposes, to be deleted { BlocksTraditional tradicionalBlocks = new BlocksTraditional(); tradicionalBlocks.ListBlocksAndScreens(module); }
public IAction CreateToggleAction(IESpace espace) { var action = espace.CreateServerAction("GetFTValue"); action.Function = true; ConstructAction(espace, action); return(action); }
public virtual void InsertIf(IESpace espace, List <IKey> keys) { var actions = espace.GetAllDescendantsOfType <IAction>().Where(s => keys.Contains(s.ObjectKey)); ToggleEntities t = new ToggleEntities(); ToggleAction a = new ToggleAction(); var entity = t.GetTogglesEntity(espace); var action = a.GetToggleAction(espace); var lib = espace.References.Single(a => a.Name == "FeatureToggle_Lib"); var getToggleAction = (IServerActionSignature)lib.ServerActions.Single(a => a.Name == "FeatureToggle_IsOn"); foreach (IAction sa in actions.ToList()) { var rec = t.CreateRecord(entity, $"FT_{espace.Name}_{sa.Name}", $"FT_{sa.Name}", espace); var newAction = (IAction)espace.Copy(sa); var oldname = sa.Name.ToString(); sa.Name = $"FT_{oldname}"; newAction.Name = oldname; var nodes = sa.Nodes; foreach (IActionNode n in nodes.ToList()) { n.Delete(); } var start = sa.CreateNode <IStartNode>(); var getToggle = sa.CreateNode <IExecuteServerActionNode>($"FT_{oldname}_IsOn").Below(start); var ifToggle = sa.CreateNode <IIfNode>().Below(getToggle); var doAction = sa.CreateNode <IExecuteServerActionNode>().ToTheRightOf(ifToggle); var end = sa.CreateNode <IEndNode>().Below(doAction); getToggle.Action = getToggleAction; var keyParam = getToggleAction.InputParameters.Single(s => s.Name == "FeatureToggleKey"); getToggle.SetArgumentValue(keyParam, $"Entities.FeatureToggles.FT_{espace.Name}_{oldname}"); var modParam = getToggleAction.InputParameters.Single(s => s.Name == "ModuleName"); getToggle.SetArgumentValue(modParam, "GetEntryEspaceName()"); start.Target = getToggle; ifToggle.SetCondition($"FT_{oldname}_IsOn.IsOn"); ifToggle.FalseTarget = end; getToggle.Target = ifToggle; doAction.Action = newAction; doAction.Target = end; ifToggle.TrueTarget = doAction; foreach (IInputParameter i in newAction.InputParameters) { doAction.SetArgumentValue(i, i.Name); } if (newAction.OutputParameters.Count() != 0) { var assign = sa.CreateNode <IAssignNode>().Below(doAction); end.Below(assign); foreach (IOutputParameter o in sa.OutputParameters) { assign.CreateAssignment(o.Name, $"{doAction.Name}.{o.Name}"); } doAction.Target = assign; assign.Target = end; } } }
public void GetDiffElements(IESpace old, IESpace newe, String newOrAltered) { var listOldServerActions = old.GetAllDescendantsOfType <IServerAction>(); var listNewServerActions = newe.GetAllDescendantsOfType <IServerAction>(); List <IServerAction> difActions = new List <IServerAction>(); List <IKey> difActionKeys = new List <IKey>(); foreach (IServerAction actions in listNewServerActions) { var skey = actions.ObjectKey; var modDate = ((IFlow)actions).LastModifiedDate; if (newOrAltered.Equals("new")) { var olds = listOldServerActions.SingleOrDefault(s => (s.ObjectKey.Equals(skey))); if (olds == null) { difActions.Add(actions); difActionKeys.Add(actions.ObjectKey); } } else { var olds = listOldServerActions.SingleOrDefault(s => (s.ObjectKey.Equals(skey) && ((IFlow)s).LastModifiedDate.Equals(modDate))); var olds2 = listOldServerActions.SingleOrDefault(s => (s.ObjectKey.Equals(skey))); if (olds == null && olds2 != null) { difActions.Add(actions); difActionKeys.Add(actions.ObjectKey); } } } if (newOrAltered.Equals("new")) { Console.WriteLine("\nNew Actions:"); } else if (newOrAltered.Equals("altered")) { Console.WriteLine("\nAltered Actions:"); } foreach (IServerAction actions in difActions) { Console.WriteLine(actions); } if (newOrAltered.Equals("new")) { if (difActionKeys.Count() != 0) { InsertIf(newe, difActionKeys); //CreateScreenPrep(newe, difScreensKeys); } } }
public void GetDiffElements(IESpace old, IESpace newe, string newOrAltered) { var listOldScreens = old.GetAllDescendantsOfType <GScreen>(); var listNewScreens = newe.GetAllDescendantsOfType <GScreen>(); List <GScreen> difScreens = new List <GScreen>(); List <IKey> difScreensKeys = new List <IKey>(); foreach (GScreen screen in listNewScreens) { var skey = screen.ObjectKey; var modDate = screen.LastModifiedDate; if (newOrAltered.Equals("new")) { var olds = listOldScreens.SingleOrDefault(s => (s.ObjectKey.Equals(skey))); if (olds == null) { difScreens.Add(screen); difScreensKeys.Add(screen.ObjectKey); } } else { var olds = listOldScreens.SingleOrDefault(s => (s.ObjectKey.Equals(skey) && s.LastModifiedDate.Equals(modDate))); var olds2 = listOldScreens.SingleOrDefault(s => (s.ObjectKey.Equals(skey))); if (olds == null && olds2 != null) { difScreens.Add(screen); difScreensKeys.Add(screen.ObjectKey); } } } if (newOrAltered.Equals("new")) { Console.WriteLine("\nNew Screens:"); } else if (newOrAltered.Equals("altered")) { Console.WriteLine("\nAltered Screens:"); } foreach (GScreen screen in difScreens) { Console.WriteLine(screen); } if (newOrAltered.Equals("new")) { if (difScreensKeys.Count() != 0) { InsertIf(newe, difScreensKeys); CreateScreenPrep(newe, difScreensKeys); } } }
protected override void CreateIf2(IContainerWidget p, ILinkWidget l, IESpace espace) { var instanceIf = p.CreateWidget <OutSystems.Model.UI.Web.Widgets.IIfWidget>(); instanceIf.SetCondition($"GetFTValue(Entities.FeatureToggles.FT_{espace.Name}_{GetDestinationName(l)})"); instanceIf.Name = $"If_FT_{GetDestinationName(l)}"; instanceIf.TrueBranch.Copy(l); l.Delete(); }
public virtual void GetDiffElements(IESpace old, IESpace newe, string newOrAltered) { var listOldBlocks = old.GetAllDescendantsOfType <GBlock>(); var listNewBlocks = newe.GetAllDescendantsOfType <GBlock>(); List <GBlock> difBlocks = new List <GBlock>(); List <IKey> difBlocksKeys = new List <IKey>(); foreach (GBlock block in listNewBlocks) { var bkey = block.ObjectKey; var modDate = block.LastModifiedDate; if (newOrAltered.Equals("new")) { var oldb = listOldBlocks.SingleOrDefault(s => (s.ObjectKey.Equals(bkey))); if (oldb == null) { difBlocks.Add(block); difBlocksKeys.Add(block.ObjectKey); } } else { var oldb = listOldBlocks.SingleOrDefault(s => (s.ObjectKey.Equals(bkey) && s.LastModifiedDate.Equals(modDate))); var oldb2 = listOldBlocks.SingleOrDefault(s => (s.ObjectKey.Equals(bkey))); if (oldb == null && oldb2 != null) { difBlocks.Add(block); difBlocksKeys.Add(block.ObjectKey); } } } if (newOrAltered.Equals("new")) { Console.WriteLine("\nNew Blocks:"); } else if (newOrAltered.Equals("altered")) { Console.WriteLine("\nAltered Blocks:"); } foreach (GBlock block in difBlocks) { Console.WriteLine(block); } if (newOrAltered.Equals("new")) { if (difBlocksKeys.Count() != 0) { InsertIf(newe, difBlocksKeys); } } }
private static bool IsTraditional(IESpace module) { var themes = module.GetAllDescendantsOfType <IWebTheme>(); bool any = false; foreach (IWebTheme tm in themes) { any = true; } return(any); }
public IStaticEntity GetTogglesEntity(IESpace espace) { var entity = (IStaticEntity)espace.Entities.SingleOrDefault(s => s.Name == TogglesEntity); if (entity == default) { return(CreateEntity(espace)); } else { return(entity); } }
protected override IEnumerable <ILinkWidget> InsertIfplus(IESpace espace, List <IKey> keys, IEnumerable <ILinkWidget> links) { var links2 = espace.GetAllDescendantsOfType <ILinkWidget>().Where(s => s.OnClick.Destination is IGoToDestination); foreach (ILinkWidget link in links2) { var dest = (IGoToDestination)link.OnClick.Destination; if (keys.Contains(dest.Destination.ObjectKey)) { links = links.Append(link); } } return(links); }
public void GetAllElements(IESpace newe) { var listBlocks = newe.GetAllDescendantsOfType <GBlock>(); List <IKey> difBlocksKeys = new List <IKey>(); Console.WriteLine("Blocks:"); foreach (GBlock block in listBlocks) { Console.WriteLine(block); difBlocksKeys.Add(block.ObjectKey); } if (difBlocksKeys.Count() != 0) { InsertIf(newe, difBlocksKeys); } }
public void GetAllElements(IESpace newe) { var listactions = newe.GetAllDescendantsOfType <IServerAction>(); List <IKey> actionKeys = new List <IKey>(); Console.WriteLine("Screens:"); foreach (IServerAction action in listactions) { Console.WriteLine(action); actionKeys.Add(action.ObjectKey); } if (actionKeys.Count() != 0) { InsertIf(newe, actionKeys); } }
private IDataAction CreateDataActionBlock(IESpace espace, IMobileBlock sc, ILink l) { var action = sc.GetAllDescendantsOfType <IDataAction>().SingleOrDefault(e => e.Name == "GetToggles"); if (action == default) { action = sc.CreateDataAction(); action.Name = "GetToggles"; var out1 = action.GetAllDescendantsOfType <IOutputParameter>().SingleOrDefault(o => o.Name == "Out1"); out1.Delete(); CreateDataAction(espace, l, action, sc.Name); } else { AddToDataAction(espace, l, action, sc.Name); } return(action); }
public IAction GetToggleAction(IESpace espace) { if (IsTraditional(espace)) { var action = (IServerAction)espace.ServerActions.SingleOrDefault(s => s.Name == "GetFTValue"); if (action == default) { return(CreateToggleAction(espace)); } else { return(action); } } else { return(null); } }
public void GetAllElements(IESpace newe) { var listScreens = newe.GetAllDescendantsOfType <GScreen>(); List <IKey> screensKeys = new List <IKey>(); Console.WriteLine("Screens:"); foreach (GScreen screen in listScreens) { Console.WriteLine(screen); screensKeys.Add(screen.ObjectKey); } if (screensKeys.Count() != 0) { InsertIf(newe, screensKeys); CreateScreenPrep(newe, screensKeys); } }
private void AddToDataAction(IESpace espace, ILink l, IDataAction action, String sname) { var lib = espace.References.Single(a => a.Name == "FeatureToggle_Lib"); var getToggleAction = (IServerActionSignature)lib.ServerActions.Single(a => a.Name == "FeatureToggle_IsOn"); var keyParam = getToggleAction.InputParameters.Single(s => s.Name == "FeatureToggleKey"); var modParam = getToggleAction.InputParameters.Single(s => s.Name == "ModuleName"); var start = action.GetAllDescendantsOfType <IStartNode>().Single(); var assign = action.GetAllDescendantsOfType <IAssignNode>().Single(); var destname = sname; if (l != null) { destname = GetDestinationName(l); } var startTarget = start.Target; var getToggle = action.CreateNode <IExecuteServerActionNode>().Below(start); getToggle.Action = getToggleAction; getToggle.SetArgumentValue(keyParam, $"Entities.FeatureToggles.FT_{espace.Name}_{destname}"); getToggle.SetArgumentValue(modParam, "GetEntryEspaceName()"); getToggle.Name = $"FT_{destname}_IsOn"; var outputparam = action.CreateOutputParameter($"FT_{destname}"); outputparam.DataType = espace.BooleanType; if (assign != null) { assign.CreateAssignment($"FT_{destname}", $"FT_{destname}_IsOn.IsOn"); getToggle.Target = startTarget; } else { assign = action.CreateNode <IAssignNode>().Below(getToggle); assign.CreateAssignment($"FT_{destname}", $"FT_{destname}_IsOn.IsOn"); getToggle.Target = assign; assign.Target = startTarget; } start.Target = getToggle; }
protected override void CreateScreenPrep(IESpace espace, List <IKey> screenskeys) { var screens = espace.GetAllDescendantsOfType <IWebScreen>().Where(s => screenskeys.Contains(s.ObjectKey)); foreach (IWebScreen sc in screens) { var preparation = sc.CreatePreparation(); var start = preparation.CreateNode <IStartNode>(); var ifToggle = preparation.CreateNode <IIfNode>().Below(start); var end = preparation.CreateNode <IEndNode>().Below(ifToggle); ifToggle.SetCondition($"GetFTValue(Entities.FeatureToggles.FT_{espace.Name}_{sc.Name})"); ifToggle.TrueTarget = end; start.Target = ifToggle; var excep = preparation.CreateNode <IRaiseExceptionNode>().ToTheRightOf(ifToggle); excep.SetExceptionMessage("\"Screen not available\""); excep.Exception = espace.GetAllDescendantsOfType <OutSystems.Model.Logic.IException>().Single(sr => sr.ToString().Contains("Abort Activity Change Exception")); ifToggle.FalseTarget = excep; } }
public IStaticEntity CreateEntity(IESpace espace) { var entity = espace.CreateStaticEntity(TogglesEntity); var keyatt = entity.CreateAttribute("Key"); keyatt.DataType = espace.TextType; keyatt.Length = 100; keyatt.IsMandatory = true; var labelatt = entity.CreateAttribute("Label"); keyatt.DataType = espace.TextType; keyatt.Length = 100; keyatt.IsMandatory = true; entity.Public = false; entity.IdentifierAttribute = keyatt; entity.LabelAttribute = labelatt; return(entity); }
public IRecord CreateRecord(IStaticEntity entity, String key, String label, IESpace espace) { IEntityAttribute GetAttribute(string name) => entity.Attributes.Single(a => a.Name == name); var rec = entity.Records; var exists = rec.SingleOrDefault(s => s.ToString().Contains(key)); if (exists == default) { var record = entity.CreateRecord(); record.Identifier = key; var keyatt = GetAttribute("Key"); record.SetAttributeValue(keyatt, $"\"{key}\""); var labelatt = GetAttribute("Label"); record.SetAttributeValue(labelatt, $"\"{label}\""); return(record); } return(null); }
/// <summary> /// only for debugging and experimentation purposes, to be deleted /// </summary> /// <param name="module"></param> public void ListBlocksAndScreens(IESpace module) { var listScreens = module.GetAllDescendantsOfType <GScreen>(); Console.WriteLine("\nScreens:"); foreach (GScreen screen in listScreens) { Console.WriteLine(screen); } var listwebblocks = module.GetAllDescendantsOfType <GBlock>(); Console.WriteLine("\nWebBlocks:"); foreach (GBlock block in listwebblocks) { Console.WriteLine(block); } }
protected override void CreateScreenPrep(IESpace espace, List <IKey> screenskeys) { var screens = espace.GetAllDescendantsOfType <IMobileScreen>().Where(s => screenskeys.Contains(s.ObjectKey)); //var lib = espace.References.Single(a => a.Name == "FeatureToggle_Lib"); //var getToggleAction = (IServerActionSignature)lib.ServerActions.Single(a => a.Name == "FeatureToggle_IsOn"); //var keyParam = getToggleAction.InputParameters.Single(s => s.Name == "FeatureToggleKey"); //var modParam = getToggleAction.InputParameters.Single(s => s.Name == "ModuleName"); foreach (IMobileScreen sc in screens) { var dataaction = CreateDataActionScreen(espace, sc, null); var ongetdata = sc.GetAllDescendantsOfType <IUILifeCycleEvent>().Single(e => e.GetType().ToString().Contains("OnAfterFetch")); IScreenAction action = (IScreenAction)ongetdata.Destination; var oninitaction = sc.CreateScreenAction(); oninitaction.Name = "OnAfterFetch"; var start = oninitaction.CreateNode <IStartNode>(); //var getToggle = oninitaction.CreateNode<IExecuteServerActionNode>().Below(start); var end = oninitaction.CreateNode <IEndNode>(); var name = sc.Name; /*getToggle.Action = getToggleAction; * getToggle.SetArgumentValue(modParam, "GetEntryEspaceName()"); * start.Target = getToggle; * getToggle.Name = $"FT_{name}_IsOn"; * getToggle.SetArgumentValue(keyParam, $"Entities.FeatureToggles.FT_{espace.Name}_{name}");*/ var ifToggle = oninitaction.CreateNode <IIfNode>().Below(start); ifToggle.SetCondition($"GetToggles.FT_{name}"); end.Below(ifToggle); ifToggle.TrueTarget = end; start.Target = ifToggle; var excep = oninitaction.CreateNode <IRaiseExceptionNode>().ToTheRightOf(ifToggle); excep.SetExceptionMessage("\"Screen not available\""); excep.Exception = espace.GetAllDescendantsOfType <OutSystems.Model.Logic.IException>().Single(sr => sr.ToString().Contains("Abort Activity Change Exception")); ifToggle.FalseTarget = excep; ongetdata.Destination = oninitaction; } }
private void ConstructAction(IESpace espace, IAction action) { var ftType = action.CreateInputParameter("FTType"); ftType.DataType = espace.Entities.Single(s => s.Name == TogglesEntity).IdentifierType; ftType.IsMandatory = true; ftType.Description = "Feature Toggle Identifier"; var isOn = action.CreateOutputParameter("IsOn"); isOn.DataType = espace.BooleanType; isOn.SetDefaultValue("False"); isOn.Description = "Feature Toggle Value"; var start = action.CreateNode <IStartNode>(); var executeaction = action.CreateNode <IExecuteServerActionNode>().Below(start); var lib = espace.References.Single(a => a.Name == "FeatureToggle_Lib"); var getToggleAction = (IServerActionSignature)lib.ServerActions.Single(a => a.Name == "FeatureToggle_IsOn");///////////////////////////////////////////// executeaction.Action = getToggleAction; var keyParam = getToggleAction.InputParameters.Single(s => s.Name == "FeatureToggleKey"); executeaction.SetArgumentValue(keyParam, "FTType"); var modParam = getToggleAction.InputParameters.Single(s => s.Name == "ModuleName"); executeaction.SetArgumentValue(modParam, "GetEntryEspaceName()"); start.Target = executeaction; var assign = action.CreateNode <IAssignNode>().Below(executeaction); assign.CreateAssignment("IsOn", "FeatureToggle_IsOn.IsOn"); executeaction.Target = assign; var end = action.CreateNode <IEndNode>().Below(assign); assign.Target = end; }
public virtual void InsertIf(IESpace espace, List <IKey> keys) { var bl = espace.GetAllDescendantsOfType <GObjectSignature>().Where(s => keys.Contains(GetObjectKey(s))); ToggleEntities t = new ToggleEntities(); ToggleAction a = new ToggleAction(); var entity = t.GetTogglesEntity(espace); var action = a.GetToggleAction(espace); foreach (GObjectSignature o in bl.ToList()) { if (o.Parent is GParent) { var parent = (GParent)o.Parent; var rec = t.CreateRecord(entity, $"FT_{espace.Name}_{GetName(o)}", $"FT_{GetName(o)}", espace); CreateIf(parent, o, espace); o.Delete(); } else { Console.WriteLine($"Bypass Block {o} because parent is not IPlaceholderContentWidget. Parent is {o.Parent}"); } } }
private void CreateDataAction(IESpace espace, ILink l, IDataAction oninitaction, String sname) { var start = oninitaction.CreateNode <IStartNode>(); var getToggle = oninitaction.CreateNode <IExecuteServerActionNode>().Below(start); var end = oninitaction.CreateNode <IEndNode>(); var lib = espace.References.Single(a => a.Name == "FeatureToggle_Lib"); var getToggleAction = (IServerActionSignature)lib.ServerActions.Single(a => a.Name == "FeatureToggle_IsOn"); getToggle.Action = getToggleAction; start.Target = getToggle; var keyParam = getToggleAction.InputParameters.Single(s => s.Name == "FeatureToggleKey"); var modParam = getToggleAction.InputParameters.Single(s => s.Name == "ModuleName"); var destname = sname; if (l != null) { destname = GetDestinationName(l); } getToggle.SetArgumentValue(modParam, "GetEntryEspaceName()"); getToggle.SetArgumentValue(keyParam, $"Entities.FeatureToggles.FT_{espace.Name}_{destname}"); getToggle.Name = $"FT_{destname}_IsOn"; var outputparam = oninitaction.CreateOutputParameter($"FT_{destname}"); outputparam.DataType = espace.BooleanType; var assignVar = oninitaction.CreateNode <IAssignNode>().Below(getToggle); assignVar.CreateAssignment($"FT_{destname}", $"FT_{destname}_IsOn.IsOn"); getToggle.Target = assignVar; end.Below(assignVar); assignVar.Target = end; }
protected override void CreateIf(IPlaceholderContentWidget p, IMobileBlockInstanceWidget o, IESpace espace) { var name = GetName(o); var screens = espace.GetAllDescendantsOfType <IMobileScreen>(); foreach (IMobileScreen s in screens) { var exists = s.GetAllDescendantsOfType <IMobileBlockInstanceWidget>().SingleOrDefault(k => k.ObjectKey.Equals(o.ObjectKey)); if (exists != default) { //var localvar = s.CreateLocalVariable($"FT_{name}"); //localvar.DataType = espace.BooleanType; //var oninit = s.GetAllDescendantsOfType<IUILifeCycleEvent>().Single(e => e.GetType().ToString().Contains("OnInitialize")); //IScreenAction action = (IScreenAction)oninit.Destination; var action = s.GetAllDescendantsOfType <IDataAction>().SingleOrDefault(e => e.Name == "GetToggles"); var lib = espace.References.Single(a => a.Name == "FeatureToggle_Lib"); var getToggleAction = (IServerActionSignature)lib.ServerActions.Single(a => a.Name == "FeatureToggle_IsOn"); if (action == default) { var oninitaction = s.CreateDataAction(); oninitaction.Name = "GetToggles"; var out1 = oninitaction.GetAllDescendantsOfType <IOutputParameter>().SingleOrDefault(o => o.Name == "Out1"); out1.Delete(); var outputparam = oninitaction.CreateOutputParameter($"FT_{name}"); outputparam.DataType = espace.BooleanType; var start = oninitaction.CreateNode <IStartNode>(); var getToggle = oninitaction.CreateNode <IExecuteServerActionNode>($"FT_{name}_IsOn").Below(start); var assignVar = oninitaction.CreateNode <IAssignNode>().Below(getToggle); var end = oninitaction.CreateNode <IEndNode>().Below(assignVar); getToggle.Action = getToggleAction; var keyParam = getToggleAction.InputParameters.Single(s => s.Name == "FeatureToggleKey"); getToggle.SetArgumentValue(keyParam, $"Entities.FeatureToggles.FT_{espace.Name}_{name}"); var modParam = getToggleAction.InputParameters.Single(s => s.Name == "ModuleName"); getToggle.SetArgumentValue(modParam, "GetEntryEspaceName()"); start.Target = getToggle; assignVar.CreateAssignment($"FT_{name}", $"FT_{name}_IsOn.IsOn"); getToggle.Target = assignVar; assignVar.Target = end; //oninit.Destination = oninitaction; } else { var outputparam = action.CreateOutputParameter($"FT_{name}"); outputparam.DataType = espace.BooleanType; var start = action.GetAllDescendantsOfType <IStartNode>().Single(); var assign = action.GetAllDescendantsOfType <IAssignNode>().Single(); var getToggle = action.CreateNode <IExecuteServerActionNode>($"FT_{name}_IsOn").Below(start); getToggle.Action = getToggleAction; var keyParam = getToggleAction.InputParameters.Single(s => s.Name == "FeatureToggleKey"); getToggle.SetArgumentValue(keyParam, $"Entities.FeatureToggles.FT_{espace.Name}_{name}"); var modParam = getToggleAction.InputParameters.Single(s => s.Name == "ModuleName"); getToggle.SetArgumentValue(modParam, "GetEntryEspaceName()"); var startTarget = start.Target; assign.CreateAssignment($"FT_{name}", $"FT_{name}_IsOn.IsOn"); getToggle.Target = startTarget; start.Target = getToggle; } } } var instanceIf = p.CreateWidget <IIfWidget>(); instanceIf.SetCondition($"GetToggles.IsDataFetched and GetToggles.FT_{name}"); instanceIf.Name = $"If_FT_{name}"; instanceIf.TrueBranch.Copy(o); }
protected override void CreateIf(IPlaceholderContentWidget p, IWebBlockInstanceWidget o, IESpace eSpace) { ToggleAction a = new ToggleAction(); var action = a.GetToggleAction(eSpace); var instanceIf = p.CreateWidget <IIfWidget>(); instanceIf.SetCondition($"GetFTValue(Entities.FeatureToggles.FT_{eSpace.Name}_{GetName(o)})"); instanceIf.Name = $"If_FT_{GetName(o)}"; instanceIf.TrueBranch.Copy(o); }
protected override IEnumerable <ILink> InsertIfplus(IESpace espace, List <IKey> keys, IEnumerable <ILink> links) { return(links); }