public void Should_Set_And_Get_Complex_Values() { var entity = new MyEntity(); var obj = new MyComplexType { Name = "John", Age = 42, Inner = new List <MyComplexTypeInner> { new MyComplexTypeInner { Value1 = "A", Value2 = 2 }, new MyComplexTypeInner { Value1 = "B", Value2 = null }, new MyComplexTypeInner { Value1 = null, Value2 = null }, null } }; entity.SetData("ComplexData", obj); var obj2 = entity.GetData <MyComplexType>("ComplexData"); obj.ToJsonString().ShouldBe(obj2.ToJsonString()); entity.SetData("ComplexData", (MyComplexType)null); entity.GetData <MyComplexType>("ComplexData").ShouldBe(null); }
static MyType() { var myParams = new TParameter(); ParameterString = myParams.ParameterString; ParameterComplex = myParams.ParameterComplex; }
public Object Clone(){ MyComplexType mct = new MyComplexType(this.Name + " Clone"); for(int i = 0; i<this.StringList.Count; i++){ mct.StringList[i] = this.StringList[i]; } return mct; }
public static void Main(){ MyComplexType mct1 = new MyComplexType("mct1"); mct1.StringList[0] = "Hello"; mct1.StringList[1] = "World"; Console.WriteLine(mct1); MyComplexType mct2 = (MyComplexType)mct1.Clone(); Console.WriteLine(mct2); mct2.StringList[0] = "New String"; Console.WriteLine(mct1); Console.WriteLine(mct2); MyComplexType mct3 = (MyComplexType)mct2.GetMemberwiseClone(); Console.WriteLine(mct3); mct2.StringList[2] = "Another String"; Console.WriteLine(mct2); Console.WriteLine(mct3); } // end main
public void FormatForToString() { MySimpleType simple = new MySimpleType() { number = 1, word = "test" }; MyComplexType complex = new MyComplexType() { complexWord = "complex", simpleType = simple }; MyComplexInheritedType inherited = new MyComplexInheritedType() { inheritedWord = "inherited", complexWord = "complex", simpleType = simple }; MyNestdComplexType nested = new MyNestdComplexType() { nestedWord = "nested", complexType = complex }; MyNestdComplexType nestedInherited = new MyNestdComplexType() { nestedWord = "nested", complexType = inherited }; Assert.AreEqual("{ number = 1 | word = test }", simple.ToString()); Assert.AreEqual("{ complexWord = complex | simpleType = { number = 1 | word = test } }", complex.ToString()); Assert.AreEqual("{ complexWord = complex | simpleType = { number = 1 | word = test } | inheritedWord = inherited }", inherited.ToString()); Assert.AreEqual("{ nestedWord = nested | complexType = { complexWord = complex | simpleType = { number = 1 | word = test } } }", nested.ToString()); Assert.AreEqual("{ nestedWord = nested | complexType = { complexWord = complex | simpleType = { number = 1 | word = test } | inheritedWord = inherited } }", nestedInherited.ToString()); }
public MyComplexType GetComplexType(MyComplexType ct) { return(new MyComplexType()); }
public IEnumerable <MyModel> Get([FromUri] MyComplexType input) { // input is not null as long as [FromUri] is present in the method arg }