Exemple #1
0
 public IQueryCommand WithConfigs <T1, T2>() where T1 : IFingerprintConfiguration, new() where T2 : IQueryConfiguration, new()
 {
     QueryConfiguration       = new T2();
     FingerprintConfiguration = new T1();
     createFingerprintMethod  = () => fingerprintingMethodFromSelector().WithFingerprintConfig(FingerprintConfiguration);
     return(this);
 }
        public void UploadData()
        {
            string baseUrl = "https://www.gismeteo.ru";
            string prefix  = "tomorrow/";

            Console.Title = "HOST";

            string DATA = PARSERS.AngleSharpParser.DownloadHTML(baseUrl);
            var    doc  = PARSERS.AngleSharpParser.ParserHTML(DATA, "noscript a");

            foreach (var T1 in doc)
            {
                string CityData   = PARSERS.AngleSharpParser.DownloadHTML(baseUrl + T1.GetAttribute("href") + prefix);
                var    Temp       = PARSERS.AngleSharpParser.ParserHTML(CityData, "div", x => x.ClassName == "value" && x.HasAttribute("style"));
                int    count      = 0;
                int    _i         = 0;
                string tempValues = "";
                foreach (var T2 in Temp)
                {
                    if (count >= 6 && count < 14)
                    {
                        tempValues += T2.TextContent;
                        tempValues += ' ';
                        _i++;
                    }
                    count++;
                }

                DATAMAPPER.MySQLMapper.SetData(T1.GetAttribute("data-id"), T1.GetAttribute("data-name").ToString(), T1.GetAttribute("href"));
                DATAMAPPER.MySQLMapper.SetData(T1.GetAttribute("data-id"), DateTime.Now.AddDays(1), tempValues);
                tempValues = null;
            }
        }
 public void Post([FromBody] T1 t1)
 {
     using (var con = _sqliteConnection)
     {
         con.Execute("insert into t1(name) values(@Name)", t1);
     }
 }
Exemple #4
0
        private Dictionary <Tuple <T1, T2>, int> CollectKeys2 <T1, T2>()
        {
            Debug.Assert(_keyColumns.Length == 2);

            var column1  = _dataMap[_keyColumns[0]].UnderlyingList;
            var column2  = _dataMap[_keyColumns[1]].UnderlyingList;
            var rowCount = _dataMap.MaxRowCount;
            var result   = new Dictionary <Tuple <T1, T2>, int>(rowCount);

            for (var i = 0; i < rowCount; ++i)
            {
                T1 k1 = i >= column1.Count ? TypeTrait <T1> .GetNaN() : (T1)column1[i];

                T2 k2 = i >= column2.Count ? TypeTrait <T2> .GetNaN() : (T2)column2[i];

                var key = Tuple.Create(k1, k2);
                try
                {
                    result.Add(key, i);
                }
                catch (ArgumentException ex)
                {
                    throw new ArgumentException($"Duplicate key values: {key}", ex);
                }
            }

            return(result);
        }
Exemple #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ActionId != 0)
            {
                hash ^= ActionId.GetHashCode();
            }
            if (Num != 0)
            {
                hash ^= Num.GetHashCode();
            }
            if (T0 != 0L)
            {
                hash ^= T0.GetHashCode();
            }
            if (T1 != 0L)
            {
                hash ^= T1.GetHashCode();
            }
            if (T2 != 0L)
            {
                hash ^= T2.GetHashCode();
            }
            if (T3 != 0L)
            {
                hash ^= T3.GetHashCode();
            }
            return(hash);
        }
Exemple #6
0
 public IEnumerable <T2> foo6(T1 t1, T2 t2)
 {
     for (int i = 0; i < t1.IntValue; i++)
     {
         yield return(t2);
     }
 }
        public static string ByteArayToHex(byte[] Param)
        {
            var ListTemp = Param.ToList().Select(T1 => T1.ToString("X").PadLeft(2, '0')).ToList();
            var result   = string.Join("", ListTemp);

            return(result);
        }
