/// <summary> /// Fügt einem Feld den Contract Aspekt hinzu. /// </summary> /// <param name="contractList">Liste mit den übergebenen Kontrakten.</param> /// <param name="aspectCollection">Collection mit allen Membern denen der Aspekt zugewiesen wurde.</param> /// <param name="method">FieldInfo Objekt des Feldes an dem der Kontrakt definiert wurde.</param> private void AddAspectToField(List<string> contractList, LaosReflectionAspectCollection aspectCollection, FieldInfo field) { // Klassennamen erzeugen string contractClassName = AspectController.Instance.CreateContractClassName(field.DeclaringType.Assembly); FieldModel fieldModel = null; // Kontraktmodell erzeugen: string getContract = string.Empty; string setContract = string.Empty; if (contractList.Count == 2) { getContract = contractList[0]; setContract = contractList[1]; } else if (contractList.Count == 1) { getContract = contractList[0]; setContract = contractList[0]; } switch (DbcAccessType) { case AccessType.OnlyOnGet: fieldModel = new FieldModel(getContract, string.Empty, field, DbcAccessType, DbcCheckTime, contractClassName, DbcExceptionType, DbcExceptionString); break; case AccessType.OnlyOnSet: fieldModel = new FieldModel(string.Empty, setContract, field, DbcAccessType, DbcCheckTime, contractClassName, DbcExceptionType, DbcExceptionString); break; default: fieldModel = new FieldModel(getContract, setContract, field, DbcAccessType, DbcCheckTime, contractClassName, DbcExceptionType, DbcExceptionString); break; } aspectCollection.AddAspect(field, new FieldAccessAspect(fieldModel)); }
/// <summary> /// Konsturktor /// </summary> /// <param name="contactModel">Kontraktinformationen für die Methode</param> internal FieldAccessAspect(FieldModel fieldModel) { mFieldModel = fieldModel; }