protected override bool CreateAspectFor(ClassAcessor acessor, out DataAspectMember member) { DatabaseColumnAttribute dca = acessor.GetAttribute<DatabaseColumnAttribute>(true); if (dca == null) { member = null; return false; } else { member = new DataAspectMember( acessor, dca.StoredName, dca.ColumnKind == DatabaseColumnKind.Identity, dca.ColumnKind == DatabaseColumnKind.Unique, dca.ColumnKind == DatabaseColumnKind.PrimaryKey, dca.IsNullable, acessor.GetAttribute<Generator>(true)); return true; } }
protected override bool CreateAspectFor(ClassAcessor acessor, out DataAspectMember member) { DatabaseColumnAttribute dca = acessor.GetAttribute <DatabaseColumnAttribute>(true); if (dca == null) { member = null; return(false); } else { member = new DataAspectMember( acessor, dca.StoredName, dca.ColumnKind == DatabaseColumnKind.Identity, dca.ColumnKind == DatabaseColumnKind.Unique, dca.ColumnKind == DatabaseColumnKind.PrimaryKey, dca.IsNullable, acessor.GetAttribute <Generator>(true)); return(true); } }
protected override bool CreateAspectFor(ClassAcessor acessor, out FixedLengthAspectMember member) { FixedLengthColumnAttribute flca = acessor.GetAttribute <FixedLengthColumnAttribute>(true); if (flca == null) { member = null; return(false); } else { member = new FixedLengthAspectMember(acessor, flca); return(true); } }
protected override bool CreateAspectFor(ClassAcessor acessor, out SingleAnnotationAspectMember <TMemberAspect> member) { TMemberAspect tma = acessor.GetAttribute <TMemberAspect>(true); if (tma == null) { member = null; return(false); } else { member = new SingleAnnotationAspectMember <TMemberAspect>(acessor, tma); return(true); } }
protected override bool CreateAspectFor(ClassAcessor acessor, out HtmlInputAspectMember member) { HtmlInputAttribute hia = acessor.GetAttribute <HtmlInputAttribute>(true); if (hia == null) { member = null; return(false); } else { member = new HtmlInputAspectMember( acessor, hia.Fieldset, hia.InferType ? HtmlInputAspectMember.InferInputType(acessor.DataType) : hia.InputType, hia.OptionSource == null && acessor.DataType.IsEnum ? new HtmlInputOptionEnum(acessor.DataType) : null, InterceptorAspect <T> .Instance.GetMemberOrDefault(acessor.Name), RestrictionAspect <T> .Instance.GetMemberOrDefault(acessor.Name), GlobalizationAspect <T> .Instance.GetMemberOrDefault(acessor.Name)); return(true); } }
protected override bool CreateAspectFor(ClassAcessor acessor, out XmlAspectMember member) { XmlAttribute xa = acessor.GetAttribute <XmlAttribute>(true); if (xa == null) { member = null; return(false); } else { SimpleAdapter adapter = SimpleAdapters.CreateInstance( acessor.DataType, xa.FormatString, string.IsNullOrEmpty(xa.Culture) ? null : CultureInfo.GetCultureInfo(xa.Culture) ); if (adapter != null) { switch (xa.XmlType) { case XmlType.Attribute: member = new XmlAspectMemberAttribute( acessor, string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name, xa.IsMandatory, adapter); return(true); case XmlType.CDATA: member = new XmlAspectMemberCDATA( acessor, string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name, xa.IsMandatory, adapter); return(true); case XmlType.Element: member = new XmlAspectMemberText( acessor, string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name, xa.IsMandatory, adapter); return(true); default: throw new NotImplementedException("Unable to serialize primitive type with " + xa.XmlType); } } else if (typeof(IList).IsAssignableFrom(acessor.DataType)) { member = new XmlAspectMemberList( acessor, string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name, xa.IsMandatory); return(true); } else { member = new XmlAspectMemberComposite( acessor, string.IsNullOrEmpty(xa.Name) ? acessor.Name : xa.Name, xa.IsMandatory, GetInstance(acessor.DataType), acessor.DataType.GetConstructor(Type.EmptyTypes)); } return(true); } }
/// <summary> /// Gets an attribute. /// </summary> /// <typeparam name="TAttribute">Type of attribute to get.</typeparam> /// <param name="inherit">Indicates that it may be inherited.</param> /// <returns>The attribute or default.</returns> public TAttribute GetAttribute <TAttribute>(bool inherit) { return(_Acessor.GetAttribute <TAttribute>(inherit)); }