示例#1
0
 public void LinqAF()
 {
     foreach (var item in Source1.Reverse())
     {
         GC.KeepAlive(item);
     }
 }
示例#2
0
 public void LinqAF()
 {
     foreach (var str in Source1.Concat(Source2))
     {
         System.GC.KeepAlive(str);
     }
 }
示例#3
0
 public void LinqAF()
 {
     foreach (var str in Source1.ToArray())
     {
         System.GC.KeepAlive(str);
     }
 }
        public void Map_Bind_Success()
        {
            TinyMapper.Bind<SourceItem, TargetItem>();

            TinyMapper.Bind<Source1, Target1>(config =>
            {
                config.Bind(from => from.String, to => to.MyString);
                config.Bind(from => from.Int, to => to.MyInt);
                config.Bind(from => from.SourceItem, to => to.TargetItem);
            });

            var source = new Source1
            {
                Bool = true,
                Byte = 5,
                Int = 9,
                String = "Test",
                DateTime = DateTime.Now,
                SourceItem = new SourceItem { Id = Guid.NewGuid() }
            };

            var actual = TinyMapper.Map<Target1>(source);

            Assert.Equal(source.Bool, actual.Bool);
            Assert.Equal(source.String, actual.MyString);
            Assert.Equal(source.Byte, actual.Byte);
            Assert.Equal(source.Int, actual.MyInt);
            Assert.Equal(source.DateTime, actual.DateTime);
            Assert.Equal(source.SourceItem.Id, actual.TargetItem.Id);
        }
示例#5
0
        public void Map_Bind_Success()
        {
            TinyMapper.Bind <SourceItem, TargetItem>();

            TinyMapper.Bind <Source1, Target1>(config =>
            {
                config.Bind(from => from.String, to => to.MyString);
                config.Bind(from => from.Int, to => to.MyInt);
                config.Bind(from => from.SourceItem, to => to.TargetItem);
            });

            var source = new Source1
            {
                Bool       = true,
                Byte       = 5,
                Int        = 9,
                String     = "Test",
                DateTime   = DateTime.Now,
                SourceItem = new SourceItem {
                    Id = Guid.NewGuid()
                }
            };

            var actual = TinyMapper.Map <Target1>(source);

            Assert.Equal(source.Bool, actual.Bool);
            Assert.Equal(source.String, actual.MyString);
            Assert.Equal(source.Byte, actual.Byte);
            Assert.Equal(source.Int, actual.MyInt);
            Assert.Equal(source.DateTime, actual.DateTime);
            Assert.Equal(source.SourceItem.Id, actual.TargetItem.Id);
        }
示例#6
0
文件: Select.cs 项目: bonomali/Ibasa
        public override double Evaluate(double x, double y)
        {
            double controlValue = Control.Evaluate(x, y);

            if (controlValue < (LowerBound - EdgeFalloff))
            {
                return(Source0.Evaluate(x, y));
            }
            else if (controlValue < (LowerBound + EdgeFalloff))
            {
                double lowerCurve = LowerBound - EdgeFalloff;
                double upperCurve = LowerBound + EdgeFalloff;
                double alpha      = (controlValue - lowerCurve) / (upperCurve - lowerCurve);
                return(Numerics.Functions.Lerp(
                           Source0.Evaluate(x, y), Source1.Evaluate(x, y), alpha));
            }
            else if (controlValue <= (UpperBound - EdgeFalloff))
            {
                return(Source1.Evaluate(x, y));
            }
            else if (controlValue <= (UpperBound + EdgeFalloff))
            {
                double lowerCurve = UpperBound - EdgeFalloff;
                double upperCurve = UpperBound + EdgeFalloff;
                double alpha      = (controlValue - lowerCurve) / (upperCurve - lowerCurve);
                return(Numerics.Functions.Lerp(
                           Source1.Evaluate(x, y), Source0.Evaluate(x, y), alpha));
            }
            else
            {
                return(Source0.Evaluate(x, y));
            }
        }
示例#7
0
 public void LinqAF()
 {
     foreach (var item in Source1.Except(Source2))
     {
         GC.KeepAlive(item);
     }
 }
