Posts

Showing posts from December, 2013

Dependency Properties' key features

In progress... The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs. Main features: Reduced memory footprint   90% of the properties of a UI control typically stay at its initial values   The default values are stored once within the dependency property. Value inheritance   Value resolution strategy.     If no local value is set, the dependency property navigates up the logical tree until it finds a value.   Not good practice cause performance impact.   The main example is the DataContext.   Property value inheritance is not the default property system behavior; a property must be established with a particular metadata setting in order to cause that property to initiate property value inheritance on child elements. Change notification   used by the databinding   used by a custom logic Details: Value Precedence   ... Metadata Overrides    Call in a constructor the AnyProperty.OverrideMetadat

Binding.Path syntax

All possible things of the Binding's Path See Binding.Path Property - Remarks (MSDN)

Explicit interface implementation Anti-pattern.

Explicit interface definition forces the members to be exposed only when you are working with the interface directly. The main words are: Unexpected Behavior Mostly used: Implementing of several interfaces with the same members required different implementation. Struggle with dependencies (very doubtful). Code with using more derived types knows nothing about interface's members that were implemented explicitly. For example in a ASP.NET MVP (Web Forms) control hide member used by presenter. Work around for having same member with different logic in an interface and its derived class. Some silly protection (by a run-time exception) from using of inappropriate interface members. As an example the array's explicit implementation for the ICollection<T>.Add() that will throw the NotSupportedException "Collection of a fixed size".  Famous drawbacks: It's greasy messy awful coding especially when used without a serious reason. It's definitely not

The C# Dynamic Properties' implementation and a full Expando

It's implemented by the DynamicObject from .NET Framework. Just an straightforward example in the MSDN - DynamicObject Class . Wow! But also we have the ExpandoObject . Some tip from MSDN The   ExpandoObject   class is an implementation of the dynamic object concept that enables getting, setting, and invoking members. If you want to define types that have their own dynamic dispatch semantics, use the   DynamicObject   class. If you want to define how dynamic objects participate in the interoperability protocol and manage DLR fast dynamic dispatch caching, create your own implementation of the   IDynamicMetaObjectProvider   interface. dynamic sampleObject = new ExpandoObject(); sampleObject.test = "Dynamic Property" ; // Create a new event and initialize it with null. sampleObject.sampleEvent = null ; // Add an event handler. sampleObject.sampleEvent += new EventHandler(SampleHandler); Main features: Dynamic properties and methods Enumerating and Dele