| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for license information. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Linq; |
| | 7 | | using System.Text; |
| | 8 | | using System.Threading.Tasks; |
| | 9 | |
|
| | 10 | | namespace Microsoft.Azure.Batch |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Methods and properties that are inherited from the instantiating parent object. |
| | 14 | | /// </summary> |
| | 15 | | public interface IInheritedBehaviors |
| | 16 | | { |
| | 17 | | /// <summary> |
| | 18 | | /// This collection is initially populated by instantiation or by copying from the instantiating parent object ( |
| | 19 | | /// In this model, the collections are independent but the members are shared references. |
| | 20 | | /// Members of this collection alter or customize various behaviors of Azure Batch Service client objects. |
| | 21 | | /// These behaviors are generally inherited by any child class instances. |
| | 22 | | /// Modifications are applied in the order of the collection. |
| | 23 | | /// The last write wins. |
| | 24 | | /// </summary> |
| | 25 | | IList<BatchClientBehavior> CustomBehaviors { get; set; } |
| | 26 | | } |
| | 27 | |
|
| | 28 | | internal class InheritUtil |
| | 29 | | { |
| | 30 | | internal static void InheritClientBehaviorsAndSetPublicProperty(IInheritedBehaviors inheritingObject, IEnumerabl |
| | 31 | | { |
| | 32 | | // implement inheritance of behaviors |
| 7787 | 33 | | List<BatchClientBehavior> customBehaviors = new List<BatchClientBehavior>(); |
| | 34 | |
|
| | 35 | | // if there were any behaviors, pre-populate the collection (ie: inherit) |
| 7787 | 36 | | if (null != baseBehaviors) |
| | 37 | | { |
| 6759 | 38 | | customBehaviors.AddRange(baseBehaviors); |
| | 39 | | } |
| | 40 | |
|
| | 41 | | // set the public property |
| 7787 | 42 | | inheritingObject.CustomBehaviors = customBehaviors; |
| 7787 | 43 | | } |
| | 44 | | } |
| | 45 | | } |