public void Apply_ColumnIndex_CorrectResult() { var builder = new ResultSetBuilder(); var rs = builder.Build(new object[] { new List <object>() { "(null)", 10, 100 }, new List <object>() { "(empty)", 2, 75 }, new List <object>() { "C", 5, 50 } }); var info = Mock.Of <IPredicateInfo> ( p => p.ComparerType == ComparerType.NullOrEmpty && p.ColumnType == ColumnType.Text && p.Name == "#0" ); var factory = new PredicateFilterFactory(); var filter = factory.Instantiate(new IColumnAlias[0], new IColumnExpression[0], info); var result = filter.Apply(rs); Assert.That(result.Rows, Has.Count.EqualTo(2)); Assert.That(filter.Describe(), Is.StringContaining("null").And.StringContaining("or empty")); }
public void Apply_ColumnName_CorrectResult() { var builder = new ResultSetBuilder(); var rs = builder.Build(new object[] { new List <object>() { "(null)", 10, 100 }, new List <object>() { "(empty)", 2, 75 }, new List <object>() { "C", 5, 50 } }); rs.Table.Columns[0].ColumnName = "first"; var info = Mock.Of <IPredicateInfo> ( p => p.ComparerType == ComparerType.NullOrEmpty && p.ColumnType == ColumnType.Text && p.Name == "first" ); var factory = new PredicateFilterFactory(); var filter = factory.Instantiate(new IColumnAlias[0], new IColumnExpression[0], info); var result = filter.Apply(rs); Assert.That(result.Rows, Has.Count.EqualTo(2)); }
public ResultSet CreateScenes() { var resultSetBuilder = new ResultSetBuilder(); for (var i = 0; i < _mapList.Count; i++) { var document = _mapList[i]; var processor = new MapDocumentProcessor(); RaiseStepEvent(document.FileName, i); var result = processor.Convert(document); var map = result.RootNode; resultSetBuilder.AddProcessorProblems(result.Problems, document.FileName); if (map == null) { continue; } SceneBuilder.OutputFromMap(map, MakeOutputPathForScene(document)); } AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate); return(resultSetBuilder.ToResultSet()); }
public ResultSet Parse() { var resultSetBuilder = new ResultSetBuilder(); _mapList.Clear(); for (var i = 0; i < _selection.Length; i++) { var file = _selection[i]; RaiseStepEvent(file, i); try { var content = File.ReadAllText(file); var document = ParsedDocument.From(file, content); if (document.RootNode.SectionType != "Map") { continue; } _mapList.Add(document); } catch (ParserException ex) { resultSetBuilder.AddProblem(ProblemSeverity.Fatal, file, ex.Message); } } return(resultSetBuilder.ToResultSet()); }
public NBi.Core.ResultSet.ResultSet Execute(XDocument items) { var result = from item in items.XPathSelectElements(@from) select GetObj(item); var builder = new ResultSetBuilder(); var rows = result.ToArray(); var resultSet = builder.Build(rows); return(resultSet); }
public ResultSet CreateMaterialInstances() { var resultSetBuilder = new ResultSetBuilder(); AssetDatabase.StartAssetEditing(); CreateMaterialsForInstances(resultSetBuilder); AssetDatabase.StopAssetEditing(); AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate); return(resultSetBuilder.ToResultSet()); }
protected IEnumerable <string> GetMembersFromResultSet(Object obj) { var rs = ResultSetBuilder.Build(obj); var members = new List <string>(); foreach (DataRow row in rs.Rows) { members.Add(row.ItemArray[0].ToString()); } return(members); }
public void Apply_MixedExpression_CorrectResult() { var builder = new ResultSetBuilder(); var rs = builder.Build(new object[] { new List <object>() { 1, 10, 100 }, new List <object>() { 2, 2, 75 }, new List <object>() { 3, 5, 50 } }); rs.Table.Columns[2].ColumnName = "c1"; var aliases = new List <IColumnAlias>() { Mock.Of <IColumnAlias>(v => v.Column == 0 && v.Name == "a"), }; var expressions = new List <IColumnExpression>() { Mock.Of <IColumnExpression>(e => e.Value == "Abs([a])+[e]" && e.Name == "d"), Mock.Of <IColumnExpression>(e => e.Value == "[#1]*[c1]" && e.Name == "e") }; var info = Mock.Of <IPredicateInfo> ( p => p.ComparerType == ComparerType.MoreThanOrEqual && p.ColumnType == ColumnType.Numeric && p.Name == "d" && p.Reference == (object)200 ); var factory = new PredicateFilterFactory(); var filter = factory.Instantiate(aliases, expressions, info); var result = filter.Apply(rs); Assert.That(result.Rows, Has.Count.EqualTo(2)); }
public void Apply_Resultset_CorrectResult() { var builder = new ResultSetBuilder(); var row1 = new List <object>() { "A", 10, 100 }; var row2 = new List <object>() { "B", 2, 75 }; var row3 = new List <object>() { "C", 5, 50 }; var rs = builder.Build(new object[] { row1, row2, row3 }); var v1 = Mock.Of <IColumnVariable>(v => v.Column == 1 && v.Name == "a"); var v2 = Mock.Of <IColumnVariable>(v => v.Column == 2 && v.Name == "b"); var variables = new List <IColumnVariable>() { v1, v2 }; var exp = Mock.Of <IColumnExpression>(e => e.Value == "a*b" && e.Name == "c"); var expressions = new List <IColumnExpression>() { exp }; var info = Mock.Of <IPredicateInfo> ( p => p.ComparerType == ComparerType.MoreThanOrEqual && p.ColumnType == ColumnType.Numeric && p.Name == "c" && p.Reference == (object)200 ); var filter = new PredicateFilter(variables, expressions, info); var result = filter.Apply(rs); Assert.That(result.Rows, Has.Count.EqualTo(2)); }
public void SetUp() { this.resultSetBuilder = new ResultSetBuilder(); this.jdbcQueryActivity = new JdbcQueryActivity("Currency", ActivityType.jdbcQueryActivityType); jdbcQueryActivity.QueryStatement = "my_proc_stock"; jdbcQueryActivity.ClassName = jdbcQueryActivity.Name; jdbcQueryActivity.QueryOutputStatementParameters = new List <ClassParameter> { new ClassParameter { Name = "FirstOutput", Type = "VARCHAR" }, new ClassParameter { Name = "SecondOutput", Type = "VARCHAR" } }; }
public ResultSet ValidateDependencies() { var resultSetBuilder = new ResultSetBuilder(); for (var i = 0; i < _materialInstanceList.Count; i++) { var document = _materialInstanceList[i]; RaiseStepEvent(document.FileName, i); var material = FindUnrealMaterialByInstanceDocument(document); if (material == null) { resultSetBuilder.AddProblem(ProblemSeverity.Fatal, document.FileName, "Parent material not found"); } } return(resultSetBuilder.ToResultSet()); }
public ResultSet Parse() { var resultSetBuilder = new ResultSetBuilder(); _materialList.Clear(); _materialInstanceList.Clear(); for (var i = 0; i < _selection.Length; i++) { var file = _selection[i]; RaiseStepEvent(file, i); try { var content = File.ReadAllText(file); var document = ParsedDocument.From(file, content); var classValue = document.RootNode.FindAttributeValue("Class"); if (document.RootNode.SectionType != "Object") { continue; } if (classValue == "/Script/Engine.Material") { _materialList.Add(document); } else if (classValue == "/Script/Engine.MaterialInstanceConstant") { _materialInstanceList.Add(document); } } catch (ParserException ex) { resultSetBuilder.AddProblem(ProblemSeverity.Fatal, file, ex.Message); } } return(resultSetBuilder.ToResultSet()); }
private void CreateMaterialsForShaderGraphs(ResultSetBuilder resultSetBuilder) { for (var i = 0; i < _materialList.Count; i++) { var document = _materialList[i]; RaiseStepEvent(document.FileName, i); var shaderPath = "Assets/" + MakeRelativePath(_outputDirectory, MakeOutputPathForShaderGraph(document)); var shaderAsset = AssetDatabase.LoadAssetAtPath <Shader>(shaderPath); if (null == shaderAsset) { continue; } var graphData = JsonUtility.FromJson <GraphData>(File.ReadAllText(shaderPath)); var textureProperties = graphData.properties.Where(p => p.propertyType == PropertyType.Texture2D || p.propertyType == PropertyType.Texture3D); var materialAsset = new Material(shaderAsset); var outputPath = MakeOutputPathForMaterial(document, true); foreach (var shaderProperty in textureProperties) { if (shaderProperty is Texture2DShaderProperty) { // materialAsset.SetTexture(shaderProperty.referenceName, ((Texture2DShaderProperty) shaderProperty).value.texture); } else if (shaderProperty is Texture3DShaderProperty) { // materialAsset.SetTexture(shaderProperty.referenceName, ((Texture3DShaderProperty) shaderProperty).value.texture); } } Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); AssetDatabase.CreateAsset(materialAsset, outputPath); } }
public ResultSet CreateShaderGraphs() { var resultSetBuilder = new ResultSetBuilder(); AssetDatabase.StartAssetEditing(); for (var i = 0; i < _materialList.Count; i++) { var document = _materialList[i]; var processor = new MaterialDocumentProcessor(); RaiseStepEvent(document.FileName, i); var result = processor.Convert(document); var material = result.RootNode; resultSetBuilder.AddProcessorProblems(result.Problems, document.FileName); if (material == null) { continue; } var shaderGraph = ShaderGraphBuilder.FromMaterial(material); shaderGraph.ValidateGraph(); var content = JsonUtility.ToJson(shaderGraph); var outputPath = MakeOutputPathForShaderGraph(document); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); File.WriteAllText(outputPath, content, Encoding.UTF8); } AssetDatabase.StopAssetEditing(); AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate); return(resultSetBuilder.ToResultSet()); }
internal FileParametersConstraints(CsvParameters csvParameters, FluentFileParameters fileParameters) : base(csvParameters) { And = fileParameters; ThatReturns = new ResultSetBuilder(csvParameters); }
protected ResultSet GetResultSet(Object obj) { return(ResultSetBuilder.Build(obj)); }
private void CreateMaterialsForInstances(ResultSetBuilder resultSetBuilder) { for (var i = 0; i < _materialInstanceList.Count; i++) { var instanceDocument = _materialInstanceList[i]; var parentDocument = FindUnrealMaterialByInstanceDocument(instanceDocument); RaiseStepEvent(instanceDocument.FileName, MaterialCount + i); if (null == parentDocument) { continue; } var processor = new MaterialInstanceDocumentProcessor(); var result = processor.Convert(instanceDocument); var materialInstance = result.RootNode; var shaderPath = "Assets/" + MakeRelativePath(_outputDirectory, MakeOutputPathForShaderGraph(parentDocument)); var shaderAsset = AssetDatabase.LoadAssetAtPath <Shader>(shaderPath); if (null == shaderAsset) { continue; } var graphData = JsonUtility.FromJson <GraphData>(File.ReadAllText(shaderPath)); var materialAsset = new Material(shaderAsset); foreach (var parameter in materialInstance.ScalarParameters) { var parameterName = parameter.FindPropertyValue("ParameterName") ?? FindNameFromParameterInfo(parameter); var parameterValue = ValueUtil.ParseFloat(parameter.FindPropertyValue("ParameterValue") ?? "1.0"); if (graphData.properties.Any(p => p.displayName == parameterName)) { var parameterReference = graphData.properties.First(p => p.displayName == parameterName).referenceName; materialAsset.SetFloat(parameterReference, parameterValue); } } foreach (var parameter in materialInstance.VectorParameters) { var parameterName = parameter.FindPropertyValue("ParameterName") ?? FindNameFromParameterInfo(parameter); var parameterValue = ValueUtil.ParseVector4(parameter.FindPropertyValue("ParameterValue") ?? "(R=0.0,G=0.0,B=0.0,A=1.0)"); if (graphData.properties.Any(p => p.displayName == parameterName)) { var parameterReference = graphData.properties.First(p => p.displayName == parameterName).referenceName; materialAsset.SetVector(parameterReference, new Vector4(parameterValue.X, parameterValue.Y, parameterValue.Z, parameterValue.A)); } } foreach (var parameter in materialInstance.TextureParameters) { var parameterName = parameter.FindPropertyValue("ParameterName") ?? FindNameFromParameterInfo(parameter); var parameterValue = ValueUtil.ParseResourceReference(parameter.FindPropertyValue("ParameterValue")); if (graphData.properties.Any(p => p.displayName == parameterName)) { var parameterReference = graphData.properties.First(p => p.displayName == parameterName).referenceName; var textureAssetPath = "Assets" + Path.ChangeExtension(parameterValue.FileName, "TGA"); var textureAsset = AssetDatabase.LoadAssetAtPath <Texture>(textureAssetPath); materialAsset.SetTexture(parameterReference, textureAsset); } } var outputPath = MakeOutputPathForMaterial(instanceDocument, true); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); AssetDatabase.CreateAsset(materialAsset, outputPath); } }