示例#8
0
 public void LinqAF()
 {
     foreach (var str in Source1.Cast <string>())
     {
         System.GC.KeepAlive(str);
     }
 }
示例#9
0
        // Sort of registration of factory, because the channel setup is merely a factory containing the data provider instances.
        public void CreateChannel <T1, T2>(IChannelSetup <T1, T2> setup)
            where T1 : TBase1
            where T2 : TBase2
        {
            // Constructing or expanding the channel setup model in such a way while still having type information
            // is a better strategy. Doing it afterwards requires a lot more effort using reflection.
            // - Find endpoints and build configuration using them.
            var t1Endpoint       = Source1.GetEndpoint <T1>();
            var t1Extractor      = Source1.CreateResolver <T1>(); // Because constraint on this, as a whole this can't be moved into Source itself.
            var t1TypeConfig     = new TypeConfiguration <T1, TId>(t1Extractor, Source2.DefaultExtractorValue);
            var t1EndpointConfig = new EndpointConfiguration <T1, TId>(t1TypeConfig, t1Endpoint);

            var t2Endpoint       = Source2.GetEndpoint <T2>();
            var t2Extractor      = Source2.CreateResolver <T2>();
            var t2TypeConfig     = new TypeConfiguration <T2, TId>(t2Extractor, Source2.DefaultExtractorValue);
            var t2EndpointConfig = new EndpointConfiguration <T2, TId>(t2TypeConfig, t2Endpoint);

            var channelConfig = new ChannelConfiguration <T1, T2, TId, ItemMatch <T1, T2> >(t1EndpointConfig, t2EndpointConfig, setup.TypeTranslator);

            var plumber = PlumberFactory.Create(channelConfig, _rules);

            // Could move towards a construction where factories are registered instead of the actual objects for preventing to many channels linguering
            // around in memory. However, right now the channels needs to be singletons and run in sequence due to sqlite limitations of having only one
            // thread writing!
            var channel = setup.Create(channelConfig, plumber);

            _channels.Add(channel);
        }
示例#10
0
 public void LinqAF()
 {
     foreach (var item in Source1.Zip(Source2, ResultSelector))
     {
         GC.KeepAlive(item);
     }
 }
        public void Map_WithType_Success()
        {
            TinyMapper.Bind <Source1, Target1>();
            TinyMapper.Bind <Source1, Target2>();

            Source1 source  = CreateSource1();
            var     target1 = TinyMapper.Map <Target1>(source);

            Assert.Equal(target1.DateTime, default(DateTime));
            Assert.Equal(target1.FirstName, source.FirstName);

            Assert.Equal(target1.LatestString, source.LegacyString);
            Assert.Equal(target1.SourceString, source.LegacyTarget1String);
            Assert.NotEqual(target1.SourceString, source.LegacyTarget2String);

            Assert.Equal(target1.ProtectedString, source.SealedString);
            Assert.Equal(target1.TargetString, source.SealedTarget1String);
            Assert.NotEqual(target1.TargetString, source.SealedTarget2String);

            var target2 = TinyMapper.Map <Target2>(source);

            Assert.Equal(target2.DateTime, source.DateTime);
            Assert.Equal(target2.FirstName, source.FirstName);

            Assert.Equal(target2.LatestString, source.LegacyString);
            Assert.NotEqual(target2.SourceString, source.LegacyTarget1String);
            Assert.Equal(target2.SourceString, source.LegacyTarget2String);

            Assert.Equal(target2.ProtectedString, source.SealedString);
            Assert.NotEqual(target2.TargetString, source.SealedTarget1String);
            Assert.Equal(target2.TargetString, source.SealedTarget2String);
        }