Exemple #8
0
        // Test that default JSON deserialization does map camelCase correctly into a non-camelCase struct.
        public void JSON_Deserialization_Casing()
        {
            // Deserialize T1aJson & ensure all of the struct fields get populated as per T1aStruct.

            // start the target struct with "bad" values
            const string SomeName     = "<someName>";
            var          theEnumValue = T1.X.C;
            var          theTierValue = BlobAccessTier.Hot;

            T1 t2aResult = new T1
            {
                FirstName  = null,
                MiddleName = SomeName,
                Surname    = null,
                TheEnum    = theEnumValue,
                Tier       = theTierValue,
            };

            // Equivalent of t2aResult - whitespace "compressed" version of the JSON input/output.
            string t2aJson = $"{{'middleName':'{SomeName}','theEnum':'{theEnumValue}','tier':'{theTierValue}'}}".Replace('\'', '"');

            var t2aResultActual = JsonConvert.DeserializeObject <T1>(t2aJson);

            bool gotExpectedResult = T1Equals(t2aResult, t2aResultActual);

            if (!gotExpectedResult)
            {
                // DebugHelpers.WriteLine("Bad Deserialization: Expected {0}, Got {1}", ToString(t2aResult), ToString(t2aResultActual));
            }

            gotExpectedResult.ShouldBeTrue();
        }
        public void Test3()
        {
            IServiceCollection sc = new ServiceCollection()
                                    .AddLightweightMapper();

            IServiceProvider sp       = sc.BuildServiceProvider();
            IMapperProvider  provider = sp.GetRequiredService <IMapperProvider>();
            var mapper = provider.GetMapper <S2, T1>();

            var s2 = new S2()
            {
                A = null
            };
            var t2 = mapper.Convert(s2);

            Assert.IsType <T1>(t2);
            Assert.Equal(0, t2.A);

            s2 = new S2()
            {
                A = 10
            };
            t2 = mapper.Convert(s2);
            Assert.IsType <T1>(t2);
            Assert.Equal(10, t2.A);

            var mapper2 = provider.GetMapper <T1, S2>();
            var t1      = new T1()
            {
                A = 10
            };
            var s3 = mapper2.Convert(t1);

            Assert.Equal(10, s3.A);
        }
Exemple #10
0
    static int Main()
    {
        bool        res   = true;
        T0 <string> t0str = new T0 <string>();

        T1 <char> t1char = new T1 <char>();

        T2 <int> t2int = new T2 <int>();

        if (t2int.Me() != 0)
        {
            res = false;
        }

        T3 <uint> t3uint = new T3 <uint>();

        if (t3uint.Home(0) != 0)
        {
            res = false;
        }

        if (res = true)
        {
            return(0);
        }

        return(1);
    }
Exemple #11
0
        public Tuple <T1, T2> ReadPair <T1, T2>()
        {
            T1 firstValue  = Read <T1>();
            T2 secondValue = Read <T2>();

            return(new Tuple <T1, T2>(firstValue, secondValue));
        }
Exemple #12
0
        public virtual void Add <T1, T2>() where T2 : T1
        {
            Type clazzType              = typeof(T2);
            var  canActivate            = clazzType.IsClass || clazzType.IsValueType;
            var  argsAllowed            = clazzType.IsClass;
            Func <object[], T1> creator = args => {
                if (args != null)
                {
                    if (!argsAllowed)
                    {
                        throw new ArgumentException(clazzType.Name + "does't have a contstrutor with arguments");
                    }
                    else
                    {
                        return(Ctor <T2>(args));
                    }
                }

                T1 result = default(T1);

                if (canActivate)
                {
                    result = (T1)Activator.CreateInstance(clazzType);
                }
                return(result);
            };

            Clazzes[typeof(T1)] = creator;
            AddKnown <T1, T2>();
        }
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T1"></typeparam>
        /// <typeparam name="T2"></typeparam>
        /// <returns></returns>
        public Dictionary <string, List <ITable> > Execute <T1, T2>() where T1 : class, ITable, new() where T2 : class, ITable, new()
        {
            Dictionary <string, List <ITable> > result = new Dictionary <string, List <ITable> >();

            try
            {
                Connection.Open();
                var           reader = Command.ExecuteReader();
                List <ITable> data   = new List <ITable>();
                while (reader.Read())
                {
                    T1 t = new T1();
                    t.Parse(reader);
                    data.Add(t);
                }
                result.Add(typeof(T1).Name, data);
                if (reader.NextResult())
                {
                    List <ITable> data2 = new List <ITable>();
                    while (reader.Read())
                    {
                        T2 s = new T2();
                        s.Parse(reader);
                        data2.Add(s);
                    }
                    result.Add(typeof(T2).Name, data2);
                }
            }
            finally
            {
                Connection.Close();
            }
            return(result);
        }
