S
sklett
I know the assignment operator is shallow and I know it can't be overloaded.
What I can't find (on the web) is a best practice or guideline for assigning
the values of one instance to the value of another instance of objects.
In C++ I would overload the assignment operator to achieve what I want. But
in C# I'm not seeing how to do this other than creating a member function
like "T.DeepAssign(T source)"
The problem is that when you have controls bound to the properties of an
object that support INotifyPropertyChanged the Binding instances are
referencing the original instance supplied in the Binding constructor. So
if I change the reference that the Binding is pointing to no events are
fired to let the Binding know. I hope that makes sense. I'm typing this
like I have it all figured out but I'm really just getting my head around
still.
I'd rather not re-bind everything when my reference changes. All I'm really
looking for is best practice (interface to support, method name,
anything....) for batch property assignment.
IE:
<code>
Type.DeepAssign(Type source)
{
this.Prop1 = source.Prop1;
this.Prop2 = source.Prop2;
}
</code>
A method like the above would notify my Bindings that the properties have
changed and all will be well in the world.
Am I missing some basic concept here? I'm surprised that I'm even needing
to think about this so much, seems there would be something in place to
assign the properties of one object to another.
-Steve
What I can't find (on the web) is a best practice or guideline for assigning
the values of one instance to the value of another instance of objects.
In C++ I would overload the assignment operator to achieve what I want. But
in C# I'm not seeing how to do this other than creating a member function
like "T.DeepAssign(T source)"
The problem is that when you have controls bound to the properties of an
object that support INotifyPropertyChanged the Binding instances are
referencing the original instance supplied in the Binding constructor. So
if I change the reference that the Binding is pointing to no events are
fired to let the Binding know. I hope that makes sense. I'm typing this
like I have it all figured out but I'm really just getting my head around
still.
I'd rather not re-bind everything when my reference changes. All I'm really
looking for is best practice (interface to support, method name,
anything....) for batch property assignment.
IE:
<code>
Type.DeepAssign(Type source)
{
this.Prop1 = source.Prop1;
this.Prop2 = source.Prop2;
}
</code>
A method like the above would notify my Bindings that the properties have
changed and all will be well in the world.
Am I missing some basic concept here? I'm surprised that I'm even needing
to think about this so much, seems there would be something in place to
assign the properties of one object to another.
-Steve