本文整理汇总了C#中NHibernate.Mapping.List.Add方法的典型用法代码示例。如果您正苦于以下问题:C# List.Add方法的具体用法?C# List.Add怎么用?C# List.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Mapping.List
的用法示例。
在下文中一共展示了List.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperties
public override PropertyDescriptorCollection GetProperties()
{
if (_properties == null)
{
bool hasEntityAttributes = false;
_properties = base.GetProperties();
var list = new List<PropertyDescriptor>();
foreach (PropertyDescriptor descriptor in _properties)
{
List<Attribute> attrs = GetEntityMemberAttributes(descriptor).ToList();
if (_metaDataAttributes.ContainsKey(descriptor.Name))
attrs.AddRange(_metaDataAttributes[descriptor.Name]);
if (attrs.Any())
{
hasEntityAttributes = true;
list.Add(new PropertyDescriptorWrapper(descriptor, attrs.ToArray()));
}
else
{
list.Add(descriptor);
}
}
if (hasEntityAttributes)
_properties = new PropertyDescriptorCollection(list.ToArray(), true);
}
return _properties;
}
示例2: viewroots
public void viewroots() {
var result = new List<string>();
result.Add(MonoRailConfiguration.GetConfig().ViewEngineConfig.ViewPathRoot);
foreach (var path in MonoRailConfiguration.GetConfig().ViewEngineConfig.PathSources) {
result.Add(path);
}
PropertyBag["result"] = result;
}
示例3: GetSlabInfoByTimeInterval
public ISlabInfo[] GetSlabInfoByTimeInterval(long aFrom, long aTo)
{
try {
using (var session = NHibernateHelper.OpenSession()) {
var entitys = session.CreateCriteria(typeof(SlabInfoEntity))
.Add(Restrictions.Between("StartScanTime", aFrom, aTo))
.List<SlabInfoEntity>();
var results = new List<ISlabInfo>();
foreach (var entity in entitys) {
results.Add(new SlabInfoImpl {
Id = entity.Id,
Number = entity.Number,
StandartSizeId = entity.StandartSizeId,
StartScanTime = entity.StartScanTime,
EndScanTime = entity.EndScanTime
});
}
return results.ToArray();
}
}
catch (Exception ex) {
logger.Error("Ошибка при чтении SlabInfo: " + ex.Message);
return null;
}
}
示例4: GetContentList
public List<DiskContentModel> GetContentList(Directories dir)
{
var listOfDirectories = dir.SubFolder.ToList();
var listOfContent = new List<DiskContentModel>();
foreach (var dirs in listOfDirectories)
{
listOfContent.Add(Mapper.Map<Directories, DiskContentModel>(dirs));
}
return listOfContent;
}
示例5: Main
static void Main(string[] args)
{
var results = new List<TestResult>();
results.Add(AdoDataAccess());
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
results.Add(DapperDataAccess());
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
results.Add(EfDataAccess());
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
results.Add(EfFastDataAccess());
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
results.Add(NhDataAccess());
ConsoleTable.From(results).Write();
Console.WriteLine("Teste finalizado");
Console.ReadKey();
}
示例6: CreateForeignKeyOfEntity
public override void CreateForeignKeyOfEntity(string entityName)
{
if (!HasFormula && !string.Equals("none", ForeignKeyName, StringComparison.InvariantCultureIgnoreCase))
{
var referencedColumns = new List<Column>(_prototype.ColumnSpan);
foreach (Column column in _prototype.ColumnIterator)
{
referencedColumns.Add(column);
}
ForeignKey fk = Table.CreateForeignKey(ForeignKeyName, ConstraintColumns, entityName, referencedColumns);
fk.CascadeDeleteEnabled = IsCascadeDeleteEnabled;
}
}
示例7: GenerateSchemaDropScriptAuxiliaryDatabaseObjects
public string[] GenerateSchemaDropScriptAuxiliaryDatabaseObjects(Func<IAuxiliaryDatabaseObject, bool> predicate)
{
Dialect dialect = Dialect.GetDialect(Properties);
string defaultCatalog = PropertiesHelper.GetString("default_catalog", Properties, null);
string defaultSchema = PropertiesHelper.GetString("default_schema", Properties, null);
List<string> list = new List<string>();
foreach (IAuxiliaryDatabaseObject obj2 in auxiliaryDatabaseObjects.Where(predicate))
{
if (obj2.AppliesToDialect(dialect))
{
list.Add(obj2.SqlDropString(dialect,defaultCatalog, defaultSchema));
}
}
return list.ToArray();
}
示例8: AnalysisChromatograms
public AnalysisChromatograms(PeptideFileAnalysis peptideFileAnalysis)
{
PeptideFileAnalysis = peptideFileAnalysis;
FirstTime = peptideFileAnalysis.FirstTime;
LastTime = peptideFileAnalysis.LastTime;
Chromatograms = new List<ChromatogramGenerator.Chromatogram>();
for (int charge = PeptideAnalysis.MinCharge; charge <= PeptideAnalysis.MaxCharge; charge ++)
{
var mzs = PeptideAnalysis.TurnoverCalculator.GetMzs(charge);
for (int massIndex = 0; massIndex < mzs.Count; massIndex ++)
{
Chromatograms.Add(new ChromatogramGenerator.Chromatogram(new MzKey(charge, massIndex), mzs[massIndex]));
}
}
ScanIndexes = new List<int>();
Times = new List<double>();
}
示例9: BindModel
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var siteCopyOptions = new List<SiteCopyOption>();
NameValueCollection form = controllerContext.HttpContext.Request.Form;
IEnumerable<string> keys = form.AllKeys.Where(s => s.StartsWith("sco-"));
foreach (string key in keys)
{
string value = form[key];
int id;
string typeName = key.Substring(4);
Type type = TypeHelper.GetTypeByName(typeName);
if (int.TryParse(value, out id) && type != null)
{
siteCopyOptions.Add(new SiteCopyOption {SiteCopyActionType = type, SiteId = id});
}
}
return siteCopyOptions;
}
示例10: InverseProgressivePath
/// <summary>
/// Provide the list of progressive-paths
/// </summary>
/// <param name="source"></param>
/// <returns>
/// Given a path as : Pl1.Pl2.Pl3.Pl4.Pl5 returns paths-sequence as:
/// Pl5
/// Pl4.Pl5
/// Pl3.Pl4.Pl5
/// Pl2.Pl3.Pl4.Pl5
/// Pl1.Pl2.Pl3.Pl4.Pl5
/// </returns>
public static IEnumerable<PropertyPath> InverseProgressivePath(this PropertyPath source)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
var analizing = source;
var returnLocalMembers = new List<MemberInfo>(10);
do
{
returnLocalMembers.Add(analizing.LocalMember);
PropertyPath progressivePath = null;
for (int i = returnLocalMembers.Count -1; i >= 0; i--)
{
progressivePath = new PropertyPath(progressivePath, returnLocalMembers[i]);
}
yield return progressivePath;
analizing = analizing.PreviousPath;
}
while (analizing != null);
}
示例11: SyncRoles
private void SyncRoles(IList<RoleCheckBox> checkBoxes, IList<Role> roles)
{
var selectedRoles = new List<Role>();
foreach (var role in Database.Session.Query<Role>())
{
var checkbox = checkBoxes.Single(a => a.Id == role.Id);
checkbox.Name = role.Name;
if(checkbox.IsChecked)
selectedRoles.Add(role);
}
foreach (var toAdd in selectedRoles.Where(a => !roles.Contains(a)))
roles.Add(toAdd);
foreach (var toRemove in roles.Where(a => !selectedRoles.Contains(a)).ToList())
roles.Remove(toRemove);
}
示例12: GetImplementors
/// <summary>
/// Return the names of all persistent (mapped) classes that extend or implement the
/// given class or interface, accounting for implicit/explicit polymorphism settings
/// and excluding mapped subclasses/joined-subclasses of other classes in the result.
/// </summary>
public string[] GetImplementors(string className)
{
System.Type clazz = null;
// NH Different implementation for performance: a class without at least a namespace sure can't be found by reflection
if (className.IndexOf('.') > 0)
{
IEntityPersister checkPersister;
// NH Different implementation: we have better performance checking, first of all, if we know the class
// and take the System.Type directly from the persister (className have high probability to be entityName)
if (entityPersisters.TryGetValue(className, out checkPersister))
{
if(!checkPersister.EntityMetamodel.HasPocoRepresentation)
{
// we found the persister but it is a dynamic entity without class
return new[] { className };
}
// NH : take care with this because we are forcing the Poco EntityMode
clazz = checkPersister.GetMappedClass(EntityMode.Poco);
}
if (clazz == null)
{
try
{
clazz = ReflectHelper.ClassForFullName(className);
}
catch (Exception)
{
clazz = null;
}
}
}
if (clazz == null)
{
return new[] {className}; //for a dynamic-class
}
List<string> results = new List<string>();
foreach (IEntityPersister p in entityPersisters.Values)
{
IQueryable q = p as IQueryable;
if (q != null)
{
string testClassName = q.EntityName;
bool isMappedClass = className.Equals(testClassName);
if (q.IsExplicitPolymorphism)
{
if (isMappedClass)
{
return new string[] {testClassName}; // NOTE EARLY EXIT
}
}
else
{
if (isMappedClass)
{
results.Add(testClassName);
}
else
{
System.Type mappedClass = q.GetMappedClass(EntityMode.Poco);
if (mappedClass != null && clazz.IsAssignableFrom(mappedClass))
{
bool assignableSuperclass;
if (q.IsInherited)
{
System.Type mappedSuperclass = GetEntityPersister(q.MappedSuperclass).GetMappedClass(EntityMode.Poco);
assignableSuperclass = clazz.IsAssignableFrom(mappedSuperclass);
}
else
{
assignableSuperclass = false;
}
if (!assignableSuperclass)
{
results.Add(testClassName);
}
}
}
}
}
}
return results.ToArray();
}
示例13: UpdateWardList
private void UpdateWardList(List<Ward> wardList, FormCollection model, string key)
{
var wardCounter = Convert.ToInt32(key.Substring(key.IndexOf("_", StringComparison.CurrentCultureIgnoreCase) + 1));
if (wardList.Count < wardCounter)
{
wardList.Add(new Ward());
}
var ward = wardList[wardCounter - 1];
switch(key.Substring(0,key.IndexOf("_", StringComparison.CurrentCultureIgnoreCase)))
{
case "wardMemberId":
ward.MemberId = Convert.ToInt32(model[key]);
break;
case "wardLastname":
ward.Lastname = model[key];
break;
case "wardFirstname":
ward.Firstname = model[key];
break;
case "wardNickname":
ward.Nickname = model[key];
break;
case "wardDob":
ward.Dob = DateTime.Parse(model[key]);
break;
}
}
示例14: Search
public SearchResults Search(SearchRequest request)
{
if (!OpenReader())
{
return new SearchResults { Query = request.Query };
}
if (!reader.IsCurrent())
{
reader = reader.Reopen();
}
var take = request.Take > 0 ? request.Take : SearchModuleConstants.DefaultSearchResultsCount;
var skip = request.Skip > 0 ? request.Skip : 0;
var result = new List<SearchResultItem>();
TopScoreDocCollector collector = TopScoreDocCollector.Create(take + skip, true);
using (var searcher = new IndexSearcher(reader))
{
var searchQuery = request.Query;
Query query;
try
{
query = parser.Parse(searchQuery);
}
catch (ParseException)
{
try
{
searchQuery = QueryParser.Escape(searchQuery);
query = parser.Parse(searchQuery);
}
catch (ParseException exc)
{
throw new ValidationException(() => exc.Message, exc.Message, exc);
}
}
Filter isPublishedFilter = null;
if (!RetrieveUnpublishedPages())
{
var isPublishedQuery = new TermQuery(new Term(LuceneIndexDocumentKeys.IsPublished, "true"));
isPublishedFilter = new QueryWrapperFilter(isPublishedQuery);
}
if (LuceneSearchHelper.Search != null)
{
collector = LuceneSearchHelper.Search(query, isPublishedFilter, collector);
}
else
{
query = LuceneEvents.Instance.OnSearchQueryExecuting(query, searchQuery).Query;
if (isPublishedFilter != null)
{
// Exclude unpublished pages
searcher.Search(query, isPublishedFilter, collector);
}
else
{
// Search within all the pages
searcher.Search(query, collector);
}
}
ScoreDoc[] hits = collector.TopDocs(skip, take).ScoreDocs;
List<Document> hitDocuments = new List<Document>();
for (int i = 0; i < hits.Length; i++)
{
int docId = hits[i].Doc;
Document d = searcher.Doc(docId);
hitDocuments.Add(d);
result.Add(
new SearchResultItem
{
FormattedUrl = d.Get(LuceneIndexDocumentKeys.Path),
Link = d.Get(LuceneIndexDocumentKeys.Path),
Title = d.Get(LuceneIndexDocumentKeys.Title),
Snippet = GetSnippet(d.Get(LuceneIndexDocumentKeys.Content), request.Query)
});
}
CheckAvailability(result);
LuceneEvents.Instance.OnSearchResultRetrieving(hitDocuments, result);
}
return new SearchResults
{
Items = result,
Query = request.Query,
TotalResults = collector.TotalHits
};
}
示例15: RetrieveUnpublishedPages
private bool RetrieveUnpublishedPages()
{
// Check if user can manage content
var allRoles = new List<string>(RootModuleConstants.UserRoles.AllRoles);
if (!string.IsNullOrEmpty(cmsConfiguration.Security.FullAccessRoles))
{
allRoles.Add(cmsConfiguration.Security.FullAccessRoles);
}
var retrieveUnpublishedPages = securityService.IsAuthorized(RootModuleConstants.UserRoles.MultipleRoles(allRoles.ToArray()));
return retrieveUnpublishedPages;
}