public override void WriteToStream(IndentStream stream) { if (!string.IsNullOrEmpty(JoinType)) { stream.Write($"{JoinType.ToUpper()} "); } if (!string.IsNullOrEmpty(OuterType)) { stream.Write($"{OuterType.ToUpper()} "); } stream.Write("JOIN "); SecondTable.WriteToStream(stream); if (AliasName != null) { stream.Write(" "); AliasName.WriteToStream(stream); } if (WithOptions != null && WithOptions.Count > 0) { stream.Write(" WITH("); WithOptions.ToUpper().WriteToStreamWithComma(stream); stream.Write(")"); } if (JoinOnExpr != null) { stream.Write(" ON "); JoinOnExpr.WriteToStream(stream); } }
static void Main(string[] args) { OuterType outerType = new OuterType(); outerType.testInnerType(); Console.ReadKey(); }
public void ReferenceBackedByObjectTypeTest6() { var innerType = new InnerType() { A = "this is a test" }; var strongTypeSource = new OuterType() { InnerType = innerType, PrimitiveList = Enumerable.Range(20, 10).ToList(), ComplexList = new List <InnerType>() { innerType }, String = "ok" }; strongTypeSource.InnerType.C = strongTypeSource; OuterType source = strongTypeSource; var ultraMapper = new Mapper(); var target = ultraMapper.Map <object>(source); Assert.IsFalse(Object.ReferenceEquals(source, target)); Assert.IsTrue(source.GetType() == target.GetType()); Assert.IsTrue(target.GetType() == typeof(OuterType)); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public void ReferenceSimpleTest() { var innerType = new InnerType() { A = "this is a test" }; var source = new OuterType() { InnerType = innerType, PrimitiveList = Enumerable.Range(20, 10).ToList(), ComplexList = new List <InnerType>() { innerType }, String = "ok" }; source.InnerType.C = source; var target = new OuterType(); var ultraMapper = new Mapper(); ultraMapper.Map(source, target); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (this.GetType() != obj.GetType()) { return(false); } HistogramEntry other = (HistogramEntry)obj; if (!OuterType.Equals(other.OuterType)) { return(false); } if (this.amount != other.amount) { return(false); } if (this.id != other.id) { return(false); } return(true); }
public void AccessMemberOfNonGenericNestedInGeneric() { Func <dynamic, int> dynamicDelegate = e => e.Id; var dto = new OuterType <int> .MyEntity { Id = 1, Name = "Foo" }; Assert.Equal(1, dynamicDelegate(dto)); }
public void SetOuter(OuterType type) { OType = type; //if (obj is TextBox) //{ // Outer = obj; // OType = OuterType.TextBox; //} }
public override int GetHashCode() { const int prime = 31; int result = 1; result = prime * result + OuterType.GetHashCode(); result = prime * result + this.amount; result = prime * result + this.id; return(result); }
public void PlainNetMapperCanHandleComplexTypes() { OpenTypeKind mapsTo; Assert.IsTrue(mapper.CanHandle(typeof(OuterType), out mapsTo, CanHandle)); Assert.AreEqual(OpenTypeKind.CompositeType, mapsTo); OpenType outerType = mapper.MapType(typeof(OuterType), MapType); Assert.AreEqual(OpenTypeKind.CompositeType, outerType.Kind); CompositeType outerCompositeType = (CompositeType)outerType; Assert.AreEqual("OuterType", outerCompositeType.TypeName); Assert.AreEqual("OuterType", outerCompositeType.Description); Assert.IsTrue(outerCompositeType.ContainsKey("Inner")); Assert.AreEqual(1, outerCompositeType.KeySet.Count); OpenType innerType = outerCompositeType.GetOpenType("Inner"); Assert.AreEqual(OpenTypeKind.CompositeType, innerType.Kind); CompositeType innerCompositeType = (CompositeType)innerType; Assert.AreEqual("InnerType", innerCompositeType.TypeName); Assert.AreEqual("InnerType", innerCompositeType.Description); Assert.IsTrue(innerCompositeType.ContainsKey("Value")); Assert.AreEqual(SimpleType.String, innerCompositeType.GetOpenType("Value")); Assert.AreEqual(1, outerCompositeType.KeySet.Count); OuterType value = new OuterType(); value.Inner = new InnerType(); value.Inner.Value = "Inner text value"; object mappedValue = mapper.MapValue(typeof(OuterType), outerType, value, MapValue); Assert.IsTrue(mappedValue is ICompositeData); ICompositeData outerCompositeData = (ICompositeData)mappedValue; Assert.IsTrue(outerCompositeType.IsValue(outerCompositeData)); Assert.IsTrue(outerCompositeData.ContainsKey("Inner")); Assert.AreEqual(1, outerCompositeData.Values.Count()); Assert.IsTrue(outerCompositeData["Inner"] is ICompositeData); ICompositeData innerCompositeData = (ICompositeData)outerCompositeData["Inner"]; Assert.IsTrue(innerCompositeData.ContainsKey("Value")); Assert.AreEqual(1, innerCompositeData.Values.Count()); Assert.AreEqual(value.Inner.Value, innerCompositeData["Value"]); }
public void CreateNewInstance() { var innerType = new InnerType() { A = "fadadfsadsffsd" }; var source = new OuterType() { PrimitiveList = Enumerable.Range(0, 10).ToList(), InnerType = new InnerType() { A = "a", B = "b" }, ComplexList = new List <InnerType>() { new InnerType() { A = "a", B = "b", }, new InnerType() { A = "c", B = "d", } } }; var target = new OuterType() { InnerType = innerType, PrimitiveList = Enumerable.Range(20, 10).ToList() }; var primitiveList = target.PrimitiveList; var ultraMapper = new Mapper(cfg => { cfg.ReferenceBehavior = ReferenceBehaviors.CREATE_NEW_INSTANCE; }); ultraMapper.Map(source, target); Assert.IsFalse(Object.ReferenceEquals(target.InnerType, innerType)); Assert.IsFalse(Object.ReferenceEquals(target.PrimitiveList, primitiveList)); }
public void RemoveReferenceTypeNullChecks_IfTrueValueIsNOTConstantOfNull_ShouldReturnOriginalExpression() { var t = new OuterType { InnerType = new InnerType { Value = 123 } }; Expression <Func <bool> > initialExpression = () => (t.InnerType == null ? 999 : t.InnerType.Value) == (int?)123; Expression actualExpression = ConditionalNullRemoverVisitor.RemoveReferenceTypeNullChecks(initialExpression); Assert.AreEqual(initialExpression.ToString(), actualExpression.ToString()); }
public void RemoveReferenceTypeNullChecks_WhenConditionalExpTestIsANotEqualityCheck_And_RightChildOfTestExpIsConstantExpOfNull_And_IfFalseValueIsConstantOfNull_ShouldReturnIfFalseExpression() { var t = new OuterType { InnerType = new InnerType { Value = 123 } }; Expression <Func <bool> > initialExpression = () => (t.InnerType != null ? t.InnerType.Value: null) == (int?)123; Expression <Func <bool> > expectedExpression = () => t.InnerType.Value == (int?)123; Expression actualExpression = ConditionalNullRemoverVisitor.RemoveReferenceTypeNullChecks(initialExpression); Assert.AreEqual(expectedExpression.ToString(), actualExpression.ToString()); }
public void UseTargetInstanceIfNotNull() { var innerType = new InnerType() { A = "fadadfsadsffsd" }; var source = new OuterType() { InnerType = innerType, PrimitiveList = Enumerable.Range(0, 10).ToList(), ComplexList = new List <InnerType>() { innerType } }; var target = new OuterType() { InnerType = new InnerType(), PrimitiveList = Enumerable.Range(20, 10).ToList(), ComplexList = new List <InnerType>() { innerType } }; var beforeMapInnerType = target.InnerType; var beforeMapPrimitiveList = target.PrimitiveList; var beforeMapComplexList = target.ComplexList; var ultraMapper = new Mapper(cfg => { cfg.ReferenceBehavior = ReferenceBehaviors.USE_TARGET_INSTANCE_IF_NOT_NULL; }); ultraMapper.Map(source, target); Assert.IsTrue(Object.ReferenceEquals(target.InnerType, beforeMapInnerType)); Assert.IsTrue(Object.ReferenceEquals(target.PrimitiveList, beforeMapPrimitiveList)); Assert.IsTrue(Object.ReferenceEquals(target.ComplexList, beforeMapComplexList)); }
public void NestingAndReferringTheSameObject() { var obj = new OuterType.InnerType { A = "a", B = "b" }; obj.Inner = obj; var source = new OuterType() { Move = obj }; var ultraMapper = new Mapper(cfg => cfg.IsReferenceTrackingEnabled = true); var target = ultraMapper.Map(source); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public void NestingAndReferringTheSameType() { var source = new OuterType() { Move = new OuterType.InnerType { A = "a", B = "b", Inner = new OuterType.InnerType() { A = "c", B = "b" } } }; var ultraMapper = new Mapper(); var target = ultraMapper.Map(source); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public static void SetLogOuter(OuterType type) { log.SetOuter(type); }
public OuterType() { _instance = this; }
public void SetOuter(OuterType type) { OType = type; }
public void PlainNetMapperCanHandleComplexTypes() { OpenTypeKind mapsTo; Assert.IsTrue(mapper.CanHandle(typeof(OuterType), out mapsTo, CanHandle)); Assert.AreEqual(OpenTypeKind.CompositeType, mapsTo); OpenType outerType = mapper.MapType(typeof(OuterType), MapType); Assert.AreEqual(OpenTypeKind.CompositeType, outerType.Kind); CompositeType outerCompositeType = (CompositeType)outerType; Assert.AreEqual("OuterType", outerCompositeType.TypeName); Assert.AreEqual("OuterType", outerCompositeType.Description); Assert.IsTrue(outerCompositeType.ContainsKey("Inner")); Assert.AreEqual(1, outerCompositeType.KeySet.Count); OpenType innerType = outerCompositeType.GetOpenType("Inner"); Assert.AreEqual(OpenTypeKind.CompositeType, innerType.Kind); CompositeType innerCompositeType = (CompositeType) innerType; Assert.AreEqual("InnerType", innerCompositeType.TypeName); Assert.AreEqual("InnerType", innerCompositeType.Description); Assert.IsTrue(innerCompositeType.ContainsKey("Value")); Assert.AreEqual(SimpleType.String, innerCompositeType.GetOpenType("Value")); Assert.AreEqual(1, outerCompositeType.KeySet.Count); OuterType value = new OuterType(); value.Inner = new InnerType(); value.Inner.Value = "Inner text value"; object mappedValue = mapper.MapValue(typeof(OuterType), outerType, value, MapValue); Assert.IsTrue(mappedValue is ICompositeData); ICompositeData outerCompositeData = (ICompositeData)mappedValue; Assert.IsTrue(outerCompositeType.IsValue(outerCompositeData)); Assert.IsTrue(outerCompositeData.ContainsKey("Inner")); Assert.AreEqual(1, outerCompositeData.Values.Count()); Assert.IsTrue(outerCompositeData["Inner"] is ICompositeData); ICompositeData innerCompositeData = (ICompositeData) outerCompositeData["Inner"]; Assert.IsTrue(innerCompositeData.ContainsKey("Value")); Assert.AreEqual(1, innerCompositeData.Values.Count()); Assert.AreEqual(value.Inner.Value, innerCompositeData["Value"]); }