7#if FIRST_PASS == false && EXPORTER == false && IMPORTER == false
12 internal abstract partial class Accessor
15 readonly
string typeName;
16 readonly AccessorTypeResolver resolver;
25 public Accessor(AccessorTypeResolver resolver,
string typeName)
27 this.resolver = resolver ??
throw new ArgumentNullException(nameof(resolver));
28 this.typeName = typeName ??
throw new ArgumentNullException(nameof(typeName));
34 public Type Type => AccessorUtil.LazyGet(
ref type, () => Resolve(typeName));
41 protected Type Resolve(
string typeName) => typeName !=
null ? resolver(typeName) :
null;
49 protected Type Resolve(
ref Type type,
string typeName) => AccessorUtil.LazyGet(
ref type, () => Resolve(typeName));
56 public object[] InitArray(
int length) => (
object[])Array.CreateInstance(
Type, length);
63 public object[] InitArray(params
object[] source)
65 var a = InitArray(source.Length);
66 Array.Copy(source, a, source.Length);
75 internal abstract partial class Accessor<TObject> : Accessor
83 public Accessor(AccessorTypeResolver resolver,
string typeName) :
84 base(resolver, typeName)
95 protected FieldAccessor<TField> GetField<TField>(
ref FieldAccessor<TField> accessor,
string name) => FieldAccessor<TField>.LazyGet(
ref accessor,
Type, name);
103 protected FieldAccessor<TObject, TField> GetField<TField>(
ref FieldAccessor<TObject, TField> accessor,
string name) => FieldAccessor<TObject, TField>.LazyGet(
ref accessor,
Type, name);
111 protected PropertyAccessor<TField> GetProperty<TField>(
ref PropertyAccessor<TField> accessor,
string name) => PropertyAccessor<TField>.LazyGet(
ref accessor,
Type, name);
119 protected PropertyAccessor<TObject, TField> GetProperty<TField>(
ref PropertyAccessor<TObject, TField> accessor,
string name) => PropertyAccessor<TObject, TField>.LazyGet(
ref accessor,
Type, name);
127 protected MethodAccessor<TDelegate> GetConstructor<TDelegate>(
ref MethodAccessor<TDelegate> accessor, params
Type[] parameterTypes) where TDelegate : Delegate => MethodAccessor<TDelegate>.LazyGet(
ref accessor,
Type,
".ctor", typeof(
void), parameterTypes);
136 protected MethodAccessor<TDelegate> GetMethod<TDelegate>(
ref MethodAccessor<TDelegate> accessor,
string name,
Type returnType, params
Type[] parameterTypes) where TDelegate : Delegate => MethodAccessor<TDelegate>.LazyGet(
ref accessor,
Type, name, returnType, parameterTypes);