本文整理汇总了C#中Mappings类的典型用法代码示例。如果您正苦于以下问题:C# Mappings类的具体用法?C# Mappings怎么用?C# Mappings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mappings类属于命名空间,在下文中一共展示了Mappings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MappingRootBinder
public MappingRootBinder(Mappings mappings, XmlNamespaceManager namespaceManager,
Dialect.Dialect dialect)
: base(mappings)
{
this.namespaceManager = namespaceManager;
this.dialect = dialect;
}
示例2: CreateCustomObject
private static IAuxiliaryDatabaseObject CreateCustomObject(Mappings mappings, HbmDatabaseObject databaseObjectSchema)
{
HbmDefinition definitionSchema = databaseObjectSchema.FindDefinition();
string customTypeName = [email protected];
try
{
string className =
TypeNameParser.Parse(customTypeName, mappings.DefaultNamespace, mappings.DefaultAssembly).ToString();
System.Type customType = ReflectHelper.ClassForName(className);
IAuxiliaryDatabaseObject customObject = (IAuxiliaryDatabaseObject)Activator.CreateInstance(customType);
Dictionary<string, string> parameters = definitionSchema.FindParameters();
customObject.SetParameterValues(parameters);
foreach (string dialectName in databaseObjectSchema.FindDialectScopeNames())
{
customObject.AddDialectScope(dialectName);
}
return customObject;
}
catch (TypeLoadException exception)
{
throw new MappingException(string.Format("Could not locate custom database object class [{0}].", customTypeName),
exception);
}
catch (Exception exception)
{
throw new MappingException(
string.Format("Could not instantiate custom database object class [{0}].", customTypeName), exception);
}
}
示例3: Binder
protected Binder(Mappings mappings)
{
if (mappings == null)
throw new ArgumentNullException("mappings");
this.mappings = mappings;
}
示例4: FullClassName
/// <summary>
/// Converts a partial class name into a fully one
/// </summary>
/// <param name="className"></param>
/// <param name="mappings"></param>
/// <returns>The class FullName (without the assembly)</returns>
/// <remarks>
/// The FullName is equivalent to the default entity-name
/// </remarks>
protected static string FullClassName(string className, Mappings mappings)
{
if (className == null)
return null;
return TypeNameParser.Parse(className, mappings.DefaultNamespace, mappings.DefaultAssembly).Type;
}
示例5: TypeBinder
public TypeBinder(SimpleValue value, Mappings mappings)
: base(mappings)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
this.value = value;
}
示例6: PropertiesBinder
public PropertiesBinder(Mappings mappings, Component component, string className, string path, bool isNullable, Dialect.Dialect dialect)
: base(mappings, dialect)
{
persistentClass = component.Owner;
this.component = component;
entityName = className;
this.className = component.ComponentClassName;
mappedClass = component.ComponentClass;
propertyBasePath = path;
componetDefaultNullable = isNullable;
}
示例7: Scan
public static FluentConfig Scan(Action<IConventionScanner> scanner)
{
var scannerSettings = ProcessSettings(scanner);
if (scannerSettings.Lazy)
{
var lazyPocoMappings = new Mappings();
return SetFactory(lazyPocoMappings, scanner);
}
return Configure(CreateMappings(scannerSettings, null));
}
示例8: Scan
public static Mappings Scan(Action<IConventionScanner> scanner)
{
var scannerSettings = ProcessSettings(scanner);
if (scannerSettings.Lazy)
{
var lazyPocoMappings = new Mappings();
SetFactory(lazyPocoMappings, scanner);
return lazyPocoMappings;
}
return CreateMappings(scannerSettings, null);
}
示例9: PostgresBulkInserter
public PostgresBulkInserter(string nameOrConnectionString, Type type, Mappings columnMappings = null)
{
_type = type;
try
{
_connectionString = ConfigUtilities.GetConnectionString(nameOrConnectionString);
}
catch (ConfigurationErrorsException configException)
{
_connectionString = nameOrConnectionString;
}
ColumnMappings = columnMappings ?? new Mappings(type).MapDirectly();
}
示例10: GetMappings
public void GetMappings()
{
string folder = @"../../Framework/TestData/Mappings";
Mappings mapping = new Mappings(folder);
Assert.IsNotNull(mapping);
Assert.AreEqual(8, mapping.Count);
IList specials = GetSpecialMaps(mapping.Keys);
Assert.AreEqual(1, specials.Count);
Assert.IsNotNull(mapping["java.lang.StringBuffer"]);
IDictionary ressField = mapping["java.lang.StringBuffer"].Members;
Assert.AreEqual(4, ressField.Count);
}
示例11: CanBulkInsertIntoPostgres
public void CanBulkInsertIntoPostgres()
{
var mappings = new Mappings<Db>().MapAsLowercaseUnderscore();
Chronos.PostgreSQL.PostgresBulkInserter<Db> bcp = new Chronos.PostgreSQL.PostgresBulkInserter<Db>("Server=127.0.0.1;Port=5432;Database=jinx;User Id=postgres;Password=postgres", mappings);
var itemsToInsert = new List<Db>
{
new Db {DatabaseId = Guid.NewGuid(), Name = "Random1"},
new Db {DatabaseId = Guid.NewGuid(), Name = "Random2"},
new Db {DatabaseId = Guid.NewGuid(), Name = "Random4"},
new Db {DatabaseId = Guid.NewGuid(), Name = "Random3"},
new Db {DatabaseId = Guid.NewGuid(), Name = "Random5"},
new Db {DatabaseId = Guid.NewGuid(), Name = "Random6"},
new Db {DatabaseId = Guid.NewGuid(), Name = "Random7"},
};
bcp.Insert(itemsToInsert, "databases");
}
示例12: CanBulkInsertToPostgresNonGenericly
public void CanBulkInsertToPostgresNonGenericly()
{
var mappings = new Mappings(typeof(Db)).MapAsLowercaseUnderscore();
var bcp = new Chronos.PostgreSQL.PostgresBulkInserter("Server=127.0.0.1;Port=5432;Database=jinx;User Id=postgres;Password=postgres", typeof(Db),mappings);
var itemsToInsert = new List<Db>
{
new Db {DatabaseId = Guid.NewGuid(), Name = "NonGeneric"},
new Db {DatabaseId = Guid.NewGuid(), Name = "RNonGenericandom2"},
new Db {DatabaseId = Guid.NewGuid(), Name = "RNonGenericandom4"},
new Db {DatabaseId = Guid.NewGuid(), Name = "RNonGenericandom3"},
new Db {DatabaseId = Guid.NewGuid(), Name = "NonGenericRandom5"},
new Db {DatabaseId = Guid.NewGuid(), Name = "RNonGenericandom6"},
new Db {DatabaseId = Guid.NewGuid(), Name = "RNonGenericandom7"},
};
bcp.Insert(itemsToInsert, "databases");
}
示例13: CreateMappings
private static Mappings CreateMappings(ConventionScannerSettings scannerSettings, Type[] typesOverride)
{
var types = typesOverride ?? FindTypes(scannerSettings);
var config = new Dictionary<Type, TypeDefinition>();
foreach (var type in types)
{
var pocoDefn = new TypeDefinition(type)
{
AutoIncrement = scannerSettings.PrimaryKeysAutoIncremented(type),
PrimaryKey = scannerSettings.PrimaryKeysNamed(type),
TableName = scannerSettings.TablesNamed(type),
SequenceName = scannerSettings.SequencesNamed(type),
ExplicitColumns = true
};
foreach (var prop in ReflectionUtils.GetFieldsAndPropertiesForClasses(type))
{
var column = new ColumnDefinition();
column.MemberInfo = prop;
column.DbColumnName = scannerSettings.PropertiesNamed(prop);
column.DbColumnAlias = scannerSettings.AliasNamed(prop);
column.IgnoreColumn = scannerSettings.IgnorePropertiesWhere.Any(x => x.Invoke(prop));
column.DbColumnType = scannerSettings.DbColumnTypesAs(prop);
column.ResultColumn = scannerSettings.ResultPropertiesWhere(prop);
column.ComputedColumn = scannerSettings.ComputedPropertiesWhere(prop);
column.VersionColumn = scannerSettings.VersionPropertiesWhere(prop);
column.ForceUtc = scannerSettings.ForceDateTimesToUtcWhere(prop);
pocoDefn.ColumnConfiguration.Add(prop.Name, column);
}
config.Add(type, pocoDefn);
}
MergeOverrides(config, scannerSettings.MappingOverrides);
//if (scannerSettings.OverrideWithAttributes)
//{
// MergeAttributeOverrides(config);
//}
var pocoMappings = new Mappings {Config = config};
return pocoMappings;
}
示例14: Diff
public override DifferenceType Diff(IDifferences differences, Mappings.MemberMapping mapping)
{
ITypeDefinitionMember impl = mapping[0];
ITypeDefinitionMember contract = mapping[1];
if (impl == null)
return DifferenceType.Unknown;
if (contract == null && impl.IsAbstract())
{
// If the type is effectively sealed then it is ok to remove abstract members
ITypeDefinition contractType = mapping.ContainingType[1];
// We check that interfaces have the same number of members in another rule so there is no need to check that here.
if (contractType != null && (contractType.IsEffectivelySealed() || (contractType.IsInterface && mapping.ContainingType[0].IsInterface)))
return DifferenceType.Unknown;
differences.AddIncompatibleDifference(this,
"Member '{0}' is abstract in the implementation but is missing in the contract.",
impl.FullName());
return DifferenceType.Changed;
}
return DifferenceType.Unknown;
}
示例15: CreateMappings
private static Mappings CreateMappings(ConventionScannerSettings scannerSettings, Type[] typesOverride)
{
var types = typesOverride ?? FindTypes(scannerSettings);
var config = new Dictionary<Type, TypeDefinition>();
foreach (var type in types)
{
var pocoDefn = new TypeDefinition(type)
{
AutoIncrement = scannerSettings.PrimaryKeysAutoIncremented(type),
PrimaryKey = scannerSettings.PrimaryKeysNamed(type),
TableName = scannerSettings.TablesNamed(type),
SequenceName = scannerSettings.SequencesNamed(type),
};
foreach (var prop in type.GetProperties())
{
var column = new ColumnDefinition();
column.PropertyInfo = prop;
column.DbColumnName = scannerSettings.PropertiesNamed(prop);
column.IgnoreColumn = scannerSettings.IgnorePropertiesWhere.Any(x => x.Invoke(prop));
column.ResultColumn = scannerSettings.ResultPropertiesWhere(prop);
column.VersionColumn = scannerSettings.VersionPropertiesWhere(prop);
pocoDefn.ColumnConfiguration.Add(prop.Name, column);
}
config.Add(type, pocoDefn);
}
MergeOverrides(config, scannerSettings.MappingOverrides);
var pocoMappings = new Mappings {Config = config};
SetFactory(pocoMappings, null);
return pocoMappings;
}