Exemple #14
0
        public void TestWorkstepSequentialDelegate()
        {
            // defines and executes a basic sequential workflow using inline delegate methods
            var w = new WorkstepBaseSeq <T1, T3>(
                new IWorkstep[] {
                // step 1
                new WorkstepBase <T1, T2>(
                    delegate(T1 input)
                {
                    T2 result;
                    result.b = input.a;
                    return(result);
                }, null),
                // step 2
                new WorkstepBase <T2, T3>(
                    delegate(T2 input)
                {
                    T3 result;
                    result.c = input.b;
                    return(result);
                }, null)
            });

            w.Initialise(_workContext);
            var t1 = new T1 {
                a = 42
            };
            T3 t3 = w.Execute(t1).Result;

            Assert.AreEqual(42, t3.c);
        }
Exemple #15
0
        public void TestWorkstepBranchingDelegate()
        {
            // defines and executes a branching workflow
            var w = new WorkstepBaseAlt <T1, T2>(
                // chooser
                input => input.a,
                // steps
                new IWorkstep[] {
                // step 1
                new WorkstepBase <T1, T2>(
                    delegate(T1 input)
                {
                    T2 result;
                    result.b = input.a * -5;
                    return(result);
                }, null),
                // step 2
                new WorkstepBase <T1, T2>(
                    delegate(T1 input)
                {
                    T2 result;
                    result.b = input.a * +5;
                    return(result);
                }, null)
            });

            w.Initialise(_workContext);
            var t1 = new T1 {
                a = 1
            };
            T2 t2 = w.Execute(t1).Result;

            Assert.AreEqual(5, t2.b);
        }
Exemple #16
0
        public void ElementInAllList()
        {
            var particle = new CompositeParticle.Builder(ParticleType.All, 0, 1)
            {
                new ElementParticle(typeof(T1), 0, 1),
                new ElementParticle(typeof(T2), 0, 1),
            }.Compile();
            var data = new TestOpenXmlCompositeElement();

            var t1a = new T1();
            var t1b = new T1();
            var t1c = new T1();
            var t2  = new T2();

            data.PrependChild(t1a);
            data.PrependChild(t1b);
            data.PrependChild(t2);
            data.PrependChild(t1c);

            Assert.Collection(
                particle.GetCollection <T1>(data),
                e => Assert.Same(t1c, e),
                e => Assert.Same(t1b, e),
                e => Assert.Same(t1a, e));
        }
Exemple #17
0
        public void TwoElementOneCollectionInSequenceTest()
        {
            var particle = new CompositeParticle.Builder(ParticleType.Sequence, 0, 1)
            {
                new ElementParticle(typeof(T1), 0, 1),
                new ElementParticle(typeof(T2), 1, 10),
                new ElementParticle(typeof(T3), 0, 1),
            }.Compile();
            var data = new TestOpenXmlCompositeElement();

            var t1  = new T1();
            var t2a = new T2();
            var t2b = new T2();
            var t3  = new T3();

            Assert.True(particle.Set(data, t3));
            Assert.True(particle.GetCollection <T2>(data).Add(t2a));
            Assert.True(particle.Set(data, t1));
            Assert.True(particle.GetCollection <T2>(data).Add(t2b));

            Assert.Collection(
                data,
                e => Assert.Same(t1, e),
                e => Assert.Same(t2a, e),
                e => Assert.Same(t2b, e),
                e => Assert.Same(t3, e));
        }
