当前位置: 首页>>代码示例>>C#>>正文


C# Properties.Select方法代码示例

本文整理汇总了C#中Properties.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Properties.Select方法的具体用法?C# Properties.Select怎么用?C# Properties.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Properties的用法示例。


在下文中一共展示了Properties.Select方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PropertiesAreCorrectlyInitialized

 public void PropertiesAreCorrectlyInitialized(ConstructorInitializedMemberAssertion assertion)
 {
     // Fixture setup
     var property = new Properties<JSuccessWithDataResponse<int>>();
     // Exercise system and verify outcome
     assertion.Verify(property.Select(r => r.Data));
     assertion.Verify(property.Select(r => r.HttpResponse));
 }
开发者ID:lofrank,项目名称:JSendWebApi,代码行数:8,代码来源:JSuccessWithDataResponseTests.cs

示例2: PropertiesAreCorrectlyInitializer

 public void PropertiesAreCorrectlyInitializer(ConstructorInitializedMemberAssertion assertion)
 {
     // Fixture setup
     var properties = new Properties<JErrorResponse<int>>();
     // Exercise system and verify outcome
     assertion.Verify(properties.Select(r => r.Error));
     assertion.Verify(properties.Select(r => r.HttpResponse));
 }
开发者ID:lofrank,项目名称:JSendWebApi,代码行数:8,代码来源:JErrorResponseTests.cs

示例3: SelectPropertyReturnsCorrectProperty

        public void SelectPropertyReturnsCorrectProperty()
        {
            var sut = new Properties<ClassWithProperties>();

            PropertyInfo actual = sut.Select(x => x.ReadOnlyText);

            var expected = typeof(ClassWithProperties).GetProperty("ReadOnlyText");
            Assert.Equal(expected, actual);
        }
开发者ID:tleviathan,项目名称:Albedo,代码行数:9,代码来源:PropertiesTests.cs

示例4: SelectPropertyDeclaredOnBaseReturnsCorrectProperty

        public void SelectPropertyDeclaredOnBaseReturnsCorrectProperty()
        {
            var sut = new Properties<SubClassWithProperties>();
            var expected = typeof(SubClassWithProperties).GetProperty("ReadOnlyText");

            var actual = sut.Select(x => x.ReadOnlyText);

            Assert.Equal(expected, actual);
        }
开发者ID:tleviathan,项目名称:Albedo,代码行数:9,代码来源:PropertiesTests.cs

示例5: SelectFieldThrows

 public void SelectFieldThrows()
 {
     var sut = new Properties<ClassWithFields>();
     Assert.Throws<ArgumentException>(
         () => sut.Select(x => x.ReadOnlyText));
 }
开发者ID:tleviathan,项目名称:Albedo,代码行数:6,代码来源:PropertiesTests.cs

示例6: SelectNonMemberExpressionThrows

 public void SelectNonMemberExpressionThrows()
 {
     var sut = new Properties<ClassWithProperties>();
     Assert.Throws<ArgumentException>(
         () => sut.Select(x => x.ToString()));
 }
开发者ID:tleviathan,项目名称:Albedo,代码行数:6,代码来源:PropertiesTests.cs

示例7: SelectNullThrows

 public void SelectNullThrows()
 {
     var sut = new Properties<ClassWithProperties>();
     Assert.Throws<ArgumentNullException>(
         () => sut.Select<object>(null));
 }
开发者ID:tleviathan,项目名称:Albedo,代码行数:6,代码来源:PropertiesTests.cs

