Exemple #1
0
        public void Dynamic()
        {
            dynamic myDyn = new MyDynamicObject();
            string  abc   = myDyn.meLoInvento;

            ((INotifyPropertyChanged)myDyn).PropertyChanged += (sender, e) =>
            {
                string addedProperty = e.PropertyName;
            };

            string  jsonText   = @"{ ""name"": ""matias"" }";
            dynamic someObject = JsonConvert.DeserializeObject <ExpandoObject>
                                 (
                jsonText,
                new ExpandoObjectConverter()
                                 );

            Synchronized sync = new Synchronized();

            if (sync.GetType().GetProperty("x") != null)
            {
            }

            var     a = "";
            dynamic b = new Synchronized();

            b.DoStuff11111111();

            b = 11;

            // Expando objects
            dynamic expando = new ExpandoObject();

            expando.text    = "hola mundo";
            expando.number  = 30;
            expando.doStuff = new Action(() =>
            {
                expando.x = 11;
            });
            expando.doStuff();

            IDictionary <string, object> dict = (IDictionary <string, object>)expando;

            if (dict.ContainsKey("doStuff"))
            {
                expando.doStuff();
            }
        }
Exemple #2
0
        public void TestMethod1()
        {
            Synchronized synchro = new Synchronized();

            Task.Run
            (
                () =>
            {
                for (int i = 0; i < 1000; i++)
                {
                    synchro.Customers.Add(new Customer());
                }
            }
            );

            for (int i = 0; i < 1000; i++)
            {
                Task.Run(() => synchro.ThreadSynchronization());
            }

            synchro.ThreadSynchronization();
        }