private PageComponentBase CreatePageComponent(PageComponentDto dto) { List <PageComponentBase> childPageComponents = new List <PageComponentBase>(); if (dto.PageComponents != null) { foreach (var item in dto.PageComponents) { childPageComponents.Add(CreatePageComponent(item)); } } PageComponentBase pageComponent = null; if (dto.ComponentType == "CompositeComponent") { pageComponent = new CompositeComponent(dto.Name) { PageComponents = childPageComponents }; } else { pageComponent = new ContentLeafComponent(dto.Name); } pageComponent.Sign = dto.Sign; pageComponent.Col = dto.Col; pageComponent.Height = dto.Height; pageComponent.Padding = dto.Padding; return(pageComponent); }
public CancelDocumentRequest(IComponentSerializer serializaer) : base(serializaer) { _cancelNode = new CompositeComponent("CANCELA"); _registryNode = new CompositeComponent("REGISTRO"); _cancelNode.AddComponent(_registryNode); }
public static void TestComposite() { Console.WriteLine("-- TEST COMPOSITE --"); ICompositeCompenent main = new CompositeComponent("TOP"); ICompositeCompenent componentA = new CompositeComponent("ComponentA"); ICompositeCompenent componentB = new CompositeComponent("ComponentB"); ICompositeCompenent componentC = new CompositeComponent("ComponentC"); ICompositeCompenent leaf = new Leaf("Leaf"); ICompositeCompenent leafA1 = new Leaf("LeafA1"); ICompositeCompenent leafA2 = new Leaf("LeafA2"); ICompositeCompenent leafB1 = new Leaf("LeafB1"); ICompositeCompenent leafC1 = new Leaf("LeafC1"); componentA.Add(leafA1); componentA.Add(leafA2); componentB.Add(leafB1); componentB.Add(componentC); componentC.Add(leafC1); main.Add(leaf); main.Add(componentA); main.Add(componentB); main.Display(0); }
public void Calculate(Component visitable) { if (!(visitable is SingleComponent)) { CompositeComponent compositeNode = visitable as CompositeComponent; if (compositeNode is Negation) { Calculate(compositeNode.LeftNode); compositeNode.Evaluate(this); } else if (compositeNode != null) { Calculate(compositeNode.LeftNode); Calculate(compositeNode.RightNode); compositeNode.Evaluate(this); } } else { if (visitable is Variable) { BinaryTree.PropositionalVariables.Variables.Add(visitable as Variable); } } }
public static ISerializableComponent ToSerializableComponent(this IZelerisModel obj, string rootName) { var type = obj.GetType(); var properties = type.GetProperties(); ISerializableComponent _root = new CompositeComponent(rootName); foreach (var prop in properties) { var value = prop.GetValue(obj); if (value == null) { continue; } var jsonProperty = prop.GetCustomAttributes(true).Where(c => c.GetType() == typeof(JsonPropertyAttribute)).FirstOrDefault() as JsonPropertyAttribute; if (jsonProperty == null) { continue; } var name = jsonProperty.PropertyName; ISerializableComponent node = new NodeComponent(name, value.ToString()); _root.AddComponent(node); } return(_root); }
public DocumentTrackingRequest(IComponentSerializer serializaer) : base(serializaer) { _document = new CompositeComponent("DOCUMENTO"); _registry = new CompositeComponent("REGISTRO"); _document.AddComponent(_registry); }
public override Component DoGet(int objectId, Component modifier) { CompositeComponent compositeModifier = (CompositeComponent)DoFindRoot(modifier); int?index = TravelTreeAndReturnIndex(objectId, compositeModifier); return((index != null) ? compositeModifier.GetComponent((int)index) : null); }
public void AddComponent(int bindingID, CompositeComponent component) { if (!Bindings.ContainsKey(bindingID)) { Bindings.Add(bindingID, new List <CompositeComponent>()); } Bindings[bindingID].Add(component); }
private PageComponentBase CreatePageComponent(PageComponentDto dto) { PageComponentBase pageComponent = null; if (dto.IsCompositeComponentType()) { pageComponent = new CompositeComponent(dto.Name); } else if (dto.IsPageLeafComponentType()) { pageComponent = new PageLeafComponent(dto.Name) { PageLeafSetting = _objectMapper.Map <PageLeafSetting>(dto.PageLeafSetting) }; } else if (dto.IsMenuComponentType()) { pageComponent = new MenuComponent(dto.Name) { MenuName = dto.MenuName }; } else { pageComponent = new LeafComponent(dto.Name); } pageComponent.ComponentOSType = ComponentOSType.CreateOSType(dto.OS); pageComponent.Sign = dto.Sign; pageComponent.ParentSign = dto.ParentSign; pageComponent.PageComponentBaseSetting = new PageComponentBaseSetting( dto.PageComponentBaseSetting.SortIndex, dto.PageComponentBaseSetting.Width, dto.PageComponentBaseSetting.Height, dto.PageComponentBaseSetting.Padding, dto.PageComponentBaseSetting.Margin, dto.PageComponentBaseSetting.BackgroundImage, dto.PageComponentBaseSetting.BackgroundColor, dto.PageComponentBaseSetting.ClassName ); var pageComponentSettings = new List <PageComponentSetting>(); foreach (var item in dto.PageComponentSettings ?? new List <PageComponentSettingDto>()) { PageComponentSetting pageComponentSetting = new PageComponentSetting() { Name = item.Name, DisplayName = item.DisplayName, SingleDatas = _objectMapper.Map <List <SingleSettingData> >(item.SingleDatas) }; ((List <SingleSettingData>)pageComponentSetting.SingleDatas).ForEach(item => item.Id = 0); pageComponentSettings.Add(pageComponentSetting); } pageComponent.PageComponentSettings = pageComponentSettings; return(pageComponent); }
public DocumentInformationRequest(IComponentSerializer serializaer) : base(serializaer) { _document = new CompositeComponent("DOCUMENTO"); _registry = new CompositeComponent("REGISTRO"); _header = new CompositeComponent("CABECERA"); _registry.AddComponent(_header); _document.AddComponent(_registry); }
public void Calculate(Component visitable) { if (visitable is SingleComponent) { return; } CompositeComponent compositeNode = visitable as CompositeComponent; compositeNode?.Evaluate(this); }
public TruthTable(BinaryTree binaryTree) { this.BinaryTree = binaryTree; this.SimplifiedRows = new List <Row>(); this.RootOfBinaryTree = binaryTree.Root as CompositeComponent; DistinctPropositionalVariables = binaryTree.PropositionalVariables.Get_Distinct_PropositionalVariables(); NumberOfVariables = DistinctPropositionalVariables.Length; FillAndCalculateRows(); SimplifyRows(); }
private PageComponentBase CreatePageComponent(PageComponentDto dto) { PageComponentBase pageComponent = null; if (dto.ComponentType == "CompositeComponent") { pageComponent = new CompositeComponent(dto.Name); } else if (dto.ComponentType == "PageLeafComponent") { pageComponent = new PageLeafComponent(dto.Name); if (dto.TargetPageId.HasValue) { var page = _repository.FirstOrDefault(dto.TargetPageId.Value); ((PageLeafComponent)pageComponent).TargetPage = page; } } else { pageComponent = new LeafComponent(dto.Name); } pageComponent.Sign = dto.Sign; pageComponent.ParentSign = dto.ParentSign; pageComponent.PageComponentBaseSetting = new PageComponentBaseSetting( dto.PageComponentBaseSetting.SortIndex, dto.PageComponentBaseSetting.Col, dto.PageComponentBaseSetting.Height, dto.PageComponentBaseSetting.Padding, dto.PageComponentBaseSetting.Margin, dto.PageComponentBaseSetting.BackgroundColor, dto.PageComponentBaseSetting.ClassName ); var pageComponentSettings = new List <PageComponentSetting>(); foreach (var item in dto.PageComponentSettings ?? new List <PageComponentSettingDto>()) { PageComponentSetting pageComponentSetting = new PageComponentSetting() { Name = item.Name, DisplayName = item.DisplayName, Field1 = item.Field1, Field2 = item.Field2, Field3 = item.Field3, Field4 = item.Field4, Field5 = item.Field5 }; pageComponentSettings.Add(pageComponentSetting); } pageComponent.PageComponentSettings = pageComponentSettings; return(pageComponent); }
public void AlternativeComposite() { var composite = new CompositeComponent(); composite.AddComponent(new Leaf()); composite.AddComponent(new SecondTypeOfLeaf()); composite.AddComponent(new AThirdLeafType()); component = composite; composite.Something(); }
public override void DoModify(Component c, int objectId, Component modifier) { CompositeComponent compositeModifier = (CompositeComponent)DoFindRoot(modifier); int?index = TravelTreeAndReturnIndex(objectId, compositeModifier); if (index != null) { compositeModifier.SetComponent((int)index, c); } }
static void Main(string[] args) { var composite = new CompositeComponent(); composite.Add(new Leaf()); composite.Add(new SecondTypeOfLeaf()); composite.Add(new AThirdLeafType()); component = composite; component.Something(); }
public IComponentSerializer Serialize(CompositeComponent component) { _builder.Append($"<{component.Name}>"); foreach (var child in component.Children) { child.Serialize(this); } _builder.Append($"</{component.Name}>"); return(this); }
static void Main(string[] args) { var composite = new CompositeComponent(); composite.AddComponent(new Leaf()); composite.AddComponent(new Leaf()); composite.AddComponent(new Leaf()); component = composite; composite.Something(); }
private void PopulatePictureBoxWithImages(CompositeComponent root) { _graphImages.Add(0, GenerateGraphVizBinaryGraph(root.GraphVizFormula, "Normal")); _graphImages.Add(1, GenerateGraphVizBinaryGraph(root.Nand.GraphVizFormula, "NAND")); _graphImages.Add(2, GenerateGraphVizBinaryGraph(_truthTable.DnfNormalBinaryTree?.Root.GraphVizFormula, "DNF")); LbImageName.Text = _graphImages[0].Substring(0, _graphImages[0].IndexOf(".")); PbBinaryGraph.ImageLocation = _graphImages[0]; BtnImagePrevious.Enabled = true; Btn_Image_Open.Enabled = true; BtnImageNext.Enabled = true; _imageIndex = 0; }
private int?TravelTreeAndReturnIndex(int objectId, CompositeComponent compositeModifier) { foreach (var c in compositeModifier.GetComponents()) { if (c.IsObjectIdEquals(objectId)) { return(compositeModifier.GetComponents().IndexOf(c)); } if (c.IsComposite()) { c.Get(objectId); } } return(null); }
public void AccountInfo_Composite_Serialization() { ISerializableComponent accountInfo = new CompositeComponent("INFOCUENTA"); IComponentSerializer serializer = new XmlComponentSerializer(); accountInfo .AddComponent(new NodeComponent("USUARIO", "user")) .AddComponent(new NodeComponent("CLAVE", "123")) .AddComponent(new NodeComponent("FECHA", "yyyyMMddHHmmss")); var result = accountInfo.Serialize(serializer).Build(); string expectedResult = "<INFOCUENTA><USUARIO>user</USUARIO><CLAVE>123</CLAVE><FECHA>yyyyMMddHHmmss</FECHA></INFOCUENTA>"; Assert.AreEqual(result, expectedResult); }
/// <summary> /// Parses the binding xml element and adds the input info to the component, and adds the component to the querybuilder /// </summary> /// <param name="bindingElement">XML Binding Element</param> /// <param name="bindingTarget">Target to attach inputs to</param> private void parseBinding(XElement bindingElement, CompositeComponent bindingTarget) { int bindingID = int.Parse(bindingElement.Attribute("ID").Value); if (bindingElement.Element("Inputs") != null) { foreach (XElement bindingInput in bindingElement.Element("Inputs").Elements()) { if (bindingInput.Attribute("Name") != null && bindingInput.Attribute("Value") != null) { bindingTarget.Inputs.Add(bindingInput.Attribute("Name").Value, bindingInput.Attribute("Value").Value); } } } queryBuilder.AddComponent(bindingID, bindingTarget); }
public void Create_Component_From_Document_Object() { Document document = new Document(); document.DocumentDateTime = DateTime.Now; document.ServiceDateTime = DateTime.Now; document.BillingAddress = "Calle Bronce"; document.BillingCity = "Madrid"; document.BillingClientName = "Alejandro"; CompositeComponent component = (CompositeComponent)document.ToSerializableComponent("CABECERA"); Assert.IsNotNull(component); Assert.AreEqual("CABECERA", component.Name); Assert.AreEqual(5, component.Children.Count); }
public override void DoRemove(Component c, int objectId, Component modifier) { CompositeComponent compositeModifier = (CompositeComponent)DoFindRoot(modifier); if (compositeModifier.IsObjectIdEquals(objectId)) { compositeModifier.RemoveComponent(c); c.SetAncestor(null); } else { foreach (var item in compositeModifier.GetComponents()) { item.Remove(c, objectId); } } }
private void PopulateTextBoxesWithValues(CompositeComponent root) { _formulaGenerator.Calculate(root); _formulaGenerator.Calculate(root.Nand); Tb_InfixFormula_Normal.Enabled = true; Tb_InfixFormula_Nandified.Enabled = true; Tb_InfixFormula_Normal.Text = root.InFixFormula; Tb_InfixFormula_Nandified.Text = root.Nand.InFixFormula; Tb_TruthTableHashCode.Text = $@"{_truthTable.GetHexadecimalHashCode()}"; TbNormalDNF.Text = $@"{Dnf.DnfFormula(_truthTable.DnfNormalComponents)}"; TbSimplifiedDNF.Text = $@"{Dnf.DnfFormula(_truthTable.DnfSimplifiedComponents)}"; TbPropositionalVariables.Text = _binaryTreeNormal.PropositionalVariables.Get_Distinct_PropositionalVariables() .SelectMany(x => x.Symbol.ToString()).Aggregate("", (current, next) => current + next); BtnParseRecursively.BackColor = _truthTable.GetHexadecimalHashCode() == _truthTableNand.GetHexadecimalHashCode() ? Color.MediumSeaGreen : Color.PaleVioletRed; }
static void Main(string[] args) { component = new DecoratorComponent(new ConcreteComponent()); component.Something(); var composite = new CompositeComponent(); composite.AddComponent(new Leaf()); composite.AddComponent(new SecondTypeOfLeaf()); composite.AddComponent(new AThirdLeafType()); composite.AddComponent(new Leaf()); component = composite; component.Something(); var calculator = new LoggingCalculator(new ConcreteCalculator()); calculator.Add(129, 234); //var profilingComponent = new ProfilingComponent(new SlowComponent(), new LoggingStopwatch(new StopwatchAdapter())); //profilingComponent.Something(); var asyncComponent = new AsyncComponent(new ProfilingComponent(new SlowComponent(), new LoggingStopwatch(new StopwatchAdapter()))); asyncComponent.Something(); Console.ReadLine(); Console.WriteLine("five"); Console.ReadLine(); Console.WriteLine("four"); Console.ReadLine(); Console.WriteLine("three"); Console.ReadLine(); Console.WriteLine("two"); Console.ReadLine(); Console.WriteLine("one"); Console.ReadLine(); Console.WriteLine("zero -- program exited."); }
public void Create_Component_From_Lineitem_Object() { LineItem item = new LineItem { ClientId = "123", OwnerId = "456", ProductCode = "789", ProductStateId = "1", QCStateId = "2", Quantity = 2 }; CompositeComponent component = (CompositeComponent)item.ToSerializableComponent("LINEA"); Assert.IsNotNull(component); Assert.AreEqual("LINEA", component.Name); Assert.AreEqual(6, component.Children.Count); }
static void Main(string[] args) { var composite = new CompositeComponent("First Composite Component"); composite.AddComponent(new Leaf()); composite.AddComponent(new Leaf()); composite.AddComponent(new Leaf()); // Fluent version since AddComponent return "this" composite = new CompositeComponent("Second Composite Component") .AddComponent(new Leaf()) .AddComponent(new SecondTypeOfLeaf()) .AddComponent(new AThirdTypeOfLeaf()) .AddComponent(composite); // First will now become child of Second IComponent component = composite; component.Something(); // Will call Something() for all objects in the tree }
public void Calculate(Component visitable) { if (!(visitable is SingleComponent)) { CompositeComponent compositeNode = visitable as CompositeComponent; if (compositeNode is Negation) { Calculate(compositeNode.LeftNode); compositeNode.Evaluate(this); } else if (compositeNode != null) { Calculate(compositeNode.RightNode); Calculate(compositeNode.LeftNode); compositeNode.Evaluate(this); } } }
/// <summary> /// Method for create more intuitive infix formula based on the type of left and right node. /// </summary> /// <param name="visitable">The upper root of component</param> /// <param name="connective">The character of connective</param> private void GenerateInfixGenerator(CompositeComponent visitable, char connective) { if (visitable.LeftNode is CompositeComponent && visitable.RightNode is CompositeComponent) { visitable.InFixFormula = $"({visitable.LeftNode.InFixFormula}){connective}({visitable.RightNode.InFixFormula})"; } else if (visitable.LeftNode is CompositeComponent) { visitable.InFixFormula = $"({visitable.LeftNode.InFixFormula}){connective}{visitable.RightNode.InFixFormula}"; } else if (visitable.RightNode is CompositeComponent) { visitable.InFixFormula = $"{visitable.LeftNode.InFixFormula}{connective}({visitable.RightNode.InFixFormula})"; } else { visitable.InFixFormula = $"{visitable.LeftNode.InFixFormula}{connective}{visitable.RightNode.InFixFormula}"; } }