GithubHelp home page GithubHelp logo

expando's People

Contributors

rickstrahl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expando's Issues

Concrete property and indexer return not same value

In the case of existing property - access through property or through index should return the same value, but actually an indexer is stored in Properties and not in Object

   public class ObjWithProp : Expando
{
    public string SomeProp { get; set; }
}

[TestFixture]
[Ignore]
public class ExistingProps
{

    [Test]
    public void Given_Porp_When_SetWithIndex_Then_PropsValue()
    {
        //arrange
        ObjWithProp obj = new ObjWithProp();
        //act
        obj.SomeProp = "value1";
        obj["SomeProp"] = "value2";
        //assert
        Assert.AreEqual("value2",obj.SomeProp);

    }
}

remove property from Westwind.Utilities.Dynamic.Expando

how to remove property from Westwind.Utilities.Dynamic.Expando

my tries but app crash
any way to remove property from object

public class  modelStatic : Westwind.Utilities.Dynamic.Expando
{
public list<string >attachments{get;set;}
....
.. // so other properties 

}
  dynamic dynamicModel = new ExpandoObject();
                dynamicModel = modelStatic;
                ((IDictionary<String, Object>)dynamicModel)?.Remove("attachments");

NuGet Package

Is this available as a NuGet package? Westwind.Utilities doesn't seem to ship with this project.

performance

I have used the library extensively on a large project where - node'js would be a good fit. I had porformance issues that I suspect trace to it - I would like to improve that - suggestions ?

I mean around 17K rows can take around couple of hours to process

Unity support

I'm trying to use your project in Unity 3D (added dll to the Unity project). It works for the most part but the TwoWayJsonSerializeExpandoTyped test results in

{
  "Properties": {
    "Entered": "2019-02-28T14:38:38.3122796-06:00",
    "Company": "West Wind",
    "Accesses": 10,
    "Address": "32 Kaiea",
    "TotalOrderAmounts": 51233.99
  },
  "email": "[email protected]",
  "password": "Seekrit23",
  "name": "Rick",
  "active": true
}

I tried the same test directly from Expando and get the expected result

{
  "Email": "[email protected]",
  "Password": "Seekrit23",
  "Name": "Rick",
  "Active": true,
  "ExpiresOn": null,
  "Entered": "2019-02-28T14:53:19.3184712-06:00",
  "Company": "West Wind",
  "Accesses": 10,
  "Address": "32 Kaiea",
  "TotalOrderAmounts": 51233.99
}

Any ideas why they would have different results?

Indexer and property getters different values for strongly typed class after cast from dynamic

Inheriting from Expando is great - but if the inheriting class implements strongly typed properties, setting a property dynamically causes some problems. If the types don't agree, casting the dynamic instance back to its static type will give different values for the property depending on whether you use the indexer or property to access it. For example

class Person : Expando
{
    public string Name {get; set;}
}

void Main()
{
    dynamic ex = new Person();
    ex.Name = 100;
    var person = ex as Person;
    Console.WriteLine(person.Name);
    //>> null
    Console.WriteLine(person ["Name"]);
    //>> 100
}

Serialization of DateTimeOffset

My apologies if this isn't the correct thread, but it would appear that the Serialization/Deserialization of DateTimeOffset in an Expando object is not handled.

Thank you for such a comprehensive utilities library. I'm glad I've found it.

I want to add properties of base class to serialization, but I'm getting weird error "Parameter count mismatch."

public class A : Expando
{
   public string Prop1 { get; set; }
}

public class B : A 
{
   public string Prop2 { get; set; }
}

I want to serialize B, but only own properties are serialized, because of this line :

_InstancePropertyInfo = Instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
so I replaced it with this:

_InstancePropertyInfo = Instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public) ;
Now, I'm getting weird error during serialization:

"Parameter count mismatch."

Callstack says:

at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at Expando.<GetProperties>d__19.MoveNext() in ......
   at Expando.<GetDynamicMemberNames>d__9.MoveNext() in .....
   at JsonSerializerInternalWriter.SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)

JSON.NET [JsonRequired] is broken

As demonstrated by the test case below, the behaviour of [JsonRequired] from Json.NET is broken.

    [TestFixture]
    public class JsonRequiredTests
    {
        [Test]
        public void TestJsonRequired()
        {
            // Passes
            Assert.That(() => JsonConvert.DeserializeObject<MyTestCase>("{}"), Throws.InstanceOf<JsonSerializationException>());

            // Fails
            Assert.That(() => JsonConvert.DeserializeObject<MyTestCase2>("{}"), Throws.InstanceOf<JsonSerializationException>());
        }

        public class MyTestCase
        {
            [JsonRequired]
            public string SomeProperty { get; set; }
        }

        public class MyTestCase2 : Westwind.Utilities.Expando
        {
            [JsonRequired]
            public string SomeProperty { get; set; }
        }
    }

Could you add only json version (Without Xml support)

It seems a part of code is used for XML serialization operations, but XML is obsolote for most of us.
If there is performance penalty because of XML feature, could you add only json version of this great work?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.