本文整理汇总了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));
}
示例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));
}
示例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);
}
示例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);
}
示例5: SelectFieldThrows
public void SelectFieldThrows()
{
var sut = new Properties<ClassWithFields>();
Assert.Throws<ArgumentException>(
() => sut.Select(x => x.ReadOnlyText));
}
示例6: SelectNonMemberExpressionThrows
public void SelectNonMemberExpressionThrows()
{
var sut = new Properties<ClassWithProperties>();
Assert.Throws<ArgumentException>(
() => sut.Select(x => x.ToString()));
}
示例7: SelectNullThrows
public void SelectNullThrows()
{
var sut = new Properties<ClassWithProperties>();
Assert.Throws<ArgumentNullException>(
() => sut.Select<object>(null));
}
示例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);
}
}
示例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);
}
}