//----------------------------------------------------------------------------- // // Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). // You may not use this file except in compliance with the License. // A copy of the License is located at // // http://aws.amazon.com/apache2.0 // // or in the "license" file accompanying this file. This file is distributed // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either // express or implied. See the License for the specific language governing // permissions and limitations under the License. // //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; namespace Amazon.XRay.Recorder.Core.Internal.Entities { /// /// Present the cause of fault and error in Segment and subsegment /// [Serializable] public class Cause { /// /// Initializes a new instance of the class. /// public Cause() { } /// /// List of /// private Lazy> _exceptions = new Lazy>(); /// /// Gets the working directory /// public string WorkingDirectory { get; private set; } /// /// Gets the paths /// public IList Paths { get; private set; } /// /// Gets a read-only copy of the list of exception to the cause /// public ReadOnlyCollection ExceptionDescriptors { get { return _exceptions.IsValueCreated ? _exceptions.Value.AsReadOnly() : null; } } /// /// Gets a value indicating whether any exception is added. /// /// /// true if exception has been added; otherwise, false. /// public bool IsExceptionAdded { get { return _exceptions.IsValueCreated && _exceptions.Value.Any(); } } /// /// Add list of to cause instance. /// /// List of . public void AddException(List exceptionDescriptors) { if (exceptionDescriptors != null) { WorkingDirectory = Directory.GetCurrentDirectory(); } _exceptions.Value.AddRange(exceptionDescriptors); } } }