示例#12
0
文件: Select.cs 项目: bonomali/Ibasa
        public override double Evaluate(double x, double y, double z, double w, double v, double u)
        {
            double controlValue = Control.Evaluate(x, y, z, w, v, u);

            if (controlValue < (LowerBound - EdgeFalloff))
            {
                return(Source0.Evaluate(x, y, z, w, v, u));
            }
            else if (controlValue < (LowerBound + EdgeFalloff))
            {
                double lowerCurve = LowerBound - EdgeFalloff;
                double upperCurve = LowerBound + EdgeFalloff;
                double alpha      = (controlValue - lowerCurve) / (upperCurve - lowerCurve);
                return(Numerics.Functions.SmoothStep(
                           Source0.Evaluate(x, y, z, w, v, u), Source1.Evaluate(x, y, z, w, v, u), alpha));
            }
            else if (controlValue < (UpperBound - EdgeFalloff))
            {
                return(Source1.Evaluate(x, y, z, w, v, u));
            }
            else if (controlValue < (UpperBound + EdgeFalloff))
            {
                double lowerCurve = UpperBound - EdgeFalloff;
                double upperCurve = UpperBound + EdgeFalloff;
                double alpha      = (controlValue - lowerCurve) / (upperCurve - lowerCurve);
                return(Numerics.Functions.SmoothStep(
                           Source1.Evaluate(x, y, z, w, v, u), Source0.Evaluate(x, y, z, w, v, u), alpha));
            }
            else
            {
                return(Source0.Evaluate(x, y, z, w, v, u));
            }
        }
示例#13
0
文件: Select.cs 项目: bonomali/Ibasa
        public override double Evaluate(double x)
        {
            double controlValue = Control.Evaluate(x);

            if (controlValue < (LowerBound - EdgeFalloff))
            {
                return(Source0.Evaluate(x));
            }
            else if (controlValue < (LowerBound + EdgeFalloff))
            {
                double lowerCurve = LowerBound - EdgeFalloff;
                double upperCurve = LowerBound + EdgeFalloff;
                double alpha      = (controlValue - lowerCurve) / (upperCurve - lowerCurve);
                return(Functions.SmoothStep(
                           Source0.Evaluate(x), Source1.Evaluate(x), alpha));
            }
            else if (controlValue < (UpperBound - EdgeFalloff))
            {
                return(Source1.Evaluate(x));
            }
            else if (controlValue < (UpperBound + EdgeFalloff))
            {
                double lowerCurve = UpperBound - EdgeFalloff;
                double upperCurve = UpperBound + EdgeFalloff;
                double alpha      = (controlValue - lowerCurve) / (upperCurve - lowerCurve);
                return(Functions.SmoothStep(
                           Source1.Evaluate(x), Source0.Evaluate(x), alpha));
            }
            else
            {
                return(Source0.Evaluate(x));
            }
        }
示例#14
0
 public void LinqAF()
 {
     foreach (var item in Source1.Join(Source2, KeySelector, KeySelector, ResultSelector, Comparer))
     {
         GC.KeepAlive(item);
     }
 }
示例#15
0
 public void LinqAF()
 {
     foreach (var item in Source1.Intersect(Source2, Comparer))
     {
         GC.KeepAlive(item);
     }
 }
示例#16
0
        protected override IObservable <IChangeSet <int> > CreateObservable()
        {
            var l = new List <IObservable <IChangeSet <int> > > {
                Source1.Connect(), Source2.Connect()
            };

            return(l.Except());
        }
示例#17
0
            public void LinqAF()
            {
                foreach (var str in Source1.DefaultIfEmpty(Value))
                {
                    GC.KeepAlive(str);
                }

                foreach (var str in Source2.DefaultIfEmpty(Value))
                {
                    GC.KeepAlive(str);
                }
            }
        public void Map_ConvertibleType_Success()
        {
            TinyMapper.Bind<Source1, Target1>();
            var source = new Source1
            {
                FirstName = "First",
                LastName = "Last"
            };

            var result = TinyMapper.Map<Target1>(source);

            Assert.Equal(string.Format("{0} {1}", source.FirstName, source.LastName), result.FullName);
        }
        public void Map_ConvertibleType_Success()
        {
            TinyMapper.Bind <Source1, Target1>();
            var source = new Source1
            {
                FirstName = "First",
                LastName  = "Last"
            };

            var result = TinyMapper.Map <Target1>(source);

            Assert.Equal(string.Format("{0} {1}", source.FirstName, source.LastName), result.FullName);
        }