示例8: InitializeProperties

        /// <summary>
        /// Loads all properties from database into objects. If this method is re-called, it will re-query the database.
        /// </summary>
        /// <remarks>
        /// This optimizes sql calls. This will first check if all of the properties have been loaded. If not, 
        /// then it will query for all property types for the current version from the db. It will then iterate over each
        /// cmdPropertyData row and store the id and propertyTypeId in a list for lookup later. Once the records have been 
        /// read, we iterate over the cached property types for this ContentType and create a new property based on
        /// our stored list of proeprtyTypeIds. We then have a cached list of Property objects which will get returned
        /// on all subsequent calls and is also used to return a property with calls to getProperty.
        /// </remarks>
        private void InitializeProperties()
        {
            m_LoadedProperties = new Properties();

            if (this.ContentType == null)
                return;

            //Create anonymous typed list with 2 props, Id and PropertyTypeId of type Int.
            //This will still be an empty list since the props list is empty.
            var propData = m_LoadedProperties.Select(x => new { Id = 0, PropertyTypeId = 0 }).ToList();

            string sql = @"select id, propertyTypeId from cmsPropertyData where [email protected]";

            using (IRecordsReader dr = SqlHelper.ExecuteReader(sql,
                SqlHelper.CreateParameter("@versionId", Version)))
            {
                while (dr.Read())
                {
                    //add the item to our list
                    propData.Add(new { Id = dr.Get<int>("id"), PropertyTypeId = dr.Get<int>("propertyTypeId") });
                }
            }

            foreach (PropertyType pt in this.ContentType.PropertyTypes)
            {
                if (pt == null)
                    continue;

                //get the propertyId
                var property = propData
                    .Where(x => x.PropertyTypeId == pt.Id)
                    .SingleOrDefault();
                if (property == null)
                    continue;
                var propertyId = property.Id;

                Property p = null;
                try
                {
                    p = new Property(propertyId, pt);
                }
                catch
                {
                    continue; //this remains from old code... not sure why we would do this?
                }

                m_LoadedProperties.Add(p);
            }
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:60,代码来源:Content.cs

示例9: InitializeProperties

        /// <summary>
        /// Loads all properties from database into objects. If this method is re-called, it will re-query the database.
        /// </summary>
        /// <remarks>
        /// This optimizes sql calls. This will first check if all of the properties have been loaded. If not, 
        /// then it will query for all property types for the current version from the db. It will then iterate over each
        /// cmdPropertyData row and store the id and propertyTypeId in a list for lookup later. Once the records have been 
        /// read, we iterate over the cached property types for this ContentType and create a new property based on
        /// our stored list of proeprtyTypeIds. We then have a cached list of Property objects which will get returned
        /// on all subsequent calls and is also used to return a property with calls to getProperty.
        /// </remarks>
        private void InitializeProperties()
        {
            m_LoadedProperties = new Properties();

            if (ContentBase != null)
            {
                //NOTE: we will not load any properties where HasIdentity = false - this is because if properties are 
                // added to the property collection that aren't persisted we'll get ysods
                m_LoadedProperties.AddRange(ContentBase.Properties.Where(x => x.HasIdentity).Select(x => new Property(x)));
                return;
            }

            if (this.ContentType == null)
                return;

            //Create anonymous typed list with 2 props, Id and PropertyTypeId of type Int.
            //This will still be an empty list since the props list is empty.
            var propData = m_LoadedProperties.Select(x => new { Id = 0, PropertyTypeId = 0 }).ToList();

            string sql = @"select id, propertyTypeId from cmsPropertyData where [email protected]";

            using (IRecordsReader dr = SqlHelper.ExecuteReader(sql,
                SqlHelper.CreateParameter("@versionId", Version)))
            {
                while (dr.Read())
                {
                    //add the item to our list
                    propData.Add(new { Id = dr.Get<int>("id"), PropertyTypeId = dr.Get<int>("propertyTypeId") });
                }
            }

            foreach (PropertyType pt in this.ContentType.PropertyTypes)
            {
                if (pt == null)
                    continue;

                //get the propertyId
                var property = propData.LastOrDefault(x => x.PropertyTypeId == pt.Id);
                if (property == null)
                {
                    continue;
                    //var prop = Property.MakeNew(pt, this, Version);
                    //property = new {Id = prop.Id, PropertyTypeId = pt.Id};
                }
                var propertyId = property.Id;

                Property p = null;
                try
                {
                    p = new Property(propertyId, pt);
                }
                catch
                {
                    continue; //this remains from old code... not sure why we would do this?
                }

                m_LoadedProperties.Add(p);
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:70,代码来源:Content.cs


注:本文中的Properties.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。