internal void SaveCurrentSliderInfo() { TransformationNode modelTransformation = printerview.ModelTransformation; if (modelTransformation == null) { return; } if (editmode == ModelAdjustmentsDialog.EditMode.Rotation) { modelTransformation.Rotation.X = X_Slider.TrackPosition; modelTransformation.Rotation.Y = Y_Slider.TrackPosition; modelTransformation.Rotation.Z = Z_Slider.TrackPosition; } else if (editmode == ModelAdjustmentsDialog.EditMode.Scale) { modelTransformation.Scale.X = X_Slider.TrackPosition; modelTransformation.Scale.Y = Y_Slider.TrackPosition; modelTransformation.Scale.Z = Z_Slider.TrackPosition; } else { if (editmode != ModelAdjustmentsDialog.EditMode.Translation) { return; } modelTransformation.Translation.X = X_Slider.TrackPosition; modelTransformation.Translation.Y = Y_Slider.TrackPosition; } }
public void UseTranslationSliders() { Height = 126; EnableLinkedScalingControls(false); editmode = ModelAdjustmentsDialog.EditMode.Translation; __processingInput = true; X_Slider.Visible = true; X_Text.Visible = true; XPitch_Text.Visible = false; X_Slider.SetRange(-200f, 200f); X_Slider.PushButtonStep = 10f; X_Slider.RoundingPlace = 2; Y_Slider.Visible = true; Y_Text.Visible = true; YRoll_Text.Visible = false; Y_Slider.SetRange(-200f, 200f); Y_Slider.PushButtonStep = 10f; Y_Slider.RoundingPlace = 2; Z_Slider.Visible = false; Z_Text.Visible = false; ZYaw_Text.Visible = false; Z_Edit.Visible = false; Z_Slider.RoundingPlace = 2; __processingInput = false; TransformationNode modelTransformation = printerview.ModelTransformation; if (modelTransformation == null) { return; } X_Slider.TrackPosition = modelTransformation.Translation.X; Y_Slider.TrackPosition = modelTransformation.Translation.Y; printerview.ObjectTransformed = false; }
public void BindApplyWitGroupByWithDeepNavigationShouldReturnApplyClause() { IEnumerable <QueryToken> tokens = _parser.ParseApply("groupby((MyDog/FastestOwner/FirstName))"); MetadataBinder metadataBiner = new MetadataBinder(_bindingState); ApplyBinder binder = new ApplyBinder(metadataBiner.Bind, _bindingState); ApplyClause actual = binder.BindApply(tokens); Assert.NotNull(actual); TransformationNode transformation = Assert.Single(actual.Transformations); GroupByTransformationNode groupBy = Assert.IsType <GroupByTransformationNode>(transformation); Assert.Equal(TransformationNodeKind.GroupBy, groupBy.Kind); Assert.NotNull(groupBy.GroupingProperties); Assert.Null(groupBy.ChildTransformations); GroupByPropertyNode dogNode = Assert.Single(groupBy.GroupingProperties); Assert.Equal("MyDog", dogNode.Name); Assert.Null(dogNode.Expression); GroupByPropertyNode ownerNode = Assert.Single(dogNode.ChildTransformations); Assert.Equal("FastestOwner", ownerNode.Name); Assert.Null(ownerNode.Expression); GroupByPropertyNode nameNode = Assert.Single(ownerNode.ChildTransformations); Assert.Equal("FirstName", nameNode.Name); Assert.NotNull(nameNode.Expression); Assert.Empty(nameNode.ChildTransformations); }
public void BindApplyWitGroupByWithComplexShouldReturnApplyClause() { IEnumerable <QueryToken> tokens = _parser.ParseApply("groupby((MyAddress/City))"); MetadataBinder metadataBiner = new MetadataBinder(_bindingState); ApplyBinder binder = new ApplyBinder(metadataBiner.Bind, _bindingState); ApplyClause actual = binder.BindApply(tokens); Assert.NotNull(actual); TransformationNode transformation = Assert.Single(actual.Transformations); GroupByTransformationNode groupBy = Assert.IsType <GroupByTransformationNode>(transformation); Assert.Equal(TransformationNodeKind.GroupBy, groupBy.Kind); Assert.Null(groupBy.ChildTransformations); Assert.NotNull(groupBy.GroupingProperties); GroupByPropertyNode addressNode = Assert.Single(groupBy.GroupingProperties); Assert.Equal("MyAddress", addressNode.Name); Assert.Null(addressNode.Expression); GroupByPropertyNode cityNode = Assert.Single(addressNode.ChildTransformations); Assert.Equal("City", cityNode.Name); Assert.NotNull(cityNode.Expression); Assert.Empty(cityNode.ChildTransformations); }
public void BindApplyWitMultipleTokensShouldReturnApplyClause() { IEnumerable <QueryToken> tokens = _parser.ParseApply( "groupby((ID, SSN, LifeTime))/aggregate(LifeTime with sum as TotalLife)/groupby((TotalLife))/aggregate(TotalLife with sum as TotalTotalLife)"); BindingState state = new BindingState(_configuration); MetadataBinder metadataBiner = new MetadataBinder(_bindingState); ApplyBinder binder = new ApplyBinder(metadataBiner.Bind, _bindingState); ApplyClause actual = binder.BindApply(tokens); actual.Should().NotBeNull(); actual.Transformations.Should().HaveCount(4); List <TransformationNode> transformations = actual.Transformations.ToList(); GroupByTransformationNode firstGroupBy = transformations[0] as GroupByTransformationNode; firstGroupBy.Should().NotBeNull(); TransformationNode firstAggregate = transformations[1] as AggregateTransformationNode; firstAggregate.Should().NotBeNull(); TransformationNode scecondGroupBy = transformations[2] as GroupByTransformationNode; scecondGroupBy.Should().NotBeNull(); AggregateTransformationNode scecondAggregate = transformations[3] as AggregateTransformationNode; scecondAggregate.Should().NotBeNull(); }
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); }
public void AttachToParentStoresParent() { var parent = new TransformationNode("parent"); var child = new TransformationNode("child"); child.AttachToParent(parent); Assert.AreSame(parent, child.Parent); }
public void Embark(TransformationNode node) { core.Embark(node); // note directly manipulate the RawValue because we are *NOT* targeting thread safety backlogCount.RawValue++; rateOfEmbark.RawValue++; }
public void Embark(TransformationNode node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } traversal.Enqueue(node); }
private void Translate(TransformationNode transformation) { switch (transformation.Kind) { case TransformationNodeKind.Aggregate: query.Append(ExpressionConstants.KeywordAggregate); break; case TransformationNodeKind.GroupBy: query.Append(ExpressionConstants.KeywordGroupBy); break; case TransformationNodeKind.Filter: query.Append(ExpressionConstants.KeywordFilter); break; case TransformationNodeKind.Compute: query.Append(ExpressionConstants.KeywordCompute); break; default: throw new NotSupportedException("unknown TransformationNodeKind value " + transformation.Kind.ToString()); } query.Append(ExpressionConstants.SymbolOpenParen); GroupByTransformationNode groupByTransformation; AggregateTransformationNode aggTransformation; FilterTransformationNode filterTransformation; ComputeTransformationNode computeTransformation; if ((groupByTransformation = transformation as GroupByTransformationNode) != null) { Translate(groupByTransformation); } else if ((aggTransformation = transformation as AggregateTransformationNode) != null) { Translate(aggTransformation); } else if ((filterTransformation = transformation as FilterTransformationNode) != null) { Translate(filterTransformation); } else if ((computeTransformation = transformation as ComputeTransformationNode) != null) { Translate(computeTransformation); } else { throw new NotSupportedException("unknown TransformationNode type " + transformation.GetType().Name); } query.Append(ExpressionConstants.SymbolClosedParen); }
private string[] GetRouteTo(TransformationNode node) { var stack = new Stack <string>(); do { stack.Push(node.Word); } while ((node = node.Parent) != null); return(stack.ToArray()); }
public void ReattachToParentThrows() { var parent = new TransformationNode("parent"); var newParent = new TransformationNode("newParent"); var child = new TransformationNode("child"); child.AttachToParent(parent); Assert.ThrowsException <InvalidOperationException>(() => child.AttachToParent(parent), "original parent"); Assert.ThrowsException <InvalidOperationException>(() => child.AttachToParent(newParent), "new parent"); }
public void SupportsBlocksThatAreBothSourceAndTarget() { var sourceNode = new OneSourceNode <int>(); var transformationNode = new TransformationNode <int, string>(i => i.ToString()); var targetNode = new OneTargetNode <string>(); LinkNodes(sourceNode, transformationNode, targetNode); sourceNode.Post1(42); Assert.Equal("42", targetNode.EventuallyReceive1()); }
/// <summary> /// Create a GroupByTransformationNode. /// </summary> /// <param name="groupingProperties">A list of <see cref="GroupByPropertyNode"/>.</param> /// <param name="childTransformations">The child <see cref="TransformationNode"/>.</param> /// <param name="source">The <see cref="CollectionNode"/> representing the source.</param> public GroupByTransformationNode( IList<GroupByPropertyNode> groupingProperties, TransformationNode childTransformations, CollectionNode source) { ExceptionUtils.CheckArgumentNotNull(groupingProperties, "groupingProperties"); this.groupingProperties = groupingProperties; this.childTransformations = childTransformations; this.source = source; }
protected virtual void ModulateAndTraverse(TransformationNode node) { int count = 0; foreach (string word in wordModulator.GetModulationsOf(node.Word)) { traversal.Embark(nodeFactory.CreateNode(node, word)); count++; } OnEmbarkedModulationsOf(node.Word, count); }
public TransformationNode CreateNode(TransformationNode precursor, string word) { // can remove this restriction if we want (since the other overload allows it, anyway) if (precursor == null) { throw new ArgumentNullException(nameof(precursor)); } var node = new TransformationNode(word); node.AttachToParent(precursor); return(node); }
private TreeModel buildModel(Man man) { var growNode = new ActionNode <Man>("GrowAgeAndHealth"); var goToWork = new DecisionNode <Man>("DecideIFCanWork"); var startDying = new DecisionNode <Man>("DecideIFDye"); var workHard = new ActionNode <Man>("Work"); var deadNode = new ActionNode <Man>("Dead"); var isSportish = new DecisionNode <Man>("IfSportishContext"); var fromManToSportish = new TransformationNode <Man, Sport>("FromManToSport"); var practiceSport = new ActionNode <Sport>("DoSport"); var sportToMan = new TransformationNode <Sport, Man>("SportToMan"); growNode.AddChild(goToWork); growNode.SetAction(m => { m.Age++; m.Health++; }); goToWork.SetCondition(m => m.Age > 18); goToWork.SetYesChild(workHard); goToWork.SetNoChild(growNode); workHard.AddChild(isSportish); workHard.SetAction(m => { m.Health--; m.Age++; }); isSportish.SetNoChild(startDying); isSportish.SetYesChild(fromManToSportish); isSportish.SetCondition(m => m.Age < 60); fromManToSportish.AddChild(practiceSport); fromManToSportish.SetTranslator(m => new Sport(m.Age)); practiceSport.SetAction(s => s.Do()); practiceSport.AddChild(sportToMan); sportToMan.SetTranslator(sport => { man.Health += sport.GainedHealth; return(man); }); sportToMan.AddChild(startDying); startDying.SetCondition(m => m.Health < 5); startDying.SetNoChild(workHard); startDying.SetYesChild(deadNode); var model = new TreeModel(100); model.SetStartNode(growNode); model.SetEndNode(deadNode); Console.WriteLine("Done"); return(model); }
public void UseScaleSliders() { EnableLinkedScalingControls(true); Height = 182; editmode = ModelAdjustmentsDialog.EditMode.Scale; X_Slider.Visible = true; X_Text.Visible = true; XPitch_Text.Visible = false; X_Slider.SetRange(printerview.MinScale.X, printerview.MaxScale.X); X_Slider.PushButtonStep = (float)((printerview.MaxScale.X - 0.100000001490116) / 20.0); if (X_Slider.PushButtonStep > 10.0) { X_Slider.PushButtonStep = 10f; } X_Slider.RoundingPlace = 2; Y_Slider.Visible = true; Y_Text.Visible = true; YRoll_Text.Visible = false; Y_Slider.SetRange(printerview.MinScale.Y, printerview.MaxScale.Y); Y_Slider.PushButtonStep = (float)((printerview.MaxScale.Y - 0.100000001490116) / 20.0); if (Y_Slider.PushButtonStep > 10.0) { Y_Slider.PushButtonStep = 10f; } Y_Slider.RoundingPlace = 2; Z_Slider.Visible = true; Z_Text.Visible = true; ZYaw_Text.Visible = false; Z_Slider.SetRange(printerview.MinScale.Z, printerview.MaxScale.Z); Z_Slider.PushButtonStep = (float)((printerview.MaxScale.Z - 0.100000001490116) / 20.0); if (Z_Slider.PushButtonStep > 10.0) { Z_Slider.PushButtonStep = 10f; } Z_Edit.Visible = true; Z_Slider.RoundingPlace = 2; TransformationNode modelTransformation = printerview.ModelTransformation; if (modelTransformation == null) { return; } X_Slider.TrackPosition = modelTransformation.Scale.X; Y_Slider.TrackPosition = modelTransformation.Scale.Y; Z_Slider.TrackPosition = modelTransformation.Scale.Z; printerview.ObjectTransformed = false; }
internal AggregationBinder(ODataQuerySettings settings, IAssembliesResolver assembliesResolver, Type elementType, IEdmModel model, TransformationNode transformation) : base(model, assembliesResolver, settings) { Contract.Assert(elementType != null); Contract.Assert(transformation != null); _elementType = elementType; _transformation = transformation; this._lambdaParameter = Expression.Parameter(this._elementType, "$it"); switch (transformation.Kind) { case TransformationNodeKind.Aggregate: var aggregateClause = this._transformation as AggregateTransformationNode; _aggregateExpressions = aggregateClause.Expressions; ResultClrType = AggregationDynamicTypeProvider.GetResultType <DynamicTypeWrapper>(_model, null, _aggregateExpressions); break; case TransformationNodeKind.GroupBy: var groupByClause = this._transformation as GroupByTransformationNode; _groupingProperties = groupByClause.GroupingProperties; if (groupByClause.ChildTransformations != null) { if (groupByClause.ChildTransformations.Kind == TransformationNodeKind.Aggregate) { _aggregateExpressions = ((AggregateTransformationNode)groupByClause.ChildTransformations).Expressions; } else { throw new NotImplementedException(); } } _groupByClrType = AggregationDynamicTypeProvider.GetResultType <DynamicTypeWrapper>(_model, _groupingProperties, null); ResultClrType = AggregationDynamicTypeProvider.GetResultType <DynamicTypeWrapper>(_model, _groupingProperties, _aggregateExpressions); break; default: throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, SRResources.NotSupportedTransformationKind, transformation.Kind)); } _groupByClrType = _groupByClrType ?? typeof(DynamicTypeWrapper); }
public PrinterViewSceneGraph(GUIHost host, SettingsManager.GridUnit initialGridUnits, PrinterSizeProfile.CaseType initialCaseType) : base(123456) { RelativeX = 0.0f; RelativeY = 0.0f; RelativeWidth = 1f; RelativeHeight = 1f; ViewPointPos = new M3D.Model.Utils.Vector3(0.0f, 0.0f, 10f); ModelList = new List <ModelTransformPair>(); CameraLookAtPos = new M3D.Model.Utils.Vector3(0.0f, -10f, 0.0f); AddChildElement3D(new LightNode(0, 0, new Vector4(0.0f, 400f, 1000f, 1f), new Color4(0.2f, 0.2f, 0.2f, 1f), new Color4(1f, 1f, 1f, 1f), new Color4(1f, 1f, 1f, 1f))); AddChildElement3D(new LightNode(1, 1, new Vector4(0.0f, 20f, -400f, 1f), new Color4(0.0f, 0.0f, 0.0f, 1f), new Color4(1f, 1f, 1f, 1f), new Color4(0.3f, 0.3f, 0.3f, 1f))); OpenGLCoordinateSystem = new TransformationNode(0, origin) { Rotation = new M3D.Model.Utils.Vector3(-90f, 0.0f, 0.0f) }; AddChildElement3D(OpenGLCoordinateSystem); PrinterTiltTransform = new TransformationNode(0, OpenGLCoordinateSystem); OpenGLCoordinateSystem.AddChildElement(PrinterTiltTransform); PrinterTransformation = new TransformationNode(0, PrinterTiltTransform); PrinterTypeAdjustments = new TransformationNode(3011, PrinterTransformation); var num = 1.1f; PrinterTypeAdjustments.Scale = new M3D.Model.Utils.Vector3(num, num, 1f); PrinterTransformation.AddChildElement(PrinterTypeAdjustments); PrinterModel = new PrinterModelNode(initialCaseType); PrinterTypeAdjustments.AddChildElement(PrinterModel); ObjectToPrinterSpace = new TransformationNode(3005, PrinterTransformation) { Translation = new M3D.Model.Utils.Vector3(0.0f, 0.0f, 0.0f) }; PrinterTransformation.AddChildElement(ObjectToPrinterSpace); GridSizeAdjustments = new TransformationNode(3012, ObjectToPrinterSpace); ObjectToPrinterSpace.AddChildElement(GridSizeAdjustments); Grid = new GridObjectNode(3003, 100f, 100f); Grid.SetUnits(initialGridUnits); Grid.Visible = false; Grid.Emission = new Color4(1f, 1f, 1f, 1f); GridSizeAdjustments.AddChildElement(Grid); var texturedFloorNode = new TexturedFloorNode(3004); var bitmap = new Bitmap(Resources.shadowtexture); var texture = 0; Element3D.CreateTexture(ref texture, bitmap); bitmap.Dispose(); texturedFloorNode.Create(new M3D.Model.Utils.Vector3(0.0f, 0.0f, -76f), 450f, 240f, texture); OpenGLCoordinateSystem.AddChildElement(texturedFloorNode); PrinterTiltTransform.AddChildElement(PrinterTransformation); }
private GroupByTransformationNode BindGroupByToken(GroupByToken token) { var properties = new List <GroupByPropertyNode>(); foreach (var propertyToken in token.Properties) { var bindResult = this.bindMethod(propertyToken); var property = bindResult as SingleValuePropertyAccessNode; if (property != null) { RegisterProperty(properties, ReversePropertyPath(property)); } else { var openProperty = bindResult as SingleValueOpenPropertyAccessNode; if (openProperty != null) { var type = GetTypeReferenceByPropertyName(openProperty.Name); properties.Add(new GroupByPropertyNode(openProperty.Name, openProperty, type)); } else { throw new ODataException( ODataErrorStrings.ApplyBinder_GroupByPropertyNotPropertyAccessValue(propertyToken.Identifier)); } } } TransformationNode aggregate = null; if (token.Child != null) { if (token.Child.Kind == QueryTokenKind.Aggregate) { aggregate = BindAggregateToken((AggregateToken)token.Child); aggregateStatementsCache = ((AggregateTransformationNode)aggregate).Statements; state.AggregatedProperties = aggregateStatementsCache.Select(statement => statement.AsAlias).ToList(); } else { throw new ODataException(ODataErrorStrings.ApplyBinder_UnsupportedGroupByChild(token.Child.Kind)); } } // TODO: Determine source return(new GroupByTransformationNode(properties, aggregate, null)); }
internal AggregationBinder(ODataQuerySettings settings, IAssembliesResolver assembliesResolver, Type elementType, IEdmModel model, TransformationNode transformation) : base(model, assembliesResolver, settings) { Contract.Assert(elementType != null); Contract.Assert(transformation != null); _elementType = elementType; _transformation = transformation; this._lambdaParameter = Expression.Parameter(this._elementType, "$it"); switch (transformation.Kind) { case TransformationNodeKind.Aggregate: var aggregateClause = this._transformation as AggregateTransformationNode; _aggregateExpressions = aggregateClause.Expressions; ResultClrType = AggregationDynamicTypeProvider.GetResultType<DynamicTypeWrapper>(_model, null, _aggregateExpressions); break; case TransformationNodeKind.GroupBy: var groupByClause = this._transformation as GroupByTransformationNode; _groupingProperties = groupByClause.GroupingProperties; if (groupByClause.ChildTransformations != null) { if (groupByClause.ChildTransformations.Kind == TransformationNodeKind.Aggregate) { _aggregateExpressions = ((AggregateTransformationNode)groupByClause.ChildTransformations).Expressions; } else { throw new NotImplementedException(); } } _groupByClrType = AggregationDynamicTypeProvider.GetResultType<DynamicTypeWrapper>(_model, _groupingProperties, null); ResultClrType = AggregationDynamicTypeProvider.GetResultType<DynamicTypeWrapper>(_model, _groupingProperties, _aggregateExpressions); break; default: throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, SRResources.NotSupportedTransformationKind, transformation.Kind)); } _groupByClrType = _groupByClrType ?? typeof(DynamicTypeWrapper); }
internal AggregationBinder( ODataQuerySettings settings, IAssemblyProvider assembliesResolver, Type elementType, IEdmModel model, TransformationNode transformation, IServiceProvider requestContainer) : base(model, requestContainer, settings) { Contract.Assert(elementType != null); Contract.Assert(transformation != null); _elementType = elementType; _transformation = transformation; this._lambdaParameter = Expression.Parameter(this._elementType, "$it"); switch (transformation.Kind) { case TransformationNodeKind.Aggregate: var aggregateClause = this._transformation as AggregateTransformationNode; _aggregateExpressions = FixCustomMethodReturnTypes(aggregateClause.Expressions); ResultClrType = typeof(NoGroupByAggregationWrapper); break; case TransformationNodeKind.GroupBy: var groupByClause = this._transformation as GroupByTransformationNode; _groupingProperties = groupByClause.GroupingProperties; if (groupByClause.ChildTransformations != null) { if (groupByClause.ChildTransformations.Kind == TransformationNodeKind.Aggregate) { var aggregationNode = (AggregateTransformationNode)groupByClause.ChildTransformations; _aggregateExpressions = FixCustomMethodReturnTypes(aggregationNode.Expressions); } else { throw new NotImplementedException(); } } _groupByClrType = typeof(GroupByWrapper); ResultClrType = typeof(AggregationWrapper); break; default: throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, SRResources.NotSupportedTransformationKind, transformation.Kind)); } _groupByClrType = _groupByClrType ?? typeof(NoGroupByWrapper); }
public void BindApplyWitGroupByWithAggregateShouldReturnApplyClause() { IEnumerable <QueryToken> tokens = _parser.ParseApply("groupby((UnitPrice, SalePrice), aggregate(UnitPrice with sum as TotalPrice))"); ApplyBinder binder = new ApplyBinder(FakeBindMethods.BindSingleComplexProperty, _bindingState); ApplyClause actual = binder.BindApply(tokens); actual.Should().NotBeNull(); actual.Transformations.Should().HaveCount(1); List <TransformationNode> transformations = actual.Transformations.ToList(); GroupByTransformationNode groupBy = transformations[0] as GroupByTransformationNode; TransformationNode aggregate = groupBy.ChildTransformations; aggregate.Should().NotBeNull(); }
private void SaveScalingRatio() { TransformationNode modelTransformation = printerview.ModelTransformation; if (modelTransformation != null) { initialscalevalues.X = modelTransformation.Scale.X; initialscalevalues.Y = modelTransformation.Scale.Y; initialscalevalues.Z = modelTransformation.Scale.Z; } else { initialscalevalues.X = 1f; initialscalevalues.Y = 1f; initialscalevalues.Z = 1f; } }
private void ValidateTransformation(TransformationNode transformation, ODataUrlValidationContext validationContext) { ValidateItem(transformation, validationContext); AggregateTransformationNode aggregate; GroupByTransformationNode groupBy; FilterTransformationNode filter; ComputeTransformationNode compute; ExpandTransformationNode expand; if ((aggregate = transformation as AggregateTransformationNode) != null) { foreach (AggregateExpression aggregateExpression in aggregate.AggregateExpressions) { ValidateItem(aggregateExpression, validationContext); ValidateItem(aggregateExpression.Method, validationContext); ValidateItem(aggregateExpression.MethodDefinition, validationContext); validationContext.ExpressionValidator.ValidateNode(aggregateExpression.Expression); } } else if ((groupBy = transformation as GroupByTransformationNode) != null) { ValidateTransformation(groupBy.ChildTransformations, validationContext); foreach (GroupByPropertyNode property in groupBy.GroupingProperties) { ValidateGroupByPropertyNode(property, validationContext); } } else if ((filter = transformation as FilterTransformationNode) != null) { ValidateFilterClause(filter.FilterClause, validationContext); } else if ((compute = transformation as ComputeTransformationNode) != null) { foreach (ComputeExpression computeExpression in compute.Expressions) { validationContext.ExpressionValidator.ValidateNode(computeExpression.Expression); } } else if ((expand = transformation as ExpandTransformationNode) != null) { // fine to pass null as type since the expand clause will not be null ValidateSelectExpandClause(null, expand.ExpandClause, validationContext); } }
internal AggregationBinder(ODataQuerySettings settings, IWebApiAssembliesResolver assembliesResolver, Type elementType, IEdmModel model, TransformationNode transformation, ODataQueryContext context, SelectExpandClause selectExpandClause = null) : base(settings, assembliesResolver, elementType, model) { Contract.Assert(transformation != null); _transformation = transformation; _selectExpandClause = selectExpandClause; _context = context; switch (transformation.Kind) { case TransformationNodeKind.Aggregate: var aggregateClause = this._transformation as AggregateTransformationNode; _aggregateExpressions = FixCustomMethodReturnTypes(aggregateClause.AggregateExpressions); ResultClrType = typeof(NoGroupByAggregationWrapper); break; case TransformationNodeKind.GroupBy: var groupByClause = this._transformation as GroupByTransformationNode; _groupingProperties = groupByClause.GroupingProperties; if (groupByClause.ChildTransformations != null) { if (groupByClause.ChildTransformations.Kind == TransformationNodeKind.Aggregate) { var aggregationNode = (AggregateTransformationNode)groupByClause.ChildTransformations; _aggregateExpressions = FixCustomMethodReturnTypes(aggregationNode.AggregateExpressions); } else { throw new NotImplementedException(); } } _groupByClrType = typeof(GroupByWrapper); ResultClrType = typeof(AggregationWrapper); break; default: throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, SRResources.NotSupportedTransformationKind, transformation.Kind)); } _groupByClrType = _groupByClrType ?? typeof(NoGroupByWrapper); }
private bool CompareTransformation(TransformationNode node1, TransformationNode node2) { if (node1.GetType() != node2.GetType()) { return(false); } if (node1 is GroupByTransformationNode) { if (!CompareGroupBy(node1 as GroupByTransformationNode, node2 as GroupByTransformationNode)) { return(false); } } else if (node1 is AggregateTransformationNode) { if (!CompareAggregate(node1 as AggregateTransformationNode, node2 as AggregateTransformationNode)) { return(false); } } else if (node1 is FilterTransformationNode) { FilterClause filter1 = (node1 as FilterTransformationNode).FilterClause; FilterClause filter2 = (node2 as FilterTransformationNode).FilterClause; if (!CompareFilter(filter1, filter2, false)) { return(false); } } else { throw new NotSupportedException(); } return(true); }
public void UseRotationSliders() { Height = 182; EnableLinkedScalingControls(false); editmode = ModelAdjustmentsDialog.EditMode.Rotation; X_Slider.Visible = true; X_Text.Visible = false; XPitch_Text.Visible = true; X_Slider.SetRange(-180f, 180f); X_Slider.PushButtonStep = 15f; X_Slider.RoundingPlace = 0; Y_Slider.Visible = true; Y_Text.Visible = false; YRoll_Text.Visible = true; Y_Slider.SetRange(-180f, 180f); Y_Slider.PushButtonStep = 15f; Y_Slider.RoundingPlace = 0; Z_Slider.Visible = true; Z_Text.Visible = false; ZYaw_Text.Visible = true; Z_Edit.Visible = true; Z_Slider.SetRange(-180f, 180f); Z_Slider.PushButtonStep = 15f; Z_Slider.RoundingPlace = 0; TransformationNode modelTransformation = printerview.ModelTransformation; if (modelTransformation == null) { return; } X_Slider.TrackPosition = modelTransformation.Rotation.X; Y_Slider.TrackPosition = modelTransformation.Rotation.Y; Z_Slider.TrackPosition = modelTransformation.Rotation.Z; printerview.ObjectTransformed = false; }
internal AggregationBinderEFFake(ODataQuerySettings settings, IWebApiAssembliesResolver assembliesResolver, Type elementType, IEdmModel model, TransformationNode transformation) : base(settings, assembliesResolver, elementType, model, transformation) { }
internal AggregationBinderEFFake(ODataQuerySettings settings, IWebApiAssembliesResolver assembliesResolver, Type elementType, IEdmModel model, TransformationNode transformation, ODataQueryContext context, SelectExpandClause selectExpandClause = null) : base(settings, assembliesResolver, elementType, model, transformation, context, selectExpandClause) { }
public TransformationNode CreateNode(TransformationNode precursor, string word) { return(null); }