Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6026057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:23:23+00:00 2026-05-23T04:23:23+00:00

I have an object ConnectableProperty that hooks up one property to another, and requires

  • 0

I have an object “ConnectableProperty” that hooks up one property to another, and requires I feed it Func. Now I have 2 types at the moment – Scalar and Color. Both are castable to each other via explicit operators. For some reason I can’t feed a Func<double, double, Scalar> to Func<double, double Color>, even though Scalar can cast to Color. What’s the deal?

To clarify, i’ve added the code. Note that connectable properties are the “inputs”. The outputs (that can be plugged in) are Methods that have that signature.

Here’s ConnectableProperty

public sealed class ConnectableProperty<T> : IEquatable<T>, IGetXY<T> where T : IValue<T>
{
    private T _value;
    public T Value { get { return _value; } set { _value = value; } }

    public INode ParentNode { get; private set; }
    public ValueConnection<T> Connection { get; set; }
    public INode ConnectionFrom { get { return !IsConnected ? null : Connection.FromNode; } }
    public bool IsConnected { get { return Connection == null; } }

    public ConnectableProperty(INode parentNode, T value)
    {
        ParentNode = parentNode;
        _value = value;
    }

    public T GetXY(double x, double y)
    {
        return IsConnected 
            ? Connection.FromValue(x, y) 
            : _value;
    }

    public void Connect(INode fromNode, Func<double, double, T> getXY)
    {
        Connection = new ValueConnection<T>(fromNode, ParentNode, getXY, this);
    }

    public void Disconnect()
    {
        Connection = null;
    }

    public bool Equals(T other)
    {
        return _value.Equals(other);
    }

    public static implicit operator T(ConnectableProperty<T> connectableProperty)
    {
        return connectableProperty._value;
    }
}

And ValueConnection:

public class ValueConnection<T>
{
    public INode FromNode { get; private set; }
    public INode ToNode { get; private set; }

    public Func<double, double, T> FromValue { get; private set; }
    public ConnectableProperty<T> ToValue { get; private set; }

    public ValueConnection(INode fromNode, INode toNode, Func<double, double, T> fromValue, ConnectableProperty<T> toValue)
    {
        // TODO: Implement INPC type thing

        FromNode = fromNode;
        ToNode = toNode;

        FromValue = fromValue;
        ToValue = toValue; 
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:23:24+00:00Added an answer on May 23, 2026 at 4:23 am

    No, you won’t be able to perform that conversion directly, and I wouldn’t expect to be able to – but you could easily write a pair of methods to perform it for you:

    public Func<double, double, Scalar> ConvertFunc(Func<double, double, Color func)
    {
        return (x, y) => (Scalar) func(x, y);
    }
    
    public Func<double, double, Color> ConvertFunc(Func<double, double, Scalar func)
    {
        return (x, y) => (Color) func(x, y);
    }
    

    When you’ve got a delegate which is meant to return a particular type, that has to be able to be invoked directly and return a value of the appropriate type. The caller shouldn’t have to know that even though they’ve got a Func<X>, if they want to get an X out of it, they’ll need to cast the result to an X.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that holds several value types and other objects. I want
I have object A which in turn has a property of type Object B
I have two tables: object that has object_id column and avalues that have object_id
I think I read somewhere that some modules only have object oriented interfaces (
I have an object that represents a food item to order at a restaurant.
I have an object that is mapped to a cookie as a serialized base-64
I have an object in a multi-threaded environment that maintains a collection of information,
I have object called Foo. Right now it implements IFoo which has a lot
i have two processes so process one generate some container object and send it
Let's imagine that we have object Animal $.Animal = function(options) { this.defaults = {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.