internal void UpdateVariantType(NIType type) { NIType oldType = Type; if (oldType != type) { Type = type; TransactionRecruiter.EnlistPropertyItem(this, nameof(Type), oldType, type, (t, _) => Type = t, TransactionHints.Semantic); QualifiedName oldTypeName = TypeName; QualifiedName typeName = type.GetTypeDefinitionQualifiedName(); if (oldTypeName != typeName) { TypeName = typeName; TransactionRecruiter.EnlistPropertyItem(this, nameof(TypeName), oldTypeName, typeName, (n, _) => TypeName = n, TransactionHints.Semantic); // need to notify that dependencies have changed so that we can resolve to them if (!oldTypeName.IsEmpty) { _dependencies.RemoveOfType <TypeDiagramDependency>(this); } _dependencies.Add(this, new TypeDiagramDependency(this, typeName)); } } }
internal void UpdateStructType(NIType type) { NIType oldType = StructType; if (oldType != type) { StructType = type; TransactionRecruiter.EnlistPropertyItem(this, nameof(StructType), oldType, type, (t, _) => StructType = t, TransactionHints.Semantic); } }
private void UpdateUnderlyingType(NIType value, bool updateDependencies) { if (!_underlyingType.Equals(value)) { NIType oldValue = _underlyingType; _underlyingType = value; // Don't set dependencies on load, they will be parsed in. if (updateDependencies) { TypeDefinitionSupport.SetTypeDefinitionDependencies(value, this); } TransactionRecruiter.EnlistPropertyItem(this, DataTypePropertyName, oldValue, _underlyingType, (d, _) => _underlyingType = d, TransactionHints.Semantic); } }
internal void UpdateDependencies(NIType type) { QualifiedName oldTypeName = TypeName; QualifiedName typeName = type.GetTypeDefinitionQualifiedName(); if (oldTypeName != typeName) { TypeName = typeName; TransactionRecruiter.EnlistPropertyItem(this, nameof(TypeName), oldTypeName, typeName, (n, _) => TypeName = n, TransactionHints.Semantic); if (!oldTypeName.IsEmpty) { _dependencies.RemoveOfType <TypeDiagramDependency>(this); } _dependencies.Add(this, new TypeDiagramDependency(this, typeName)); } }
/// <inheritdoc /> public Task OnExportsChangedAsync(Envoy envoy, ExportsChangedData data) { // This is called when something about the "exported" attributes of the item we are linked to changes. if (!(Rooted && envoy.Rooted)) { return(AsyncHelpers.CompletedTask); } this.TransactUpdateFromDependency(envoy, data, "Update From Dependency", () => { if (!(Rooted && envoy.Rooted)) { return; } IMethodCallTarget target = envoy?.QueryService <IMethodCallTarget>().FirstOrDefault(); if (target != null) { var name = target.Name; var icon = target.GetIcon(ViewElementTemplate.Icon); bool envoyChanged = data.Reason == ExportsChangeReason.Resolve || data.Reason == ExportsChangeReason.Unresolve; bool propertyChanged = data.Reason == ExportsChangeReason.PropertyChange; if (envoyChanged || (propertyChanged && data.ChangedProperties.Any(n => n == "Icon"))) { // Notify that the icon changed TransactionRecruiter.EnlistPropertyChanged(this, "Icon"); } if (envoyChanged || (propertyChanged && data.ChangedProperties.Any(n => n == "CacheSignature"))) { TransactionRecruiter.EnlistPropertyChanged(this, "Signature"); // You can look at the signature to gather connector pane information var signature = target.Signature; var allParameters = signature.GetParameters(); foreach (var parameter in allParameters) { var terminalName = parameter.GetAttributeValue("NI.UserDefinedName").Value ?? "Unknown"; var index = parameter.GetName(); var usage = parameter.GetParameterTerminalUsage(); var input = parameter.GetInputParameterPassingRule() != NIParameterPassingRule.NotAllowed; var output = parameter.GetOutputParameterPassingRule() != NIParameterPassingRule.NotAllowed; Log.WriteLine($"Parameter: {terminalName}, Type: {parameter.GetDataType()}"); } } } }); return(AsyncHelpers.CompletedTask); }
/// <summary> /// The transacted update of our Adjacent Joint List. /// </summary> /// <inheritdoc /> public override WireJoint AddAdjacentJoint(WireJoint sibling, IList <Mapping <WireJoint> > collapsedJoints) { var splineJoint = sibling as SplineWireJoint; if (splineJoint != null) { TransactionRecruiter.EnlistCollectionItem(this, "_adjacentJoints", _ => _adjacentJoints, CollectionChangeTypes.Add, splineJoint, TransactionHints.Visual); _adjacentJoints.Add(splineJoint); var siblingAdjacentJoints = splineJoint.AdjacentJoints as List <SplineWireJoint>; if (siblingAdjacentJoints != null) { TransactionRecruiter.EnlistCollectionItem(splineJoint, "_adjacentJoints", _ => siblingAdjacentJoints, CollectionChangeTypes.Add, this, TransactionHints.Visual); siblingAdjacentJoints.Add(this); } } return(splineJoint); }
public async Task OnExportsChangedAsync(Envoy envoy, ExportsChangedData data) { if (ShouldUpdateDataTypeFromChange(data)) { NIType oldType = Type; NIType type = await envoy.GetTypeDiagramSignatureAsync(); if (type.IsUnset() || type == oldType) { return; } this.TransactUpdateFromDependency(envoy, data, TransactionManager, "Set variant type", () => { Type = type; TransactionRecruiter.EnlistPropertyItem(this, nameof(Type), oldType, type, (t, __) => { Type = t; }, TransactionHints.Semantic); UpdateCasesFromDataType(type); }); } }
/// <summary> /// The transacted update of our Adjacent Joint List. /// </summary> /// <inheritdoc /> public override bool RemoveAdjacentJoint(WireJoint sibling) { var splineJoint = sibling as SplineWireJoint; if (splineJoint != null) { TransactionRecruiter.EnlistCollectionItem(this, "_adjacentJoints", _ => _adjacentJoints, CollectionChangeTypes.Remove, splineJoint, TransactionHints.Visual); _adjacentJoints.Remove(splineJoint); var siblingAdjacentJoints = splineJoint.AdjacentJoints as List <SplineWireJoint>; if (siblingAdjacentJoints != null) { TransactionRecruiter.EnlistCollectionItem(splineJoint, "_adjacentJoints", _ => siblingAdjacentJoints, CollectionChangeTypes.Add, this, TransactionHints.Visual); siblingAdjacentJoints.Remove(this); } return(true); } return(false); }
public async Task OnExportsChangedAsync(Envoy envoy, ExportsChangedData data) { if (ShouldUpdateDataTypeFromChange(data)) { NIType oldType = Type; NIType type = await envoy.GetTypeDiagramSignatureAsync(); if (type.IsUnset() || type == oldType) { return; } using (var transaction = TransactionManager.BeginTransactionIfNecessary("Set type", TransactionPurpose.NonUser)) { Type = type; TransactionRecruiter.EnlistPropertyItem(this, nameof(Type), oldType, type, (t, __) => { Type = t; }, TransactionHints.Semantic); UpdateTerminalsFromDataType(type); transaction?.Commit(); } } }