示例#20
0
        public void Map_UncompatibleProperties_ReturnsRightMappedObject()
        {
            Source1 source = new Source1()
            {
                Age    = 5,
                Weight = 87.0f
            };
            Destination1 etalon = new Destination1();

            Destination1 dest = mapper.Map <Source1, Destination1>(source);

            Assert.AreEqual(dest, etalon);
        }
示例#21
0
        public void ConvertUsingDemo()
        {
            Source1 source = new Source1
            {
                Price = 2
            };

            ObjectsMapper <Source1, Destination1> mapper =
                ObjectMapperManager.DefaultInstance.GetMapper <Source1, Destination1>(
                    new DefaultMapConfig()
                    .ConvertUsing <object, decimal>(v => 50.1M)
                    );
            Destination1 destination = mapper.Map(source);
        }
        public void Map_Dictionary_Success()
        {
            TinyMapper.Bind<Source1, Target1>();

            var source = new Source1
            {
                Id = Guid.NewGuid(),
                Dictionary = new Dictionary<string, int> { { "Key1", 1 }, { "Key2", 2 } }
            };

            var target = TinyMapper.Map<Target1>(source);

            Assert.Equal(source.Id, target.Id);
            Assert.Equal(source.Dictionary, target.Dictionary);
        }
示例#23
0
        public void DifferentFormatsAndConfigInheritance()
        {
            var source1 = new Source1()
            {
                Date1 = new DateTime(2000, 12, 31),
                Date2 = new DateTime(2001, 12, 31),
                Date3 = new DateTime(2002, 12, 31)
            };

            var source2 = new Source2()
            {
                Date1 = new DateTime(2002, 12, 31),
                Date2 = new DateTime(2003, 12, 31),
                Date3 = new DateTime(2002, 12, 31)
            };

            var target = new Target();

            var ultraMapper = new Mapper(cfg =>
            {
                cfg.MapTypes <DateTime, string>(s => "default format");

                cfg.MapTypes <Source1, Target>()
                .MapTypeToMember <DateTime, string>(t => t.LongDateString, s => s.ToLongDateString())
                .MapTypeToMember <DateTime, string>(t => t.ShortDateString, s => s.ToShortDateString())
                .MapMember(s => s.Date1, t => t.LongDateString)
                .MapMember(s => s.Date2, t => t.ShortDateString)
                .MapMember(s => s.Date3, t => t.DefaultFormat);

                cfg.MapTypes <Source2, Target>()
                .MapTypeToMember <DateTime, string>(t => t.LongDateString, s => "long format")
                .MapMember(s => s.Date1, t => t.LongDateString)
                .MapMember(s => s.Date2, t => t.ShortDateString, s => "short format")
                .MapMember(s => s.Date3, t => t.DefaultFormat, s => "default format override");
            });

            ultraMapper.Map(source1, target);

            Assert.IsTrue(source1.Date1.ToLongDateString() == target.LongDateString);
            Assert.IsTrue(source1.Date2.ToShortDateString() == target.ShortDateString);
            Assert.IsTrue(target.DefaultFormat == "default format");

            ultraMapper.Map(source2, target);

            Assert.IsTrue(target.LongDateString == "long format");
            Assert.IsTrue(target.ShortDateString == "short format");
            Assert.IsTrue(target.DefaultFormat == "default format override");
        }
        public void Map_Arrays_Success()
        {
            _tinyMapper.Bind <Source1, Target1>();

            var source = new Source1
            {
                Ints    = new[] { 0, 1 },
                Bools   = new[] { true },
                Strings = new[] { "Nelibur", "TinyMapper" }
            };

            var target = _tinyMapper.Map <Target1>(source);

            XAssert.Equal(target.Ints, source.Ints);
            XAssert.Equal(target.Bools, source.Bools);
            XAssert.Equal(target.Strings, source.Strings);
        }
        public void Map_Arrays_Success()
        {
            TinyMapper.Bind<Source1, Target1>();

            var source = new Source1
            {
                Ints = new[] { 0, 1 },
                Bools = new[] { true },
                Strings = new[] { "Nelibur", "TinyMapper" }
            };

            var target = TinyMapper.Map<Target1>(source);

            Assert.Equal(target.Ints, source.Ints);
            Assert.Equal(target.Bools, source.Bools);
            Assert.Equal(target.Strings, source.Strings);
        }
        public void Map_Dictionary_Success()
        {
            TinyMapper.Bind <Source1, Target1>();

            var source = new Source1
            {
                Id         = Guid.NewGuid(),
                Dictionary = new Dictionary <string, int> {
                    { "Key1", 1 }, { "Key2", 2 }
                }
            };

            var target = TinyMapper.Map <Target1>(source);

            Assert.Equal(source.Id, target.Id);
            Assert.Equal(source.Dictionary, target.Dictionary);
        }
        public void Map_Collections_Success()
        {
            _tinyMapper.Bind <Source1, Target1>();

            var source = new Source1
            {
                Items = new List <Item1>
                {
                    new Item1
                    {
                        Int    = 1,
                        String = "2",
                        List   = new List <int> {
                            1, 2, 3
                        },
                        Bools = new[] { true, false }
                    },
                    new Item1
                    {
                        Int    = 2,
                        String = "3",
                        List   = new List <int> {
                            2, 3
                        },
                        Bools = new[] { false, false }
                    }
                }
            };
//            DynamicAssemblyBuilder.Get().Save();
            var actual = _tinyMapper.Map <Target1>(source);

            XAssert.Equal(source.Items.Count, actual.Items.Count);
            XAssert.Equal(source.Items1, actual.Items1);

            for (int i = 0; i < source.Items.Count; i++)
            {
                Item1 expectedItem = source.Items[i];
                Item2 actualItem   = actual.Items[i];

                XAssert.Equal(expectedItem.Bools, actualItem.Bools);
                XAssert.Equal(expectedItem.Int, actualItem.Int);
                XAssert.Equal(expectedItem.List, actualItem.List);
                XAssert.Equal(expectedItem.String, actualItem.String);
            }
        }