Exemple #18
0
        public TimeLine()
        {
            InitializeComponent();
            DataContext = this;
            Intervals   = new List <Interval>();
            FullTime    = TimeSpan.FromSeconds(450);

            T1.T_full = FullTime;
            T1.T_el   = TimeSpan.FromSeconds(60);
            T1.ChangeDashesHeight(12);
            T1.ChangeDashesWidth(1);

            T2.T_full = FullTime;
            T2.T_el   = TimeSpan.FromSeconds(10);
            T2.ChangeDashesHeight(6);

            Cursor1.Container = this;


            Binding binding = new Binding();

            binding.ElementName = "Cursor1";                      // элемент-источник
            binding.Path        = new PropertyPath("CRPosition"); // свойство элемента-источника
            binding.Mode        = BindingMode.TwoWay;
            this.SetBinding(TimeLine.POSProperty, binding);       // установка привязки для элемента-приемника

            OnPOSChanged         += TimeLine_OnPOSChanged;
            Cursor1.OnCRPChanged += Cursor1_OnCRPChanged;
            Cursor1.OnStartDrag  += Cursor1_OnStartDrag;
            Cursor1.OnEndDrag    += Cursor1_OnEndDrag;



            OnSelectedItemChanged += TimeLine_OnSelectedItemChanged;
        }
Exemple #19
0
        public void SendCommand <T1>() where T1 : ICommand, new()
        {
            var command = new T1();

            command.SetArchitecture(this);
            command.Execute();
        }
        private void frmRptRegisterKoreksiReturBeliFilter_Load(object sender, EventArgs e)
        {
            this.Text    = "Pembelian";
            T1.DateValue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            t2.DateValue = DateTime.Now;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                DataTable dtGudang = new DataTable();
                using (Database db = new Database())
                {
                    db.Commands.Add(db.CreateCommand("usp_Gudang_LIST"));
                    dtGudang = db.Commands[0].ExecuteDataTable();
                }
                DataColumn cConcatenated = new DataColumn("Concatenated", Type.GetType("System.String"), "GudangID + ' | ' + NamaGudang");
                dtGudang.Columns.Add(cConcatenated);
                dtGudang.Rows.Add("");
                dtGudang.DefaultView.Sort = "GudangID ASC";
                cboGudang.DataSource      = dtGudang;
                cboGudang.DisplayMember   = "Concatenated";
                cboGudang.ValueMember     = "GudangID";
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            T1.Focus();
        }
 public void Post([FromBody] T1 t1)
 {
     using (_sqliteDB)
     {
         _sqliteDB.Execute("insert into t1(name) values(@Name)", t1);
     }
 }
Exemple #22
0
        static List <DepartMentModel> getDept(int?pid = null)
        {
            var query = from dept in db.Dic_Department
                        join dept2 in db.Dic_Department on dept.dept_parent_id equals dept2.dept_id into T1
                        from t1 in T1.DefaultIfEmpty()
                        orderby dept.dept_parent_id ascending
                        select new DepartMentModel
            {
                deptId     = dept.dept_id,
                deptName   = dept.dept_name,
                parentName = t1.dept_name == null ? "" : t1.dept_name,
                parentId   = dept.dept_parent_id
            };
            List <DepartMentModel> list;

            if (pid != null)
            {
                list = query.Where(x => x.parentId == (int)pid).ToList();
            }
            else
            {
                list = query.ToList();
            }
            return(list);
        }
 /// <summary> 展开/折叠所有子节点
 ///
 /// </summary>
 /// <param name="IsExpandParame">[true:展开;false:折叠]</param>
 public void ExpandOrCollapseAll(bool IsExpandParame)
 {
     this.GetChidrenNode().ForEach(T1 => T1.PrivateExpandOrCollapseAll(IsExpandParame));
     //if (collapseNodeButton1.IsExpand == IsExpandParame) return;
     collapseNodeButton1.IsExpand = IsExpandParame;
     ResetNodeSize();
 }
