System Library Common Framework
Search Results for

    *.Benchmark*,*.Tests*,*.ApiTests*,*.BaseTest*,DelegateJsonConverter,CalleeCancelledRequestException,ClientResponse,ContentType,OutputCachePolicy
    Show / Hide Table of Contents Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Framework.Extensions SystemLibrary.Common.Framework.Net.dll

    This class contains extension methods for Dynamic objects

    Remarks
    X

    Current version of C# does not allow extension methods on 'dynamic', hence these are static methods

    DynamicExtensions

    public static class DynamicExtensions

    Inheritance
    object
    DynamicExtensions
    Examples
    Arguments
    X

    Methods

    Merge dynamic objects into a one new dynamic object

    The latter updating value takes precedence if both objects contains same property name

    Remarks
    X

    Current version of C# does not allow extension methods on 'dynamic', hence these are static methods

    public static dynamic Merge(dynamic source, params object[] updates)

    X
    var a = new
    {
        firstName = "world",
        age = 1
    };
    var b = new
    {
        firstName = "hello",
        Age = 2
    };
    var c = new 
    {
       Age = 10   
    }
    
    var d = DynamicExtensions.Merge(a, b, c);
    
    // d contains 3 properties: firstName, age, Age
    // d's property values are now: hello, 1, 10
    // var dictionary = d as IDictionary<string, object>
    // d can be cast to dictionary
    // dictionary["Age"] will return 10
    X
    Methods arguments
    Type Name Description
    dynamic source

    An anonymous/dynamic object

    object[] updates

    One or more anonymous/dynamic objects, but if error occurs, cast the 'updating' objects to an actual object before invoking this method

    X
    Type Description
    dynamic

    Returns a new dynamic object with the merge result, can be casted to IDictionary<string, object>

    }

    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Framework