示例#28
0
        public void Map_BindCaseSensitive_Success()
        {
            TinyMapper.Bind <SourceItem, TargetItem>();

            TinyMapper.Bind <Source1, Target1>(config =>
            {
                config.Bind(from => from.CaseSensitive, to => to.Casesensitive);
            });

            var source = new Source1
            {
                CaseSensitive = "CaseSensitive"
            };

            var actual = TinyMapper.Map <Target1>(source);

            Assert.Equal(source.CaseSensitive, actual.Casesensitive);
        }
        public void Map_BindCaseSensitive_Success()
        {
            TinyMapper.Bind<SourceItem, TargetItem>();

            TinyMapper.Bind<Source1, Target1>(config =>
            {
                config.Bind(from => from.CaseSensitive, to => to.Casesensitive);
            });

            var source = new Source1
            {
                CaseSensitive = "CaseSensitive"
            };

            var actual = TinyMapper.Map<Target1>(source);

            Assert.Equal(source.CaseSensitive, actual.Casesensitive);
        }
示例#30
0
        protected override void Init()
        {
            BindingContext = this;

            var cv1 = BindingWithConverter();
            var cv2 = WithTrigger();

            var grid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = GridLength.Star
                    },
                    new RowDefinition()
                    {
                        Height = GridLength.Star
                    },
                }
            };

            grid.Children.Add(cv1);
            grid.Children.Add(cv2);
            Grid.SetRow(cv2, 1);

            Content = grid;

            Device.StartTimer(TimeSpan.FromMilliseconds(300), () =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    Source1.Add(new Item {
                        Text = Success1
                    });
                    Source2.Add(new Item {
                        Text = Success2
                    });
                });

                return(false);
            });
        }
        public void Map_Collections_Success()
        {
            TinyMapper.Bind<Source1, Target1>();

            var source = new Source1
            {
                Items = new List<Item1>
                {
                    new Item1
                    {
                        Int = 1,
                        String = "2",
                        List = new List<int> { 1, 2, 3 },
                        Bools = new[] { true, false }
                    },
                    new Item1
                    {
                        Int = 2,
                        String = "3",
                        List = new List<int> { 2, 3 },
                        Bools = new[] { false, false }
                    }
                }
            };

            var actual = TinyMapper.Map<Target1>(source);

            Assert.Equal(source.Items.Count, actual.Items.Count);
            Assert.Equal(source.Items1, actual.Items1);

            for (int i = 0; i < source.Items.Count; i++)
            {
                Item1 expectedItem = source.Items[i];
                Item2 actualItem = actual.Items[i];

                Assert.Equal(expectedItem.Bools, actualItem.Bools);
                Assert.Equal(expectedItem.Int, actualItem.Int);
                Assert.Equal(expectedItem.List, actualItem.List);
                Assert.Equal(expectedItem.String, actualItem.String);
            }
        }
