本文整理汇总了C#中Castle.ActiveRecord.Framework.Internal.ActiveRecordModel类的典型用法代码示例。如果您正苦于以下问题:C# ActiveRecordModel类的具体用法?C# ActiveRecordModel怎么用?C# ActiveRecordModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActiveRecordModel类属于Castle.ActiveRecord.Framework.Internal命名空间,在下文中一共展示了ActiveRecordModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProcessField
/// <summary>
/// Dispatches the call to the extensions.
/// </summary>
/// <param name="fi">The field info reflection object.</param>
/// <param name="model">The model.</param>
public void ProcessField(FieldInfo fi, ActiveRecordModel model)
{
foreach(IModelBuilderExtension extension in extensions)
{
extension.ProcessField(fi, model);
}
}
开发者ID:pallmall,项目名称:WCell,代码行数:12,代码来源:ModelBuilderExtensionComposite.cs
示例2: EditCatalogWindow
public EditCatalogWindow (string model, object record,
ActiveRecordModel mod, EventHandler OnSaveButtonClicked, Gtk.Window parent) :
base(Gtk.WindowType.Toplevel)
{
this.Build ();
this.TransientFor = parent;
this.Modal = true;
this.model = model;
this.mod = mod;
this.record = (ActiveRecordBase)record;
this.OnRecordSaved = OnSaveButtonClicked;
this.WindowPosition = Gtk.WindowPosition.CenterAlways;
this.Title = model + " creation";
modelLabel.Text = model;
if (!mod.PropertyDictionary.Keys.Contains("Notes"))
{
editRecord.HideNotesEntry ();
}
PropertyInfo p = record.GetType().GetProperty("ParentId");
if (p != null) {
MethodInfo modelMethod = record.GetType().GetMethod("ParentModel");
editRecord.ParentName = modelMethod.Invoke (record, null) as String;
MethodInfo nameMethod = record.GetType().GetMethod("ParentName");
editRecord.ParentValue = nameMethod.Invoke (record, null) as String;
} else {
editRecord.HideParentEntry ();
}
}
开发者ID:monsterlabs,项目名称:HumanRightsTracker,代码行数:34,代码来源:EditCatalogWindow.cs
示例3: ProcessProperty
/// <summary>
/// Dispatches the call to the extensions.
/// </summary>
/// <param name="pi">The property info reflection object.</param>
/// <param name="model">The model.</param>
public void ProcessProperty(PropertyInfo pi, ActiveRecordModel model)
{
foreach(IModelBuilderExtension extension in extensions)
{
extension.ProcessProperty(pi, model);
}
}
开发者ID:pallmall,项目名称:WCell,代码行数:12,代码来源:ModelBuilderExtensionComposite.cs
示例4: CreateXml
/// <summary>
/// Creates the XML.
/// </summary>
/// <param name="model">The model.</param>
public void CreateXml(ActiveRecordModel model)
{
CreateXmlPI();
StartMappingNode(model.UseAutoImport);
Ident();
VisitModel(model);
Dedent();
EndMappingNode();
if (ActiveRecordModel.isDebug)
{
String file = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, model.Type.Name + ".hbm.xml");
System.IO.File.Delete(file);
using(System.IO.FileStream fs = System.IO.File.OpenWrite(file))
{
String xml = Xml;
byte[] ba = System.Text.ASCIIEncoding.Unicode.GetBytes(xml);
fs.Write(ba, 0, ba.Length);
fs.Flush();
}
}
}
开发者ID:pallmall,项目名称:WCell,代码行数:31,代码来源:XmlGenerationVisitor.cs
示例5: VisitModel
/// <summary>
/// Visits the model.
/// </summary>
/// <param name="model">The model.</param>
public virtual void VisitModel(ActiveRecordModel model)
{
if (!visited.ContainsKey(model))
{
visited.Add(model, String.Empty);
}
else
{
return;
}
VisitNode(model.PrimaryKey);
VisitNode(model.CompositeKey);
VisitNode(model.Key);
VisitNode(model.Version);
VisitNode(model.Timestamp);
VisitNodes(model.JoinedClasses);
VisitNodes(model.JoinedTables);
VisitNodes(model.BelongsTo);
VisitNodes(model.Classes);
VisitNodes(model.Fields);
VisitNodes(model.Anys);
VisitNodes(model.Properties);
VisitNodes(model.OneToOnes);
VisitNodes(model.HasMany);
VisitNodes(model.HasAndBelongsToMany);
VisitNodes(model.HasManyToAny);
VisitNodes(model.CollectionIDs);
VisitNodes(model.Hilos);
VisitNodes(model.Components);
VisitNodes(model.CompositeUserType);
}
开发者ID:ray2006,项目名称:WCell,代码行数:36,代码来源:AbstractDepthFirstVisitor.cs
示例6: ObtainListableProperties
private IList ObtainListableProperties(ActiveRecordModel model)
{
var properties = new ArrayList();
ObtainPKProperty();
if (model.Parent != null)
{
properties.AddRange( ObtainListableProperties(model.Parent) );
}
foreach(var propModel in model.Properties)
{
if (IsNotSupported(propModel.Property.PropertyType)) continue;
properties.Add(propModel.Property);
}
foreach(var prop in model.NotMappedProperties)
{
if (IsNotSupported(prop.PropertyType)) continue;
properties.Add(prop);
}
return properties;
}
开发者ID:smoothdeveloper,项目名称:Castle.MonoRail,代码行数:27,代码来源:ListAction.cs
示例7: LinkToEdit
public String LinkToEdit(ActiveRecordModel model, bool useModelName,
String text, object key, IDictionary attributes)
{
string targetAction = "edit" + (useModelName ? model.Type.Name : "");
return LinkTo(targetAction, key, text, attributes);
}
开发者ID:candland,项目名称:Castle.MonoRail,代码行数:7,代码来源:PresentationHelper.cs
示例8: ProcessClass
/// <summary>
/// Dispatches the call to the extensions.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="model">The model.</param>
public void ProcessClass(Type type, ActiveRecordModel model)
{
foreach(IModelBuilderExtension extension in extensions)
{
extension.ProcessClass(type, model);
}
}
开发者ID:pallmall,项目名称:WCell,代码行数:12,代码来源:ModelBuilderExtensionComposite.cs
示例9: ProcessBelongsTo
/// <summary>
/// Dispatches the call to the extensions.
/// </summary>
/// <param name="pi">The property info reflection object.</param>
/// <param name="belongsToModel">The belongs to model.</param>
/// <param name="model">The model.</param>
public void ProcessBelongsTo(PropertyInfo pi, BelongsToModel belongsToModel, ActiveRecordModel model)
{
foreach(IModelBuilderExtension extension in extensions)
{
extension.ProcessBelongsTo(pi, belongsToModel, model);
}
}
开发者ID:pallmall,项目名称:WCell,代码行数:13,代码来源:ModelBuilderExtensionComposite.cs
示例10: VisitModel
/// <summary>
/// Visits the model.
/// </summary>
/// <param name="model">The model.</param>
public override void VisitModel(ActiveRecordModel model)
{
ActiveRecordModel savedModel = currentModel;
try
{
currentModel = model;
if (model.IsDiscriminatorBase || model.IsJoinedSubClassBase ||
model.IsDiscriminatorSubClass || model.IsJoinedSubClass)
{
foreach(ActiveRecordModel child in arCollection)
{
if (IsChildClass(model, child))
{
child.IsDiscriminatorSubClass = model.ActiveRecordAtt.DiscriminatorValue != null;
child.IsJoinedSubClass = child.Key != null;
child.Parent = model;
if (child.IsDiscriminatorSubClass)
{
// Needed for deep hierarchies
if (model.Classes.Contains(child) == false)
{
// Discriminator subclass
model.Classes.Add(child);
}
}
else if (child.IsJoinedSubClass)
{
// Needed for deep hierarchies
if (model.JoinedClasses.Contains(child) == false)
{
// Joined subclass
model.JoinedClasses.Add(child);
}
}
}
}
}
VisitNodes(model.JoinedClasses);
VisitNodes(model.Classes);
base.VisitModel(model);
// They should have been connected by now
model.CollectionIDs.Clear();
model.Hilos.Clear();
}
finally
{
currentModel = savedModel;
}
}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:59,代码来源:GraphConnectorVisitor.cs
示例11: PopulateModel
/// <summary>
/// Populates the model from tye type
/// </summary>
/// <param name="model">The model.</param>
/// <param name="type">The type.</param>
private static void PopulateModel(ActiveRecordModel model, Type type)
{
ProcessActiveRecordAttribute(type, model);
ProcessImports(type, model);
ProcessJoinedBaseAttribute(type, model);
ProcessProperties(type, model);
ProcessFields(type, model);
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:17,代码来源:ActiveRecordModelBuilder.cs
示例12: LoadActiveRecord
private object LoadActiveRecord(Type type, object pk, ARFetchAttribute attr, ActiveRecordModel model)
{
object instance = null;
if (pk != null && !String.Empty.Equals(pk))
{
PrimaryKeyModel pkModel = ObtainPrimaryKey(model);
Type pkType = pkModel.Property.PropertyType;
bool conversionSucceeded;
object convertedPk = converter.Convert(pkType, pk.GetType(), pk, out conversionSucceeded);
if (!conversionSucceeded)
{
throw new RailsException("ARFetcher could not convert PK {0} to type {1}", pk, pkType);
}
if (attr.Eager == null || attr.Eager.Length == 0)
{
// simple load
instance = ActiveRecordMediator.FindByPrimaryKey(type, convertedPk, attr.Required);
}
else
{
// load using eager fetching of lazy collections
DetachedCriteria criteria = DetachedCriteria.For(type);
criteria.Add(Expression.Eq(pkModel.Property.Name, convertedPk));
foreach (string associationToEagerFetch in attr.Eager.Split(','))
{
string clean = associationToEagerFetch.Trim();
if (clean.Length == 0)
{
continue;
}
criteria.SetFetchMode(clean, FetchMode.Eager);
}
object[] result = (object[]) ActiveRecordMediator.FindAll(type, criteria);
if (result.Length > 0)
instance = result[0];
}
}
if (instance == null && attr.Create)
{
instance = Activator.CreateInstance(type);
}
return instance;
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:52,代码来源:ARFetcher.cs
示例13: LinkToNew
public String LinkToNew(ActiveRecordModel model, bool useModelName, String text, IDictionary attributes)
{
if (useModelName)
{
return String.Format("<a href=\"new{0}.{1}\" {3}>{2}</a>", model.Type.Name,
Controller.Context.UrlInfo.Extension, text, GetAttributes(attributes));
}
else
{
return String.Format("<a href=\"new.{0}\" {2}>{1}</a>",
Controller.Context.UrlInfo.Extension, text, GetAttributes(attributes));
}
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:13,代码来源:PresentationHelper.cs
示例14: LinkToEdit
public String LinkToEdit(ActiveRecordModel model, bool useModelName,
String text, object key, IDictionary attributes)
{
if (useModelName)
{
return String.Format("<a href=\"edit{0}.{1}?id={4}\" {3}>{2}</a>", model.Type.Name,
Controller.Context.UrlInfo.Extension, text, GetAttributes(attributes), key);
}
else
{
return String.Format("<a href=\"edit.{0}?id={3}\" {2}>{1}</a>",
Controller.Context.UrlInfo.Extension, text, GetAttributes(attributes), key);
}
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:14,代码来源:PresentationHelper.cs
示例15: Create
/// <summary>
/// Creates a <see cref="ActiveRecordModel"/> from the specified type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns></returns>
public ActiveRecordModel Create(Type type)
{
if (type == null) throw new ArgumentNullException("type");
if (type.IsDefined(typeof(ActiveRecordSkipAttribute), false)) return null;
ActiveRecordModel model = new ActiveRecordModel(type);
coll.Add(model);
PopulateModel(model, type);
ActiveRecordBase.Register(type, model);
return model;
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:21,代码来源:ActiveRecordModelBuilder.cs
示例16: ObtainPKProperty
public static PrimaryKeyModel ObtainPKProperty(ActiveRecordModel model)
{
if (model == null) return null;
ActiveRecordModel curModel = model;
while (curModel != null)
{
if (curModel.PrimaryKey != null)
{
return curModel.PrimaryKey;
}
curModel = curModel.Parent;
}
return null;
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:18,代码来源:ARCommonUtils.cs
示例17: RecordNode
public RecordNode (Object record, ActiveRecordModel mod)
{
Record = record;
this.mod = mod;
PropertyInfo nameProp = mod.PropertyDictionary["Name"].Property;
Name = nameProp.GetValue(record, null) as String;
MethodInfo parentMethod = mod.Type.GetMethod("ParentName");
hasParent = parentMethod != null;
if (hasParent) {
PropertyInfo parentProp = mod.Type.GetProperty ("ParentId");
parentId = (parentProp.GetValue(record, null) as int?).Value;
if (parentId > 0)
ParentName = parentMethod.Invoke (record, null) as String;
else
ParentName = "";
} else {
ParentName = "";
}
MethodInfo categoryMethod = mod.Type.GetMethod("CategoryName");
hasCategory = categoryMethod != null;
if (hasCategory) {
PropertyInfo categoryProp = mod.Type.GetProperty ("CategoryId");
categoryId = (categoryProp.GetValue(record, null) as int?).Value;
if (categoryId > 0)
CategoryName = categoryMethod.Invoke (record, null) as String;
else
CategoryName = "";
} else {
CategoryName = "";
}
hasNotes = mod.PropertyDictionary.ContainsKey ("Notes");
if (hasNotes) {
PropertyInfo notesProp = mod.Type.GetProperty ("Notes");
Notes = (notesProp.GetValue(record, null) as String);
} else {
Notes = "";
}
Selected = false;
}
开发者ID:monsterlabs,项目名称:HumanRightsTracker,代码行数:43,代码来源:CatalogCRUD.cs
示例18: GetModelHierarchy
public ICollection GetModelHierarchy(ActiveRecordModel model, object instance)
{
ArrayList list = new ArrayList();
ActiveRecordModel hierarchy = model;
while(hierarchy != null)
{
list.Add(hierarchy);
hierarchy = ActiveRecordModel.GetModel(hierarchy.Type.BaseType);
}
hierarchy = model;
while(hierarchy != null)
{
foreach(NestedModel nested in hierarchy.Components)
{
object nestedInstance = nested.Property.GetValue(instance, null);
if (nestedInstance == null)
{
nestedInstance = CreationUtil.Create(nested.Property.PropertyType);
}
if (nestedInstance != null)
{
model2nestedInstance[nested.Model] = nestedInstance;
}
list.Add(nested.Model);
}
hierarchy = ActiveRecordModel.GetModel(hierarchy.Type.BaseType);
}
return list;
}
开发者ID:candland,项目名称:Castle.MonoRail,代码行数:39,代码来源:ARFormHelper.cs
示例19: ProcessJoinedBaseAttribute
private static void ProcessJoinedBaseAttribute(Type type, ActiveRecordModel model)
{
model.IsJoinedSubClassBase = type.IsDefined(typeof(JoinedBaseAttribute), false);
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:4,代码来源:ActiveRecordModelBuilder.cs
示例20: ProcessImports
private static void ProcessImports(Type type, ActiveRecordModel model)
{
object[] attrs = type.GetCustomAttributes(typeof(ImportAttribute), false);
foreach (ImportAttribute att in attrs)
{
ImportModel im = new ImportModel(att);
model.Imports.Add(im);
}
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:10,代码来源:ActiveRecordModelBuilder.cs
注:本文中的Castle.ActiveRecord.Framework.Internal.ActiveRecordModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论