Using IsInstanceOfType instead of IsAssignableFrom

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-02-16 16:02:12 -08:00
parent 4cefffe568
commit 81c6ae4412
4 changed files with 6 additions and 6 deletions

View File

@@ -31,13 +31,13 @@ namespace Orchard.ContentManagement {
public IContentManager ContentManager { get; set; }
public bool Has(Type partType) {
return partType == typeof(ContentItem) || _parts.Any(part => partType.IsAssignableFrom(part.GetType()));
return partType == typeof(ContentItem) || _parts.Any(partType.IsInstanceOfType);
}
public IContent Get(Type partType) {
if (partType == typeof(ContentItem))
return this;
return _parts.FirstOrDefault(part => partType.IsAssignableFrom(part.GetType()));
return _parts.FirstOrDefault(partType.IsInstanceOfType);
}
public void Weld(ContentPart part) {

View File

@@ -54,11 +54,11 @@ namespace Orchard.ContentManagement {
public bool Has(Type fieldType, string fieldName) {
return _fields.Any(field => fieldType.IsAssignableFrom(field.GetType()) && field.Name == fieldName);
return _fields.Any(field => fieldType.IsInstanceOfType(field) && field.Name == fieldName);
}
public ContentField Get(Type fieldType, string fieldName) {
return _fields.FirstOrDefault(field => fieldType.IsAssignableFrom(field.GetType()) && field.Name == fieldName);
return _fields.FirstOrDefault(field => fieldType.IsInstanceOfType(field) && field.Name == fieldName);
}
public void Weld(ContentField field) {

View File

@@ -76,7 +76,7 @@ namespace Orchard.Data.Migration.Generator {
foreach(var table in tables.Where(t => parameters.RecordDescriptors.Any(rd => rd.Feature.Descriptor.Id == feature && rd.TableName == t.Name))) {
string tableName = table.Name;
var recordType = parameters.RecordDescriptors.Where(rd => rd.Feature.Descriptor.Id == feature && rd.TableName == tableName).First().Type;
var recordType = parameters.RecordDescriptors.First(rd => rd.Feature.Descriptor.Id == feature && rd.TableName == tableName).Type;
var isContentPart = typeof(ContentPartRecord).IsAssignableFrom(recordType);
if ( tableName.StartsWith(prefix) ) {

View File

@@ -119,7 +119,7 @@ namespace Orchard.Environment {
return false;
}
if (destinationType.IsAssignableFrom(value.GetType())) {
if (destinationType.IsInstanceOfType(value)) {
result = value;
return true;
}