本文整理汇总了C#中ISetter类的典型用法代码示例。如果您正苦于以下问题:C# ISetter类的具体用法?C# ISetter怎么用?C# ISetter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISetter类属于命名空间,在下文中一共展示了ISetter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AbstractEntityTuplizer
/// <summary> Constructs a new AbstractEntityTuplizer instance. </summary>
/// <param name="entityMetamodel">The "interpreted" information relating to the mapped entity. </param>
/// <param name="mappingInfo">The parsed "raw" mapping data relating to the given entity. </param>
protected AbstractEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
{
this.entityMetamodel = entityMetamodel;
if (!entityMetamodel.IdentifierProperty.IsVirtual)
{
idGetter = BuildPropertyGetter(mappingInfo.IdentifierProperty, mappingInfo);
idSetter = BuildPropertySetter(mappingInfo.IdentifierProperty, mappingInfo);
}
else
{
idGetter = null;
idSetter = null;
}
propertySpan = entityMetamodel.PropertySpan;
getters = new IGetter[propertySpan];
setters = new ISetter[propertySpan];
bool foundCustomAccessor = false;
int i = 0;
foreach (Mapping.Property property in mappingInfo.PropertyClosureIterator)
{
getters[i] = BuildPropertyGetter(property, mappingInfo);
setters[i] = BuildPropertySetter(property, mappingInfo);
if (!property.IsBasicPropertyAccessor)
foundCustomAccessor = true;
i++;
}
if (log.IsDebugEnabled)
{
log.DebugFormat("{0} accessors found for entity: {1}", foundCustomAccessor ? "Custom" : "No custom",
mappingInfo.EntityName);
}
hasCustomAccessors = foundCustomAccessor;
//NH-1587
//instantiator = BuildInstantiator(mappingInfo);
if (entityMetamodel.IsLazy)
{
proxyFactory = BuildProxyFactory(mappingInfo, idGetter, idSetter);
if (proxyFactory == null)
{
entityMetamodel.IsLazy = false;
}
}
else
{
proxyFactory = null;
}
Mapping.Component mapper = mappingInfo.IdentifierMapper;
identifierMapperType = mapper == null ? null : (IAbstractComponentType)mapper.Type;
}
示例2: GetReflectionOptimizer
public override IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters)
{
if (clazz.IsValueType)
{
// Cannot create optimizer for value types - the setter method will not work.
log.Info("Disabling reflection optimizer for value type " + clazz.FullName);
return null;
}
return new Generator(clazz, getters, setters).CreateReflectionOptimizer();
}
示例3: AccessOptimizer
public AccessOptimizer(GetPropertyValuesInvoker getDelegate, SetPropertyValuesInvoker setDelegate,
IGetter[] getters, ISetter[] setters)
{
this.getDelegate = getDelegate;
this.setDelegate = setDelegate;
this.getters = getters;
this.setters = setters;
getterCallback = OnGetterCallback;
setterCallback = OnSetterCallback;
}
示例4: Create
/// <summary>
/// Generate the IGetSetHelper object
/// </summary>
/// <param name="mappedClass">The target class</param>
/// <param name="setters">Array of setters</param>
/// <param name="getters">Array of getters</param>
/// <returns>null if the generation fail</returns>
public static IGetSetHelper Create( System.Type mappedClass, ISetter[] setters, IGetter[] getters )
{
if (mappedClass.IsValueType)
{
// Cannot create optimizer for value types - the setter method will not work.
log.Info( "Disabling reflection optimizer for value type " + mappedClass.FullName );
return null;
}
return new GetSetHelperFactory( mappedClass, setters, getters ).CreateGetSetHelper();
}
示例5: NoGetter
public void NoGetter()
{
IGetter[] getters = new IGetter[]
{
new BasicPropertyAccessor.BasicGetter(typeof (NoGetterClass), typeof (NoGetterClass).GetProperty("Property"), "Property")
};
ISetter[] setters = new ISetter[]
{
new BasicPropertyAccessor.BasicSetter(typeof (NoGetterClass), typeof (NoGetterClass).GetProperty("Property"), "Property")
};
Assert.Throws<PropertyNotFoundException>(() => new ReflectionOptimizer(typeof (NoGetterClass), getters, setters));
}
示例6: ComponentType
public ComponentType(System.Type componentClass,
string[] propertyNames,
IGetter[] propertyGetters,
ISetter[] propertySetters,
// currently not used, see the comment near the end of the method body
bool foundCustomAcessor,
IType[] propertyTypes,
bool[] nullabilities,
FetchMode[] joinedFetch,
Cascades.CascadeStyle[] cascade,
string parentProperty)
{
this.componentClass = componentClass;
this.propertyTypes = propertyTypes;
this.propertyNullability = nullabilities;
propertySpan = propertyNames.Length;
getters = propertyGetters;
setters = propertySetters;
string[] getterNames = new string[propertySpan];
string[] setterNames = new string[propertySpan];
System.Type[] propTypes = new System.Type[propertySpan];
for (int i = 0; i < propertySpan; i++)
{
getterNames[i] = getters[i].PropertyName;
setterNames[i] = setters[i].PropertyName;
propTypes[i] = getters[i].ReturnType;
}
if (parentProperty == null)
{
parentSetter = null;
parentGetter = null;
}
else
{
IPropertyAccessor pa = PropertyAccessorFactory.GetPropertyAccessor(null);
parentSetter = pa.GetSetter(componentClass, parentProperty);
parentGetter = pa.GetGetter(componentClass, parentProperty);
}
this.propertyNames = propertyNames;
this.cascade = cascade;
this.joinedFetch = joinedFetch;
if (Environment.UseReflectionOptimizer)
{
// NH: reflection optimizer works with custom accessors
this.optimizer = Environment.BytecodeProvider.GetReflectionOptimizer(componentClass, getters, setters);
}
}
示例7: ReflectionOptimizer
/// <summary>
/// Class constructor.
/// </summary>
public ReflectionOptimizer(System.Type mappedType, IGetter[] getters, ISetter[] setters)
{
// save off references
this.mappedType = mappedType;
typeOfThis = mappedType.IsValueType ? mappedType.MakeByRefType() : mappedType;
//this.getters = getters;
//this.setters = setters;
GetPropertyValuesInvoker getInvoker = GenerateGetPropertyValuesMethod(getters);
SetPropertyValuesInvoker setInvoker = GenerateSetPropertyValuesMethod(getters, setters);
accessOptimizer = new AccessOptimizer(getInvoker, setInvoker, getters, setters);
createInstanceMethod = CreateCreateInstanceMethod(mappedType);
}
示例8: BuildProxyFactory
protected internal override IProxyFactory BuildProxyFactory(PersistentClass mappingInfo, IGetter idGetter,
ISetter idSetter)
{
IProxyFactory pf = new MapProxyFactory();
try
{
//TODO: design new lifecycle for ProxyFactory
pf.PostInstantiate(EntityName, null, null, null, null, null);
}
catch (HibernateException he)
{
log.Warn("could not create proxy factory for:" + EntityName, he);
pf = null;
}
return pf;
}
示例9: PropertyAction
/// <summary>
///
/// </summary>
/// <param name="property"></param>
/// <param name="getter"></param>
/// <param name="setter"></param>
public PropertyAction(PropertyInfo property, IGetter getter, ISetter setter)
{
if (property == null)
throw new PropertyAccessorException("The propertyInfo for the current PropertyAction cannot be null.");
if (getter == null && setter == null)
throw new PropertyAccessorException(string.Format("The current PropertyAction doesn't have no accessor, property name: {0} - declaring type: {1}", property.Name, property.DeclaringType == null ? string.Empty : property.DeclaringType.FullName));
if (getter != null && setter != null)
this.accessType = AccessType.ReadWrite;
else
this.accessType = getter != null ? AccessType.Read : AccessType.Write;
this.property = property;
this.getter = getter;
this.setter = setter;
}
示例10: ReflectionOptimizer
IReflectionOptimizer IBytecodeProvider.GetReflectionOptimizer( System.Type clazz, IGetter[] getters, ISetter[] setters )
{
return new ReflectionOptimizer( kernel, clazz, getters, setters );
}
示例11: BuildProxyFactoryInternal
protected virtual IProxyFactory BuildProxyFactoryInternal(PersistentClass @class, IGetter getter, ISetter setter)
{
return Cfg.Environment.BytecodeProvider.ProxyFactoryFactory.BuildProxyFactory();
}
示例12: BuildProxyFactory
protected override IProxyFactory BuildProxyFactory(PersistentClass persistentClass, IGetter idGetter,
ISetter idSetter)
{
bool needAccesorCheck = true; // NH specific (look the comment below)
// determine the id getter and setter methods from the proxy interface (if any)
// determine all interfaces needed by the resulting proxy
var proxyInterfaces = new HashedSet<System.Type> {typeof (INHibernateProxy)};
System.Type _mappedClass = persistentClass.MappedClass;
System.Type _proxyInterface = persistentClass.ProxyInterface;
if (_proxyInterface != null && !_mappedClass.Equals(_proxyInterface))
{
if (!_proxyInterface.IsInterface)
{
throw new MappingException("proxy must be either an interface, or the class itself: " + EntityName);
}
needAccesorCheck = false; // NH (the proxy is an interface all properties can be overridden)
proxyInterfaces.Add(_proxyInterface);
}
if (_mappedClass.IsInterface)
{
needAccesorCheck = false; // NH (the mapped class is an interface all properties can be overridden)
proxyInterfaces.Add(_mappedClass);
}
foreach (Subclass subclass in persistentClass.SubclassIterator)
{
System.Type subclassProxy = subclass.ProxyInterface;
System.Type subclassClass = subclass.MappedClass;
if (subclassProxy != null && !subclassClass.Equals(subclassProxy))
{
if (!subclassProxy.IsInterface)
{
throw new MappingException("proxy must be either an interface, or the class itself: " + subclass.EntityName);
}
proxyInterfaces.Add(subclassProxy);
}
}
/*
* NH Different Implementation (for Error logging):
* - Check if the logger is enabled
* - Don't need nothing to check if the mapped-class or proxy is an interface
*/
if (log.IsErrorEnabled && needAccesorCheck)
{
LogPropertyAccessorsErrors(persistentClass);
}
/**********************************************************/
MethodInfo idGetterMethod = idGetter == null ? null : idGetter.Method;
MethodInfo idSetterMethod = idSetter == null ? null : idSetter.Method;
MethodInfo proxyGetIdentifierMethod = idGetterMethod == null || _proxyInterface == null ? null :
ReflectHelper.TryGetMethod(_proxyInterface, idGetterMethod);
MethodInfo proxySetIdentifierMethod = idSetterMethod == null || _proxyInterface == null ? null :
ReflectHelper.TryGetMethod(_proxyInterface, idSetterMethod);
IProxyFactory pf = BuildProxyFactoryInternal(persistentClass, idGetter, idSetter);
try
{
pf.PostInstantiate(EntityName, _mappedClass, proxyInterfaces, proxyGetIdentifierMethod, proxySetIdentifierMethod,
persistentClass.HasEmbeddedIdentifier ? (IAbstractComponentType) persistentClass.Identifier.Type: null);
}
catch (HibernateException he)
{
log.Warn("could not create proxy factory for:" + EntityName, he);
pf = null;
}
return pf;
}
示例13: base
internal ReflectionOptimizer
(System.Type mappedType,
IGetter[] getters,
ISetter[] setters) : base(mappedType, getters, setters) { }
示例14: AutofacReflectionOptimizer
/// <summary>
/// Initializes a new instance of the <see cref="AutofacReflectionOptimizer"/> class.
/// </summary>
/// <param name="container">The container.</param>
/// <param name="mappedType">The type being mapped.</param>
/// <param name="getters">The getters.</param>
/// <param name="setters">The setters.</param>
public AutofacReflectionOptimizer(IComponentContext container, Type mappedType, IGetter[] getters, ISetter[] setters)
: base(mappedType, getters, setters)
{
_container = container;
}
示例15: EmitIL
private void EmitIL(AssemblyBuilder assemblyBuilder, ModuleBuilder moduleBuilder)
{
// Create a new type object for the the field accessor class.
EmitType(moduleBuilder);
// Create a new instance
_emittedSetter = assemblyBuilder.CreateInstance("SetFor" + _targetType.FullName + _fieldName) as ISetter;
this.nullInternal = this.GetNullInternal(_fieldType);
if (_emittedSetter == null)
{
throw new NotSupportedException(
string.Format("Unable to create a set field accessor for '{0}' field on class '{0}'.", _fieldName, _fieldType));
}
}