public async Task <ActionResult> PutHomeAdminMember(Guid componentId, [FromBody] MemberComponent exchangeComponent) { if (componentId != exchangeComponent.ComponentId) { throw new ArgumentException($"componentId != component.Id"); } var configComponent = await _mongoComponentStrategy.GetAsync(_componentHome); var linkVisitor = _visitorFactory.GetBuilder <LinkComponentRelationVisitorBuilder>().Build(); exchangeComponent.Accept(linkVisitor); var flatVisitor = _visitorFactory.GetBuilder <FlatComponentVisitorBuilder>().Build(); configComponent.Accept(flatVisitor); var targetComponent = flatVisitor.FlatElements[componentId]; var exchangeVisitor = _visitorFactory.GetBuilder <ExchangeComponentVisitorBuilder>().SetExchangeComponent(targetComponent, exchangeComponent).Build(); configComponent.Accept(exchangeVisitor); await _mongoComponentStrategy.SetAsync(_componentHome, configComponent); return(Ok()); }
public void AddPaths() { SINT mtype = SINT.Type; PresetDB db = new PresetDB("Preset", new IntegerLiteral(7)); STRUCT type = new STRUCT(); ARRAY subtype = new ARRAY() { MemberType = new STRING() { Capacity = new IntegerLiteral(6) } }; subtype.Limits.Add(new ArrayLimits(new IntegerLiteral(-4), new IntegerLiteral(7))); type.Members.Add(new StructMember() { Name = "Int", MemberType = UINT.Type }); type.Members.Add(new StructMember() { Name = "Array", MemberType = subtype }); PathComponent path = new MemberComponent("Foo", type); db.AddPath(path, new MultilingualText("en-US", "Comment"), "89"); }
public static MemberComponent Fake(this MemberComponent component, Dictionary <string, DefinedCondition> conditions, int subNumber) { var fake = component.Fake(conditions); for (int i = 0; i < subNumber; i++) { fake.AddLowerLayer(component.Fake(conditions)); } return(fake); }
public async Task <ActionResult <ConfigPageComponent> > FakeMemberComponent() { var builder = Builders <ConfigCondition> .Filter; var filter = builder.Empty; var defineds = await _configConditsStrategy.GetAsync(_conditionDefined); var conditions = defineds.ToDictionary(d => d.Key, d => d.Defined); var page = new MemberComponent().Fake(conditions); return(Ok(page)); }
public static Component Fake(this Component component, Dictionary <string, DefinedCondition> conditions, int subNumber) { if (RandomBoolean) { component = new MemberComponent().Fake(conditions, subNumber); } else { component = new LazyComponent().Fake(conditions); } return(component); }
public MemberController(MemberQueryComponent memberQueryComponent, MemberComponent memberComponent) { this._memberQueryComponent = memberQueryComponent; this._memberComponent = memberComponent; }
public static MemberComponent Fake(this MemberComponent component, Dictionary <string, DefinedCondition> conditions) { var fake = component.Clone(); fake.ComponentId = SequentialGuid.NewGuid(); if (RandomBoolean) { fake.Condition = new ReferenceCondition { Ref = conditions.RandomPeek().Key }; } else { fake.Condition = new DefinedCondition().Fake(); } if (RandomBoolean) { fake.Title = RandomName; } if (RandomBoolean) { fake.SubTitle = RandomName; } if (RandomBoolean) { fake.Description = RandomName; } if (RandomBoolean) { var style = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(assembly => assembly.GetTypes()) .Where(type => type.IsSubclassOf(typeof(Style))).RandomPeek(); fake.Style = (Style)Activator.CreateInstance(style); } if (RandomBoolean) { fake.Additional = new MemberAdditional().Fake(); } if (RandomBoolean) { var reaction = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(assembly => assembly.GetTypes()) .Where(type => type.IsSubclassOf(typeof(Reaction))).RandomPeek(); fake.Reaction = (Reaction)Activator.CreateInstance(reaction); fake.Reaction.Path = RandomName; } while (RandomBoolean) { var media = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(assembly => assembly.GetTypes()) .Where(type => type.IsSubclassOf(typeof(Media))).RandomPeek(); var instance = (Media)Activator.CreateInstance(media); instance.Title = RandomName; instance.Path = RandomName; fake.Medias.Add(instance); } if (RandomBoolean) { fake.Operations.Add(new MoreOperation()); } return(fake); }
public async Task <ActionResult> PutHomeAdminSubComponentsMember(Guid componentId, [FromBody] MemberComponent component) { if (componentId == component.ComponentId) { throw new ArgumentException($"componentId == component.Id"); } var configComponent = await _mongoComponentStrategy.GetAsync(_componentHome); var flatVisitor = _visitorFactory.GetBuilder <FlatComponentVisitorBuilder>().Build(); configComponent.Accept(flatVisitor); var targetComponent = flatVisitor.FlatElements[componentId]; if (!(targetComponent is CompositeComponent)) { throw new InvalidOperationException("只有 Composite 支援增加 SubComponent。"); } if (flatVisitor.FlatElements.ContainsKey(component.ComponentId)) { throw new InvalidOperationException("ConfigComponent 已具備 component.ComponentId 請使用新的 component.ComponentId。"); } var linkVisitor = _visitorFactory.GetBuilder <LinkComponentRelationVisitorBuilder>().Build(); component.Accept(linkVisitor); (targetComponent as CompositeComponent).AddLowerLayer(component); await _mongoComponentStrategy.SetAsync(_componentHome, configComponent); return(Ok()); }