question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: Add `CanAttachFrom` Behavior

See original GitHub issue

While CanAttachTo is really helpful, sometimes it’s beneficial to have the inverse, i.e. CanAttachFrom when you want to permit/deny attachment from a port.

It’s the same logic (as CanAttachTo) but swapping the ports.

//PortModel.cs
public virtual bool CanAttachFrom(PortModel port)
    => port != this && !port.Locked && Parent != port.Parent;
//DragNewLinkBehavior.cs
if (!(model is PortModel port) || !port.CanAttachFrom(_ongoingLink.SourcePort!) || !_ongoingLink.SourcePort!.CanAttachTo(port))
{
    Diagram.Links.Remove(_ongoingLink);
    _ongoingLink = null;
    return;
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
zHaytamcommented, Oct 16, 2022

In 3.0.0, another option was added for the links factory to return null in order to not create an ongoing link. This can also be used to do any checks from the source port or node and decide whether to create a link or not.

0reactions
zHaytamcommented, May 3, 2022

Very sorry for the late reply, I thought I did a long time ago…

In your example (picture), how can the user connect red to blue? In CanAttachTo, you have both ports, so you should be able to test on both of them no?

public override bool CanAttachTo(PortModel port)
{
            // Checks for same-node/port attachments
            if (!base.CanAttachTo(port))
                return false;

            // Only able to attach to the same port type
            if (!(port is ColoredPort cp))
                return false;

            return IsRed == cp.IsRed || IsBlue == cp.IsBlue || IsGreen == cp.IsGreen;
}

This would work for all cases no? Do you have a running example that shows the issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop adding features to your product. Start crafting behaviors.
The best way for increasing the usage and value of the product is crafting the product from a behavioral perspective instead of feature...
Read more >
Configure Distribution Stamp Properties - Attachments Tab
The Attachments tab allows for the configuration of indexing additional documents to a smart form, either from the DocLink repository or from a...
Read more >
AIX shared memory behavior for 32-bit applications
How does AIX handle shared memory for 32-bit applications, including IBM MQ C, C++ and COBOL server applications, and IBM MQ Java and...
Read more >
Can not attach file from Onedrive to mail on iphone
Hi, after selecting < to attach document, go to Browse, on your right with three dots:••• Press, select Edit, then you can add...
Read more >
Add Line Items Using the Grid View
To reduce the time that it takes to conduct a one-by-one creation, you can add line items by using the Grid View.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found