本文整理汇总了C#中Castle.ActiveRecord.Framework.Internal.ActiveRecordModel类的典型用法代码示例。如果您正苦于以下问题:C# ActiveRecordModel类的具体用法?C# ActiveRecordModel怎么用?C# ActiveRecordModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActiveRecordModel类属于Castle.ActiveRecord.Framework.Internal命名空间,在下文中一共展示了ActiveRecordModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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 ();
}
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例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));
}
}
示例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);
}
}
示例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;
}