Exemple #24
0
        public void SerializeDeserialize_Recursive()
        {
            T1 t1 = new T1();

            t1.x = 1;
            t1.y = 2;

            object aSerializedT1 = TestedSerializer.Serialize <T1>(t1);

            T2 t2 = new T2();

            t2.a = "hello";
            t2.o = aSerializedT1;

            object aSerializedT2 = TestedSerializer.Serialize <T2>(t2);


            T2 aDeserializedT2 = TestedSerializer.Deserialize <T2>(aSerializedT2);

            Assert.AreEqual(t2.a, aDeserializedT2.a);

            T1 aDeserializedT1 = TestedSerializer.Deserialize <T1>(aSerializedT1);

            Assert.AreEqual(t1.x, aDeserializedT1.x);
            Assert.AreEqual(t1.y, aDeserializedT1.y);
        }
        public void CastTest()
        {
            var db = Configuration.TestDatabase;
            var collection = db.GetCollection<Base>("castTest");
            collection.Drop();

            var t1 = new T1 { Id = Guid.NewGuid(), A = "T1.A", B = "T1.B" };
            var t2 = new T2 { Id = Guid.NewGuid(), A = "T2.A" };
            collection.Insert(t1);
            collection.Insert(t2);

            var query = from t in collection.AsQueryable()
                        where t is T1 && ((T1)t).B == "T1.B" 
                        select t;

            var translatedQuery = MongoQueryTranslator.Translate(query);
            Assert.IsInstanceOf<SelectQuery>(translatedQuery);
            Assert.AreSame(collection, translatedQuery.Collection);
            Assert.AreSame(typeof(Base), translatedQuery.DocumentType);

            var selectQuery = (SelectQuery)translatedQuery;
            Assert.AreEqual("(Base t) => ((t is T1) && ((T1)t.B == \"T1.B\"))", ExpressionFormatter.ToString(selectQuery.Where));
            Assert.IsNull(selectQuery.OrderBy);
            Assert.IsNull(selectQuery.Projection);
            Assert.IsNull(selectQuery.Skip);
            Assert.IsNull(selectQuery.Take);

            Assert.AreEqual("{ \"_t\" : \"T1\", \"B\" : \"T1.B\" }", selectQuery.BuildQuery().ToString());

            var results = query.ToList();
            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results[0], Is.InstanceOf(typeof(T1)));
            Assert.That(results[0].A, Is.EqualTo("T1.A"));
        }
