private static DashboardFederationDataSource CreateFederatedDataSource(DashboardSqlDataSource sqlDS, DashboardExcelDataSource excelDS, DashboardObjectDataSource objDS, DashboardJsonDataSource jsonDS) { DashboardFederationDataSource federationDataSource = new DashboardFederationDataSource("Federated Data Source"); Source sqlSource = new Source("sqlSource", sqlDS, "SQL Orders"); Source excelSource = new Source("excelSource", excelDS, ""); Source objectSource = new Source("objectSource", objDS, ""); SourceNode jsonSourceNode = new SourceNode(new Source("json", jsonDS, "")); // Join SelectNode joinQuery = sqlSource.From() .Select("OrderDate", "ShipCity", "ShipCountry") .Join(excelSource, "[excelSource.OrderID] = [sqlSource.OrderID]") .Select("CategoryName", "ProductName", "Extended Price") .Join(objectSource, "[objectSource.Country] = [excelSource.Country]") .Select("Country", "UnitPrice") .Build("Join query"); federationDataSource.Queries.Add(joinQuery); // Union and UnionAll UnionNode queryUnionAll = sqlSource.From().Select("OrderID", "OrderDate").Build("OrdersSqlite") .UnionAll(excelSource.From().Select("OrderID", "OrderDate").Build("OrdersExcel")) .Build("OrdersUnionAll"); queryUnionAll.Alias = "Union query"; UnionNode queryUnion = sqlSource.From().Select("OrderID", "OrderDate").Build("OrdersSqlite") .Union(excelSource.From().Select("OrderID", "OrderDate").Build("OrdersExcel")) .Build("OrdersUnion"); queryUnion.Alias = "UnionAll query"; federationDataSource.Queries.Add(queryUnionAll); federationDataSource.Queries.Add(queryUnion); // Transformation TransformationNode unfoldNode = new TransformationNode(jsonSourceNode) { Alias = "Unfold", Rules = { new TransformationRule { ColumnName = "Products", Alias = "Product", Unfold = true, Flatten = false } } }; TransformationNode unfoldFlattenNode = new TransformationNode(jsonSourceNode) { Alias = "Unfold and Flatten", Rules = { new TransformationRule { ColumnName = "Products", Unfold = true, Flatten = true } } }; federationDataSource.Queries.Add(unfoldNode); federationDataSource.Queries.Add(unfoldFlattenNode); return(federationDataSource); }
private void onSelectNode(T node) { if (SelectNode != null) { SelectNode.Invoke(node); } }
/// <summary> /// generate object this will ignore properties is not in select nodes /// </summary> /// <param name="currentData"></param> /// <param name="selectNode"></param> /// <returns></returns> private object GenerateObject(object currentData, SelectNode selectNode) { if (selectNode == null || currentData == null || GeneratedObjects.Contains(currentData)) { return(currentData); } else if (currentData is IEnumerable) { return(GenerateArrayObject(currentData, selectNode)); } GeneratedObjects.Add(currentData); Type type = currentData.GetType(); System.Reflection.PropertyInfo[] properties = type.GetProperties(); //get list of properties and set default value if that is not in select node for (int i = 0; i < properties.Length; i++) { System.Reflection.PropertyInfo property = properties[i]; string propertyName = property.Name.ToLower(); if (selectNode.Properties.TryGetValue(propertyName, out List <SelectNode> nodes)) { if (nodes == null || nodes.Count == 0) { continue; } object value = property.GetValue(currentData); GenerateObject(value, nodes.FirstOrDefault()); } else { property.SetValue(currentData, Shared.Converters.DataExchangeConverter.GetDefault(property.PropertyType)); } } return(currentData); }
static void OpenWindow() { SelectNode window = (SelectNode)GetWindow(typeof(SelectNode)); window.minSize = new Vector2(350, 500); window.Show(); }
public void ParseItemSelect_Complex() { var cols = SelectNode.FromString("first, second (thing, another2(id, config_id)), no_paren, third (stuff), another (id)"); var expected = new string[] { "first", "second", "no_paren", "third", "another" }; CollectionAssert.AreEqual(expected, cols.Select(c => c.Name).ToArray()); }
void SelectClause(QueryNode parent) { QueryNode node, expr = null; node = new SelectNode(); parent.Add(node); while (StartOf(1)) { if (la.kind == 3 || la.kind == 4) { ReservedWords(); return; } if (la.kind == 5) { Get(); } if (la.kind == 11) { SelectStar(); node.Add(new LeafNode(t.val)); } else if (StartOf(2)) { ExprSpec(out expr); node.Add(expr); } else { SynErr(23); } } }
/// <summary> /// 選択ノードの位置を更新し、選択されている楽曲を更新する。 /// </summary> void UpdateSelectedMusic() { // 中央に一番近いノードを探す。 float min = worldWidth; SelectNode centerNode = null; foreach (var node in nodes) { float x = Mathf.Abs(node.X); if (x < min) { min = x; centerNode = node; } } if (centerNode != null) { // 位置を中央に揃える。 MoveNodesX(-centerNode.X); // 現在選択中の楽曲データを更新する。 selectedMusic = centerNode.Md; // 画面の楽曲データ情報を更新する。 musicInfo.SetInfo(selectedMusic); } }
public void ParseItemSelect_Simple() { var cols = SelectNode.FromString("config_id,name,is_relationship"); var expected = new string[] { "config_id", "name", "is_relationship" }; CollectionAssert.AreEqual(expected, cols.Select(c => c.Name).ToArray()); }
static public void Create_Select_Query_For_Excel_Source() { FederationDataSource federation = new FederationDataSource(); Source source = new Source("excelSource", CreateExcelDataSource("SalesPerson.xlsx", "Data")); var sourceNode = new SourceNode(source, "Orders"); var query = new SelectNode(sourceNode) { Alias = "excel", Expressions = { new SelectColumnExpression(sourceNode, "OrderID"), new SelectColumnExpression(sourceNode, "OrderDate"), new SelectColumnExpression(sourceNode, "Sales Person"), new SelectColumnExpression(sourceNode, "ProductName"), new SelectColumnExpression(sourceNode, "Extended Price") }, FilterString = "[Orders.CategoryName] = ?cat", }; federation.Queries.Add(query); federation.Fill(new[] { new DevExpress.DataAccess.Sql.QueryParameter("cat", typeof(string), "Seafood") }); var result = ((IListSource)federation).GetList() as IResultSet; DataSource = result[0]; }
public void StatefulSelectNode() { var moqAction1 = new Mock <IBehaviourTreeNode <int, int> >(); var moqAction2 = new Mock <IBehaviourTreeNode <int, int> >(); var selectNode = new SelectNode <int, int>("test", true); int func1CallCount = 0, func2CallCount = 0; moqAction1.Setup(f => f.Compile()).Returns((tick, state) => { func1CallCount++; return(BehaviourTreeState.Failure); }); moqAction2.Setup(f => f.Compile()).Returns((tick, state) => { func2CallCount++; return(BehaviourTreeState.Running); }); selectNode.AddNode(moqAction1.Object); selectNode.AddNode(moqAction2.Object); var func = selectNode.Compile(); var callResult1 = func(0, 0); var callResult2 = func(0, 0); Assert.Equal(BehaviourTreeState.Running, callResult1); Assert.Equal(BehaviourTreeState.Running, callResult2); Assert.Equal(1, func1CallCount); Assert.Equal(2, func2CallCount); }
public void SelectNode_UnionWith() { var node = SelectNode.FromString("first,second(thing,another2(id,config_id))"); var add = SelectNode.FromString("second(thing,another2(id,config_id)),no_paren,third(stuff),another(id)"); node.UnionWith(add); Assert.AreEqual("first,second(thing,another2(id,config_id)),no_paren,third(stuff),another(id)", node.ToString()); }
public DbSet <T> SelectCol(Func <DbSet <T>, Column> colHandler) { var col = colHandler(this); var selectNode = new SelectNode(col); this.selectNode.Add(selectNode); return(this); }
public virtual void Visit(SelectNode node) { foreach (var field in node.Fields) { field.Accept(this); } node.Accept(Visitor); }
public void CompileWithoutSetup() { var selectNode = new SelectNode <int, int>("test", false); Assert.Throws <BehaviourTreeCompilationException>(() => { selectNode.Compile(); }); }
/// <summary> /// 选择节点测试 /// </summary> private void SelectNodeTest() { SelectNode selectNode = new SelectNode(); selectNode.AddChild(move); selectNode.AddChild(idel); Debug.Log("选择节点执行结果为:" + selectNode.DoAction()); }
public static BehaviourTreeNodeSequenceBuilder <TTickData, TState> Select <TTickData, TState>( this BehaviourTreeNodeSequenceBuilder <TTickData, TState> builder, string name, Action <BehaviourTreeNodeSequenceBuilder <TTickData, TState> > config, bool stateful = false) { var newNode = new SelectNode <TTickData, TState>(name, stateful); return(builder.Add(newNode, config)); }
public void Visit(SelectNode node) { SetQueryPart(QueryPart.Select); foreach (var field in node.Fields) { field.Accept(this); } node.Accept(_visitor); }
public void ParseItemSelect_ComplexFunction() { const string str = "major_rev,owned_by_id[is_not_null()],managed_by_id[is_not_null()],team_id,id"; var cols = SelectNode.FromString(str); Assert.AreEqual(str, cols.ToString()); var expected = new string[] { "major_rev", "owned_by_id", "managed_by_id", "team_id", "id" }; CollectionAssert.AreEqual(expected, cols.Select(c => c.Name).ToArray()); }
public void ParseItemSelect_ConfigPath() { const string str = "id|related_id(id)|created_by_id,config_id"; var cols = SelectNode.FromString("id|related_id(id)|created_by_id,config_id"); Assert.AreEqual(str, cols.ToString()); var expected = new string[] { "id", "related_id", "created_by_id", "config_id" }; var names = cols.SelectMany(c => c).Select(c => c.Name).ToArray(); CollectionAssert.AreEqual(expected, names); }
public override void Visit(SelectNode node) { var fields = new FieldNode[node.Fields.Length]; for (int i = 0, j = fields.Length - 1; i < fields.Length; i++, j--) { fields[j] = (FieldNode)Nodes.Pop(); } ChangedSelect = new SelectNode(fields); }
public virtual void Visit(SelectNode node) { var fields = new FieldNode[node.Fields.Length]; for (var i = node.Fields.Length - 1; i >= 0; --i) { fields[i] = (FieldNode)Nodes.Pop(); } Nodes.Push(new SelectNode(fields.ToArray())); }
public static void Select <TTickData, TState> (this BehaviourTreeNodeDecoratorBuilder <TTickData, TState> builder, string name, Action <BehaviourTreeNodeSequenceBuilder <TTickData, TState> > config, bool stateful = false ) { var newNode = new SelectNode <TTickData, TState>(name, stateful); builder.Decorate(newNode, config); }
public static XmlNode First(this XmlNodeList list, SelectNode sn) { foreach (XmlNode n in list) { if (sn(n)) { return(n); } } return(null); }
public virtual void Visit(SelectNode node) { var fields = new FieldNode[node.Fields.Length]; for (var i = node.Fields.Length - 1; i >= 0; --i) { fields[i] = (FieldNode)Nodes.Pop(); } TopNode topNode = node.Top != null ? (TopNode)Nodes.Pop() : null; Nodes.Push(new SelectNode(topNode, fields.ToArray())); }
void InputListener_MouseDown(EditorMouseEvent mouseEvent) { _editorView.GraphView.GetNodeViewUnderMouse((view) => { if (_editorView.GraphView.WindowSize.Contains(mouseEvent.Position)) { var node = view != null ? view.Node : null; SelectNode.InvokeSafe(node); } }); _editorView.GraphView.GetPinViewUnderMouse((view) => MouseDownOverPin.InvokeSafe(view.Pin)); }
public void AddSelectAttribute() { var item = ElementFactory.Local.FromXml("<Item type='Part' pagesize='250' action='get'></Item>").AssertItem(); var selectNode = new SelectNode(); selectNode.EnsurePath("id"); selectNode.EnsurePath("state"); selectNode.EnsurePath("keyed_name"); item.Select().Set(selectNode); Assert.AreEqual("id,state,keyed_name", item.Select().Value); }
void Write(SelectNode select) { #region contract if(select == null) throw new ArgumentNullException("select"); #endregion _sql.Write(new[] {'\t'}, 0, _indent); _sql.Write("select "); foreach(SelectColumnNode expr in select.SelectColumns) { this.Write(expr); _sql.Write(", "); } _sql.GetStringBuilder().Length -= 2; }
/// <summary> /// generate object that is in list /// </summary> /// <param name="data"></param> /// <param name="selectNode"></param> /// <returns></returns> private object GenerateArrayObject(object data, SelectNode selectNode) { if (GeneratedObjects.Contains(data)) { return(data); } GeneratedObjects.Add(data); foreach (object item in (IEnumerable)data) { GenerateObject(item, selectNode); } return(data); }
internal override Expression CreateExpression(ParameterExpression sourceData, ParameterExpression param) { SelectNode select = FindChild <SelectNode>(1); Debug.Assert(select != null); Debug.Assert(select.IsScalarHint, "record set sub queries don't work yet"); Type queryType = typeof(ScalarQuery <,>).MakeGenericType(param.Type, typeof(object)); ICompile query = (ICompile)Activator.CreateInstance(queryType, "subquery"); query.Compile(select); return(Expression.Call(Expression.Constant(query), query.GetType().GetMethod("Evaluate"), sourceData)); }
public void VerifyStatelessExecution(IEnumerable <IBehaviourTreeNode <int, int> > nodes, BehaviourTreeState expectedState) { var selectNode = new SelectNode <int, int>("test", false); foreach (var node in nodes) { selectNode.AddNode(node); } var func = selectNode.Compile(); var state = func(0, 0); Assert.Equal(expectedState, state); }
public void test_success_at_first() { var testNode = new SelectNode( "testNode", new List <IBehaviorNode>() { successNode1.Object, successNode2.Object }); testNode.Execute(bContext.Object); successNode1.Verify(x => x.Execute(bContext.Object)); successNode2.Verify(x => x.Execute(bContext.Object), Times.Never); }