示例#32
0
        public void Map_PrimitiveType_Success()
        {
            _tinyMapper.Bind <Source1, Target1>();

            var source = new Source1
            {
                Bool              = true,
                Char              = 'a',
                DateTime          = DateTime.Now,
                IntNullable1      = 1,
                Decimal           = 1m,
                DateTimeNullable1 = DateTime.Today
            };

            var actual = _tinyMapper.Map <Target1>(source);

            XAssert.Equal(source.Bool, actual.Bool);
            XAssert.Equal(source.Byte, actual.Byte);
            XAssert.Equal(source.Char, actual.Char);
            XAssert.Equal(source.Decimal, actual.Decimal);
            XAssert.Equal(source.Float, actual.Float);
            XAssert.Equal(source.Int, actual.Int);
            XAssert.Equal(source.Int1, actual.Int1);
            XAssert.Equal(source.Int2, actual.Int2);
            XAssert.Equal(source.IntNullable1.GetValueOrDefault(), actual.IntNullable1);
            XAssert.Equal(source.IntNullable2.GetValueOrDefault(), actual.IntNullable2);
            XAssert.Equal(source.Long, actual.Long);
            XAssert.Equal(source.Sbyte, actual.Sbyte);
            XAssert.Equal(source.Short, actual.Short);
            XAssert.Equal(source.String, actual.String);
            XAssert.Equal(source.Ulong, actual.Ulong);
            XAssert.Equal(source.Ushort, actual.Ushort);
            XAssert.Equal(source.DateTime, actual.DateTime);
            XAssert.Equal(source.DateTimeOffset, actual.DateTimeOffset);
            XAssert.Equal(source.DateTimeNullable1, actual.DateTimeNullable1);
            XAssert.Equal(source.DateTimeNullable2, actual.DateTimeNullable2);
        }
示例#33
0
        protected sealed override void UpdateValue()
        {
            if (Source1 == null || Source2 == null)
            {
                return;
            }

            float duration1 = Source1.Duration;

            if (duration1 == 0.0f)
            {
                return;
            }

            float duration2 = Source2.Duration;

            if (duration2 == 0.0f)
            {
                return;
            }

            float clippedTime1 = Looped ? Time % duration1 : Math.Min(Time, duration1);
            float clippedTime2 = Looped ? Time % duration2 : Math.Min(Time, duration2);

            timeIndex1 = Source1.GetKeyframeIndex(clippedTime1, timeIndex1);
            timeIndex2 = Source2.GetKeyframeIndex(clippedTime2, timeIndex2);
            if (timeIndex1 < Source1.GetNumberOfKeyframes() - 1)
            {
                Keyframe <T> k1 = Source1.GetKeyframe(timeIndex1);
                Keyframe <T> k2 = Source1.GetKeyframe(timeIndex1 + 1);
                Value = Interpolate(k1.Value, k2.Value, (clippedTime1 - k1.StartTime) / k1.Duration);
            }
            else
            {
                Value = Source1.GetKeyframe(timeIndex1).Value;
            }
        }
        public void Map_PrimitiveType_Success()
        {
            TinyMapper.Bind<Source1, Target1>();

            var source = new Source1
            {
                Bool = true,
                Char = 'a',
                DateTime = DateTime.Now,
                IntNullable1 = 1,
                Decimal = 1m,
                DateTimeNullable1 = DateTime.Today
            };

            var actual = TinyMapper.Map<Target1>(source);

            Assert.Equal(source.Bool, actual.Bool);
            Assert.Equal(source.Byte, actual.Byte);
            Assert.Equal(source.Char, actual.Char);
            Assert.Equal(source.Decimal, actual.Decimal);
            Assert.Equal(source.Float, actual.Float);
            Assert.Equal(source.Int, actual.Int);
            Assert.Equal(source.Int1, actual.Int1);
            Assert.Equal(source.Int2, actual.Int2);
            Assert.Equal(source.IntNullable1.GetValueOrDefault(), actual.IntNullable1);
            Assert.Equal(source.IntNullable2.GetValueOrDefault(), actual.IntNullable2);
            Assert.Equal(source.Long, actual.Long);
            Assert.Equal(source.Sbyte, actual.Sbyte);
            Assert.Equal(source.Short, actual.Short);
            Assert.Equal(source.String, actual.String);
            Assert.Equal(source.Ulong, actual.Ulong);
            Assert.Equal(source.Ushort, actual.Ushort);
            Assert.Equal(source.DateTime, actual.DateTime);
            Assert.Equal(source.DateTimeOffset, actual.DateTimeOffset);
            Assert.Equal(source.DateTimeNullable1, actual.DateTimeNullable1);
            Assert.Equal(source.DateTimeNullable2, actual.DateTimeNullable2);
        }
        public void Map_Ignore_Success()
        {
            TinyMapper.Bind<Source1, Target1>(config =>
            {
                config.Ignore(x => x.Bool);
                config.Ignore(x => x.String);
            });

            var source = new Source1
            {
                Bool = true,
                Byte = 5,
                Int = 9,
                String = "Test",
            };

            var actual = TinyMapper.Map<Target1>(source);

            Assert.Equal(false, actual.Bool);
            Assert.Equal(null, actual.MyString);
            Assert.Equal(source.Byte, actual.Byte);
            Assert.Equal(0, actual.MyInt);
            Assert.Null(actual.TargetItem);
        }