Exemple #26
0
    public static void MainTest()
    {
        var x1 = new X1();
        var x2 = new X2();
        var x3 = new X3();
        var x4 = new X4();

        x4.Display2();
        x1 = x4;
        x1.Display1();
        System.Console.WriteLine(x1.y);
        //x1.Display2();
        System.Console.WriteLine();

        var tt = new Y <int, Double>();

        tt.Set(3);
        tt.Set(.3);

        x1 = new X1();
        var x11 = new X1();

        x2 = new X2();
        var x22 = new X2();

        x1 = T1.V1(x22);
        //x2 = T1.V2(x1);
    }
        public void GivenErrorHandlingStrategy_WhenUnparseableValue_CanBeIgnored()
        {
            CustomizableErrorHandlingStrategy errorStrategy = new CustomizableErrorHandlingStrategy
            {
                DeserializeErrorAction = (o, args) => args.ErrorContext.Handled = true,
                SerializeErrorAction   = (o, args) => args.ErrorContext.Handled = true
            };

            strategy.ErrorStrategy = errorStrategy;

            string s;

            {
                T1 t1 = new T1();
                t1.D1 = "123";
                t1.D2 = true;
                s     = strategy.Serialize(t1);
            }
            s = s.Replace(@"""d2"": true", @"""d2"": ""123""");
            {
                T1 t1 = new T1();
                strategy.PopulateFromSerialized(t1, s);
                Expect(t1.D1, EqualTo("123"));
                Expect(t1.D2, False);
            }
        }
Exemple #28
0
 private z1(Form form, h2 h, T1 t)
 {
     if (form == null)
     {
         throw new ArgumentException();
     }
     if (t == null)
     {
         throw new ArgumentException();
     }
     if (t.b() != form)
     {
         throw new ArgumentException();
     }
     this.a();
     base.FormBorderStyle = FormBorderStyle.None;
     base.ShowIcon        = false;
     base.ShowInTaskbar   = false;
     base.WindowState     = FormWindowState.Normal;
     this.A = h;
     this.A = t;
     this.a = form;
     base.Show(form);
     t.k();
 }
Exemple #29
0
        /// <summary>
        /// 后台C#绑定数据
        /// </summary>
        public void binding(Student s)
        {
            //创建一个binding实例
            Binding b1 = new Binding
            {
                //指定绑定值来源
                Path = new PropertyPath(nameof(Student.ID))
            };

            //绑定数据到控件
            T1.SetBinding(TextBlock.TextProperty, b1);

            Binding b2 = new Binding
            {
                Path = new PropertyPath(nameof(Student.StuName))
            };

            T2.SetBinding(TextBlock.TextProperty, b2);

            Binding b3 = new Binding
            {
                Path = new PropertyPath(nameof(Student.Age))
            };

            T3.SetBinding(TextBlock.TextProperty, b3);

            panel.DataContext = s;//绑定到父控件上
        }
        public void GivenErrorHandlingStrategy_WhenBreakPopulate_Breaks()
        {
            CustomizableErrorHandlingStrategy errorStrategy = new CustomizableErrorHandlingStrategy
            {
                PrePopulateAction = (json, o) => json.Contains("test")
                    ? new PreviewResult()
                {
                    BreakPopulating = true
                }
                    : new PreviewResult()
                {
                    BreakPopulating = false
                }
            };

            strategy.ErrorStrategy = errorStrategy;

            {
                string s = "test, this is an invalid json that should throw exception, unless populating is skipped";
                {
                    T1 t1 = new T1();
                    strategy.PopulateFromSerialized(t1, s);
                    Expect(t1.D1, Null);
                    Expect(t1.D2, False);
                }
            }

            {
                string s  = "this is also invalid json, but doesn't match skip condition, thus should cause exception";
                T1     t1 = new T1();
                Assert.Throws <JsonReaderException>(() => strategy.PopulateFromSerialized(t1, s));
            }
        }
Exemple #31
0
 public static void A(h2 h, T1 t)
 {
     if (!z1.A())
     {
         z1.A = new z1(t.b(), h, t);
     }
 }
        public void MemberPrimitivesAreMapped()
        {
            var typeMapper = Mapper.CreateMapper<T1, T2>();
            typeMapper.Property(t => t.Property).MapsTo(t => t.Property);

            var t1 = new T1() { Property = 1 };
            var t2 = Mapper.Map<T1, T2>(t1);

            Assert.AreEqual(t1.Property, t2.Property);
        }
        public void OriginalObjectsAreMerged()
        {
            var typeMapper = Mapper.CreateMapper<T1, T2>();
            typeMapper.Property(t => t.Property).MapsTo(t => t.Property);

            var t1 = new T1() { Property = 1 };
            var t2 = new T2();
            var originalT2 = t2;
            Mapper.Map<T1, T2>(t1, t2);

            Assert.AreEqual(t1.Property, originalT2.Property);
        }
        public void MemberObjectsAreMappedBothWays()
        {
            var typeMapper = Mapper.CreateMapper<T1, T2>();
            typeMapper.Property(t => t.Property).MapsTo(t => t.Property);
            typeMapper.Property(t => t.T2).MapsTo(t => t.T1);

            var t1 = new T1() { T2 = new T2() { Property = 1 } };
            var t2 = Mapper.Map<T1, T2>(t1);
            var t3 = Mapper.Map<T2, T1>(t2);

            Assert.IsNotNull(t3);
            Assert.IsNotNull(t2.T1);
            Assert.AreEqual(t1.T2.Property, t3.T2.Property);
        }
        public void CollectionsAreUnioned()
        {
            var typeMapper = Mapper.CreateMapper<T1, T2>();
            typeMapper.Collection(t => t.IntCollection, () => new List<int>(), null).MapsTo(t => t.LongCollection, () => new List<long>(), null);

            var ints = new[] { 1, 2, 3 };
            var longs = new[] { 1L, 2L, 4L };
            T1 t1 = new T1() { IntCollection = ints };
            T2 t2 = new T2() { LongCollection = longs };
            Mapper.Map(t1, t2);

            var longUnion = longs.Union(ints.Select(i => (long)i));

            Assert.IsTrue(t2.LongCollection.SequenceEqual(longUnion));
        }
        public void ProjectAfterOfTypeTest()
        {
            var server = MongoServer.Create();
            var db = server.GetDatabase("csharp475");
            var collection = db.GetCollection<Base>("ProjectTest");
            collection.Drop();
            
            var t1 = new T1 { A = "T1.A", B = "T1.B" };
            collection.Insert(t1);

            var query = from t in collection.AsQueryable().OfType<T1>() select t.B;
            var results = query.ToList();
            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results[0], Is.EqualTo("T1.B"));
        }
        public void ConvertedPrimitiveDestinationCollectionHasEquivalentItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, long> collectionMapper =
                new CollectionMapper<T1, int, T2, long>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.LongCollection, () => new List<long>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.IsTrue(t1.IntCollection.All(i => t2.LongCollection.Any(l => i == l)));
            Assert.IsTrue(t2.LongCollection.All(i => t3.IntCollection.Any(l => i == l)));
        }
        public void DestinationCollectionHasSameNumberOfItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, int> collectionMapper =
                new CollectionMapper<T1, int, T2, int>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.IntCollection, () => new List<int>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.AreEqual(t1.IntCollection.Count, t2.IntCollection.Count);
            Assert.AreEqual(t1.IntCollection.Count, t1.IntCollection.Count);
        }
Exemple #39
0
        public void ProjectAfterOfTypeTest()
        {
            var server = LegacyTestConfiguration.Server;
            var db = server.GetDatabase("csharp475");
            var collection = db.GetCollection<Base>("ProjectTest");
            collection.Drop();
            
            var t1 = new T1 { A = "T1.A", B = "T1.B" };
            collection.Insert(t1);

            var query = from t in collection.AsQueryable().OfType<T1>() select t.B;
            var results = query.ToList();
            Assert.Equal(1, results.Count);
            Assert.Equal("T1.B", results[0]);

            db.Drop();
        }
Exemple #40
0
 public Tuple(T1 item1, T2 item2)
 {
     this.Item1 = item1;
     this.Item2 = item2;
 }
Exemple #41
0
 static bool Do1(T1 t) {
   Nullable<T1> n = new Nullable<T1>(t);
   return Ensure(n.HasValue && n.Value == t);
 }
        public void OriginalObjectsAreNotDestroyed()
        {
            var typeMapper = Mapper.CreateMapper<T1, T2>();
            typeMapper.Property(t => t.Property).MapsTo(t => t.Property);

            var t1 = new T1();
            var t2 = new T2();
            var originalT2 = t2;
            Mapper.Map<T1, T2>(t1, t2);

            Assert.AreSame(originalT2, t2);
        }
        public void PrimitiveDestinationCollectionHasSameItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, int> collectionMapper =
                new CollectionMapper<T1, int, T2, int>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.IntCollection, () => new List<int>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.IsFalse(t1.IntCollection.Except(t2.IntCollection).Any());
            Assert.IsFalse(t2.IntCollection.Except(t3.IntCollection).Any());
        }