public void Add(Node n) { NodePath.Add(n); }
protected void Refine(Node source, NodePathLevel[] sourceRootLevels, NodePathLevel[] subjectRootLevels, ISubTreeSnapshot subjectSnapshot, List <NodeRelation> result) { if (source.Records.Count > 0) { var sourceLevels = source.GetPathLevelsFromRoot().ToArray(); NodePath path = new NodePath(source.Language, subjectRootLevels.Concat(NodePath.RelativeTo(sourceLevels, sourceRootLevels))); if (subjectSnapshot.ContainsNode(path)) { result.Add(new NodeRelation(RelationKind.SourcingFrom, this.metadataIndexed.AllocateNode(path), source)); } else { return; } } foreach (var c in source.Children) { this.Refine(c.Value, sourceRootLevels, subjectRootLevels, subjectSnapshot, result); } }
private void OnFadeInCompleted(Object Object, NodePath nodePath) { _fadeInComplete = true; }
public QueryExecutionException( string message, NodePath path, params ASTNode[] nodes) : this(message, null, path, nodes) { }
public void _on_StateMachine_Transitioned(NodePath statePath) { Text = statePath; }
private async Task <object> CompleteListValueAsync(IExecutorContext executorContext, ObjectType objectType, IField field, IType fieldType, ObjectType actualType, GraphQLFieldSelection selection, List <GraphQLFieldSelection> fields, object value, Dictionary <string, object> coercedVariableValues, NodePath path, List listType) { if (!(value is IEnumerable values)) { throw new CompleteValueException( $"Cannot complete value for list field '{selection.Name.Value}':'{fieldType}'. " + "Resolved value is not a collection"); } var innerType = listType.WrappedType; var result = new List <object>(); int i = 0; foreach (var resultItem in values) { var itemPath = path.Fork().Append(i++); try { var completedResultItem = await CompleteValueAsync( executorContext, objectType, field, innerType, actualType, selection, fields, resultItem, coercedVariableValues, itemPath).ConfigureAwait(false); result.Add(completedResultItem); } catch (Exception e) { if (innerType is NonNull) { throw; } executorContext.AddError(e); result.Add(null); } } return(result); }
public T GetNode <T>(NodePath path) where T : class { return((T)(object)GetNode(path)); }
public static async Task <object?> ExecuteFieldAsync( IExecutorContext context, ObjectDefinition objectDefinition, object?objectValue, IReadOnlyCollection <FieldSelection> fields, TypeBase fieldType, NodePath path) { if (fields == null) { throw new ArgumentNullException(nameof(fields)); } if (fieldType == null) { throw new ArgumentNullException(nameof(fieldType)); } var schema = context.Schema; var fieldSelection = fields.First(); var fieldName = fieldSelection.Name; var field = schema.GetField(objectDefinition.Name, fieldName); object?completedValue = null; if (field is null) { return(completedValue); } var argumentValues = ArgumentCoercion.CoerceArgumentValues( schema, objectDefinition, fieldSelection, context.CoercedVariableValues); try { var resolver = schema.GetResolver(objectDefinition.Name, fieldName); if (resolver == null) { throw new QueryExecutionException( $"Could not get resolver for {objectDefinition.Name}.{fieldName}", path); } var resolverContext = new ResolverContext( objectDefinition, objectValue, field, fieldSelection, fields, argumentValues, path, context); // begin resolve await context.ExtensionsRunner.BeginResolveAsync(resolverContext); var resultTask = resolver(resolverContext); IResolverResult result; if (resultTask.IsCompletedSuccessfully) { result = resultTask.Result; } else { result = await resultTask; } await context.ExtensionsRunner.EndResolveAsync(resolverContext, result); // end resolve // begin complete var completedValueTask = result.CompleteValueAsync(resolverContext); if (completedValueTask.IsCompletedSuccessfully) { completedValue = completedValueTask.Result; } else { completedValue = await completedValueTask; } // end complete return(completedValue); } catch (Exception e) { return(FieldErrors.Handle( context, objectDefinition, fieldName, fieldType, fieldSelection, completedValue, e, path)); } }
public CompleteValueException(string message, Exception innerException, NodePath path, IReadOnlyDictionary <string, object> extensions, params INode[] nodes) : base(message, innerException, path, extensions, nodes) { }
void OnBeginMoveAnimation(NodePath currentPath) { MovementNodes = currentPath.PathToDestination; _movementDelta = 0; }
public LabeledTreeNode(NodePath path, TData nodeData, LabeledTreeNode <TData>[] children) { _path = path; _nodeData = nodeData; _children = children; }
IEnumerable <Node> NodesOfType(NodeType type) { return(NodePath.Reverse <Node>().Where(n => n.Type == type)); }
bool Visit(Namescope scope, Node n, int offset) { n.TypeOrNamespace = scope; if (scope is Uno.Compiler.API.Domain.IL.Types.ClassType) { n.BlockBase = (scope as Uno.Compiler.API.Domain.IL.Types.ClassType).Block; } if (scope is Block) { return(Visit(scope as Block, n, offset)); } var name = n.Name; if (n.Name != "<root>" && name.Contains('<')) { name = name.Substring(0, name.IndexOf('<')); } // Check if we are not inside the right node if (!(n.StartOffset < offset && n.EndOffset >= offset)) { return(false); } NodePath.Add(n); if (n.Children != null) { foreach (var c in n.Children) { // If current scope is a data type, check if a type member has a match with the child node, if so let them have precedence if (scope is DataType) { var dt = scope as DataType; if (c.Type == NodeType.Constructor) { foreach (var m in dt.Constructors) { if (m.Source.Offset == c.StartOffset) { if (Visit(m, c, offset)) { return(true); } } } } else { foreach (var m in dt.EnumerateMembers()) { if (m.Name == c.Name) { if (Visit(m, c, offset)) { return(true); } } } } } // Check if a child scope has a match with the child node, if so let them have precedence foreach (var cn in scope.EnumerateNestedScopes()) { if (cn.Name == c.Name) { if (Visit(cn, c, offset)) { return(true); } } } if (Visit(scope, c, offset)) { return(true); } } } return(true); }
bool Visit(BlockBase b, Node n, int offset) { n.BlockBase = b; // Check if we are not inside the right node if (!(n.StartOffset < offset && n.EndOffset >= offset)) { return(false); } NodePath.Add(n); // Add metaproperties from lambda draw. var metaProperties = new List <MetaProperty>(); foreach (var i in b.Members) { if (i.Type == BlockMemberType.Apply) { var applyItem = i as Apply; if (applyItem.Block.Parent == b) { foreach (var c in applyItem.Block.Members) { if (c.Type == BlockMemberType.MetaProperty) { metaProperties.Add(c as MetaProperty); } } } } } if (n.Children != null) { foreach (var c in n.Children) { foreach (var db in b.EnumerateNestedScopes()) { if (Visit(db, c, offset)) { return(true); } } if (c.Type == NodeType.MetaProperty) { foreach (var m in metaProperties) { if (m.Name == c.Name) { if (Visit(m, c, offset)) { return(true); } } } } foreach (var i in b.Members) { if (i.Type == BlockMemberType.Apply && c.Type == NodeType.Apply) { c.ApplyItem = i as Apply; continue; } if (i.Type == BlockMemberType.MetaProperty && c.Type == NodeType.MetaProperty) { var mp = i as MetaProperty; if (mp.Name == c.Name) { if (Visit(mp, c, offset)) { return(true); } } } } if (Visit(b, c, offset)) { return(true); } } } return(true); }
private static async Task <object> CompleteInterfaceValueAsync(IExecutorContext executorContext, ObjectType actualType, List <GraphQLFieldSelection> fields, object value, Dictionary <string, object> coercedVariableValues, NodePath path, InterfaceType interfaceType) { if (!actualType.Implements(interfaceType)) { throw new CompleteValueException( "Cannot complete value as interface. " + $"Actual type {actualType.Name} does not implement {interfaceType.Name}"); } var subSelectionSet = SelectionSets.MergeSelectionSets(fields); var data = await SelectionSets.ExecuteSelectionSetAsync( executorContext, subSelectionSet, actualType, value, coercedVariableValues, path).ConfigureAwait(false); return(data); }
public CompleteValueException(string message, NodePath path, params INode[] nodes) : base(message, path, nodes) { }
private static async Task <object> CompleteObjectValueAsync(IExecutorContext executorContext, List <GraphQLFieldSelection> fields, object value, Dictionary <string, object> coercedVariableValues, NodePath path, ObjectType fieldObjectType) { var subSelectionSet = SelectionSets.MergeSelectionSets(fields); var data = await SelectionSets.ExecuteSelectionSetAsync( executorContext, subSelectionSet, fieldObjectType, value, coercedVariableValues, path).ConfigureAwait(false); return(data); }
public static ChildT GetNodeOrDefault <ParentT, ChildT>(this ParentT node, NodePath path) where ParentT : Node where ChildT : Node => node.GetNodeOrCreate <ParentT, ChildT>(path, _ => default);
public async Task <object> CompleteValueAsync(IExecutorContext executorContext, ObjectType objectType, IField field, IType fieldType, ObjectType actualType, GraphQLFieldSelection selection, List <GraphQLFieldSelection> fields, object value, Dictionary <string, object> coercedVariableValues, NodePath path) { if (value is IResolveResult resolveResult) { return(await resolveResult.CompleteValueAsync( executorContext, objectType, field, fieldType, selection, fields, coercedVariableValues, path).ConfigureAwait(false)); } if (fieldType is NonNull nonNull) { return(await CompleteNonNullValueAsync( executorContext, objectType, field, actualType, selection, fields, value, coercedVariableValues, path, nonNull)); } if (value == null) { return(null); } if (fieldType is List listType) { return(await CompleteListValueAsync( executorContext, objectType, field, fieldType, actualType, selection, fields, value, coercedVariableValues, path, listType)); } if (fieldType is ScalarType scalarType) { return(scalarType.Serialize(value)); } if (fieldType is EnumType enumType) { return(enumType.Serialize(value)); } if (fieldType is ObjectType fieldObjectType) { return(await CompleteObjectValueAsync( executorContext, fields, value, coercedVariableValues, path, fieldObjectType)); } // interfaces and unions require ActualType if (actualType == null) { throw new CompleteValueException( "Cannot complete value as interface or union. " + $"Actual type not given from resolver. Use {nameof(Resolve.As)} with type parameter"); } if (fieldType is InterfaceType interfaceType) { return(await CompleteInterfaceValueAsync( executorContext, actualType, fields, value, coercedVariableValues, path, interfaceType)); } if (fieldType is UnionType unionType) { return(await CompleteUnionValueAsync( executorContext, actualType, fields, value, coercedVariableValues, path, unionType)); } throw new CompleteValueException($"Cannot complete value for field {field}. No handling for the type {fieldType}."); }
HashSet <RunnableNode> FollowNode(Node currentNode, Node prevNode, RunnableNode lastRunnable, HashSet <Node> triedNodes, NodePath path) { // If this node has already been tried, it's path has already been followed - cancel this branch if (triedNodes.Contains(currentNode) && optimiseParallel) { if (recordNodePaths) { checkinNodePaths.Add(path); } return(new HashSet <RunnableNode>()); } /*if (triedNodes.Contains(currentNode) && optimiseParallel) { * HashSet<RunnableNode> retNodes = new HashSet<RunnableNode>(); * retNodes.Add(lastRunnable); * return retNodes; * }*/ // Node has been encountered - trigger the event currentNode.OnEncountered(prevNode, _machine, this); // The current chain's HashSet of runnables to stop at HashSet <RunnableNode> runnables = new HashSet <RunnableNode>(); runnables.Add(lastRunnable); // The HashSet of nodes to test next HashSet <Node> nextNodes = new HashSet <Node>(); // Get nodes from the current node to test next // If not specified, default to link testing Node[] givenNextNodes = currentNode.NextNodes(); if (givenNextNodes != null) { foreach (Node node in givenNextNodes) { if (node == null) { Debug.LogError("Given null node to follow from " + currentNode + "!"); } else { nextNodes.Add(node); } } } else { // Get links from the current node to test next // Use node specified links if specified Link[] links = currentNode.NextLinks(); if (links == null) { links = _model.GetOutputLinks(currentNode).ToArray(); } // Store the node in the loop checking HashSet if doing so if (optimiseParallel) { triedNodes.Add(currentNode); } // If the current node is blocking, kill the chain if (currentNode.IsBlocking()) { if (recordNodePaths) { checkinNodePaths.Add(path); } return(runnables); } // Test connected links foreach (Link link in links) { Node nextNode = _model.GetNodeFromID(link._to); // Add the tested link to the current link chain for live preview _currentLinks.Add(link); nextNodes.Add(nextNode); } } currentNode.OnPassed(nextNodes, _machine, this); foreach (Node nextNode in nextNodes) { // Record next node as an entry in the path NodePath newPath = null; if (recordNodePaths) { newPath = new NodePath(); newPath.currentNode = nextNode; newPath.fromPath = path; path.toPath = newPath; } // If nextNode is an EndNode, kill the chain if (nextNode is EndNode) { if (recordNodePaths) { checkinNodePaths.Add(newPath); } encounteredEnd = true; return(new HashSet <RunnableNode>()); } // If nextNode is a RunnableNode, store it as the next return point. // Otherwise continue with the last return point. RunnableNode makeLastRunnable = lastRunnable; if (nextNode is RunnableNode) { makeLastRunnable = nextNode as RunnableNode; } // Set up new triedNodes listing HashSet <Node> newTriedNodes = new HashSet <Node>(triedNodes); HashSet <RunnableNode> nextRunnables = FollowNode(nextNode, currentNode, makeLastRunnable, newTriedNodes, newPath); // If the model doesn't support parallel states, use first come first serve if (!_model.supportParallel) { return(nextRunnables); } else { runnables.Remove(lastRunnable); foreach (RunnableNode runnable in nextRunnables) { runnables.Add(runnable); } } } runnables.RemoveWhere(r => r == null); // Check if there are any runnables different from the last one given for this chain. bool runnableChange = false; foreach (RunnableNode runnable in runnables) { if (runnable != lastRunnable) { runnableChange = true; break; } } // If there is a change, remove the last runnable, otherwise maintain the chain. if (runnableChange) { runnables.Remove(lastRunnable); } if (recordNodePaths) { checkinNodePaths.Add(path); } return(runnables); }
public T GetNodeOrNull <T>(NodePath path) where T : class { return(GetNodeOrNull(path) as T); }
private void OnIndicatorTweenCompleted(object o, NodePath key) { tweenCompleted = true; }
public string NodePath() { NodePath path = GetPath(); return(path.ToString()); }
// -------------------------------------------------- // Methods // -------------------------------------------------- public abstract Node InitScene(NodePath path = null);
private void doIt(string script) { int desiredImageWidth = this.TabControl.Size.Width - 5; int desiredImageHeight = this.TabControl.Size.Height - 5; string[] fullpath = NodePath.Split(new char[] { '/' }); string nodeName = fullpath[fullpath.Length - 1]; string imageFileName = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + nodeName + ".png"; string scriptFileName = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + nodeName + ".R"; List <string> OutputFileNames = new List <string>(); UIUtility.OutputFileUtility.GetOutputFiles(Controller, Controller.Selection, OutputFileNames); // Build the R script from our XML value StringWriter newScript = new StringWriter(); newScript.WriteLine("# Automatically generated - do not edit"); newScript.WriteLine("width<- " + desiredImageWidth.ToString()); newScript.WriteLine("height<- " + desiredImageHeight.ToString()); newScript.WriteLine("imageFileName <- \"" + imageFileName.Replace("\\", "/") + "\""); newScript.Write("inputFiles <- c("); bool first = true; foreach (string outputfile in OutputFileNames) { if ((!(first))) { newScript.Write(","); } newScript.Write("\"" + outputfile.Replace("\\", "/") + "\""); first = false; } newScript.WriteLine(")"); newScript.Write(script); bool needsRerun = false; // See if the script has changed since its last run if ((File.Exists(scriptFileName))) { StreamReader sfp = new StreamReader(scriptFileName, false); string oldScript = sfp.ReadToEnd(); needsRerun = !(string.Equals(oldScript, newScript.ToString())); sfp.Close(); } else { needsRerun = true; } // See if the input files have changed if ((!(File.Exists(imageFileName)))) { needsRerun = true; } else { // See if a simulation has been run that invalidates this image System.DateTime myDate = File.GetCreationTime(imageFileName); foreach (string outputfile in OutputFileNames) { if ((File.Exists(outputfile) && (File.GetCreationTime(outputfile) > myDate))) { needsRerun = true; } } } // See if the window size has changed if ((!(needsRerun) && File.Exists(imageFileName))) { Image diskImage = Image.FromFile(imageFileName); if (((desiredImageWidth != diskImage.Width) || (desiredImageHeight != diskImage.Height))) { needsRerun = true; } diskImage.Dispose(); } else { needsRerun = true; } bool canRun = true; if ((needsRerun)) { foreach (string outputfile in OutputFileNames) { if ((!(File.Exists(outputfile)))) { canRun = false; } } } if ((!(canRun))) { this.ConsoleBox.Text = "Output files are missing. Can't run R. Run APSIM first."; } else if ((needsRerun)) { StreamWriter fp = new StreamWriter(scriptFileName, false); fp.Write(newScript.ToString()); fp.Close(); // scrub the old image so that we can be sure it's regenerated try { File.Delete(imageFileName); } catch (System.IO.IOException) { } finally { } // try and run R with this script RegistryKey regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\R-core\\R", false); if (((regKey != null))) { string rpath = (string)regKey.GetValue("InstallPath", ""); // Should test somehow for pre 2.12.x that doesnt have rscript installed string rcmd = rpath + "\\bin\\Rscript.exe"; string args = "--slave --vanilla \"" + scriptFileName + "\""; string consoleMsg = "Command: " + rcmd + Environment.NewLine + Environment.NewLine; consoleMsg += "Arguments: " + args + Environment.NewLine + Environment.NewLine; this.ConsoleBox.Text = consoleMsg; System.Diagnostics.Process p = Utility.RunProcess(rcmd, args, Directory.GetCurrentDirectory()); p.WaitForExit(); consoleMsg += "stdout: " + Environment.NewLine + p.StandardOutput.ReadToEnd() + Environment.NewLine + Environment.NewLine; consoleMsg += "stderr: " + Environment.NewLine + p.StandardError.ReadToEnd() + Environment.NewLine + Environment.NewLine; consoleMsg += "script: " + Environment.NewLine + newScript.ToString(); this.ConsoleBox.Text = consoleMsg; } } // update displayed image if ((File.Exists(imageFileName))) { FileStream newImageStream = new FileStream(imageFileName, FileMode.Open, FileAccess.Read); this.PictureBox.Image = Image.FromStream(newImageStream); newImageStream.Dispose(); } }
public void Clear() { NodePath?.Clear(); Path?.Clear(); }
private void _on_Tween_tween_completed(Godot.Object @object, NodePath key) { QueueFree(); }
private static async Task <object> CompleteUnionValueAsync(IExecutorContext executorContext, ObjectType actualType, List <GraphQLFieldSelection> fields, object value, Dictionary <string, object> coercedVariableValues, NodePath path, UnionType unionType) { if (!unionType.IsPossible(actualType)) { throw new CompleteValueException( "Cannot complete value as union. " + $"Actual type {actualType.Name} is not possible for {unionType.Name}"); } var subSelectionSet = SelectionSets.MergeSelectionSets(fields); var data = await SelectionSets.ExecuteSelectionSetAsync( executorContext, subSelectionSet, actualType, value, coercedVariableValues, path).ConfigureAwait(false); return(data); }
public LinkNodeStatic(string path) { Path = path; }
private void OnTweenCompleted(Object obj, NodePath key) { Visible = false; EmitSignal(nameof(ReloadFinished)); }