示例#36
0
        public void Map_Ignore_Success()
        {
            TinyMapper.Bind <Source1, Target1>(config =>
            {
                config.Ignore(x => x.Bool);
                config.Ignore(x => x.String);
            });

            var source = new Source1
            {
                Bool   = true,
                Byte   = 5,
                Int    = 9,
                String = "Test",
            };

            var actual = TinyMapper.Map <Target1>(source);

            Assert.Equal(false, actual.Bool);
            Assert.Equal(null, actual.MyString);
            Assert.Equal(source.Byte, actual.Byte);
            Assert.Equal(0, actual.MyInt);
            Assert.Null(actual.TargetItem);
        }
示例#37
0
        public void ShallowMapAndDeepMapDemo()
        {
            //浅映射Demo:
            Source1 source = new Source1
            {
                Price       = 2,
                InnerClassA = new InnerClass1
                {
                    SubName1 = "浅映射Demo"
                }
            };
            ObjectsMapper <Source1, Destination1> mapper =
                ObjectMapperManager.DefaultInstance.GetMapper <Source1, Destination1>(
                    new DefaultMapConfig()
                    .ShallowMap <InnerClass1>()
                    );
            Destination1 destination = mapper.Map(source);

            Console.WriteLine("destination.InnerClassA.SubName1 = {0}.", destination.InnerClassA.SubName1);
            source.InnerClassA.SubName1 = "浅映射Demo_updated";
            Console.WriteLine("destination.InnerClassA.SubName1 = {0}.", destination.InnerClassA.SubName1);

            //深映射Demo:
            source.InnerClassA.SubName1 = "深映射Demo";
            ObjectsMapper <Source1, Destination1> mapper2 =
                ObjectMapperManager.DefaultInstance.GetMapper <Source1, Destination1>(
                    new DefaultMapConfig()
                    .DeepMap <InnerClass1>()
                    );

            destination = mapper2.Map(source);

            Console.WriteLine("destination.InnerClassA.SubName1 = {0}.", destination.InnerClassA.SubName1);
            source.InnerClassA.SubName1 = "深映射Demo_updated";
            Console.WriteLine("destination.InnerClassA.SubName1 = {0}.", destination.InnerClassA.SubName1);
        }
示例#38
0
 public void LinqAF()
 {
     foreach (var grp in Source1.GroupJoin(Source2, KeySelector, KeySelector, (x, grp) => x, Comparer))
     {
     }
 }