Пример #1
0
        public override string ToString()
        {
            if (!this.IsValueCreated)
            {
                return(Environment2.GetResourceString("Lazy_ToString_ValueNotCreated"));
            }
            T value = this.Value;

            return(value.ToString());
        }
Пример #2
0
 protected AggregateException(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     Exception[] array = info.GetValue("InnerExceptions", typeof(Exception[])) as Exception[];
     if (array == null)
     {
         throw new SerializationException(Environment2.GetResourceString("AggregateException_DeserializationFailure"));
     }
     this.m_innerExceptions = new ReadOnlyCollection <Exception>(array);
 }
Пример #3
0
 private static object GetObjectFromMode(LazyThreadSafetyMode mode)
 {
     if (mode == LazyThreadSafetyMode.ExecutionAndPublication)
     {
         return(new object());
     }
     if (mode == LazyThreadSafetyMode.PublicationOnly)
     {
         return(Lazy <T> .PUBLICATION_ONLY_OR_ALREADY_INITIALIZED);
     }
     if (mode != LazyThreadSafetyMode.None)
     {
         throw new ArgumentOutOfRangeException("mode", Environment2.GetResourceString("Lazy_ctor_ModeInvalid"));
     }
     return(null);
 }
Пример #4
0
 private AggregateException(string message, IList <Exception> innerExceptions) : base(message, (innerExceptions != null && innerExceptions.Count > 0) ? innerExceptions[0] : null)
 {
     if (innerExceptions == null)
     {
         throw new ArgumentNullException("innerExceptions");
     }
     Exception[] array = new Exception[innerExceptions.Count];
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = innerExceptions[i];
         if (array[i] == null)
         {
             throw new ArgumentException(Environment2.GetResourceString("AggregateException_ctor_InnerExceptionNull"));
         }
     }
     this.m_innerExceptions = new ReadOnlyCollection <Exception>(array);
 }
Пример #5
0
        public override string ToString()
        {
            string text = base.ToString();

            for (int i = 0; i < this.m_innerExceptions.Count; i++)
            {
                text = string.Format(CultureInfo.InvariantCulture, Environment2.GetResourceString("AggregateException_ToString"), new object[]
                {
                    text,
                    Environment.NewLine,
                    i,
                    this.m_innerExceptions[i].ToString(),
                    "<---",
                    Environment.NewLine
                });
            }
            return(text);
        }
Пример #6
0
        private Lazy <T> .Boxed CreateValue()
        {
            Lazy <T> .Boxed      result = null;
            LazyThreadSafetyMode mode   = this.Mode;

            if (this.m_valueFactory != null)
            {
                try
                {
                    if (mode != LazyThreadSafetyMode.PublicationOnly && this.m_valueFactory == Lazy <T> .PUBLICATION_ONLY_OR_ALREADY_INITIALIZED)
                    {
                        throw new InvalidOperationException(Environment2.GetResourceString("Lazy_Value_RecursiveCallsToValue"));
                    }
                    Func <T> valueFactory = this.m_valueFactory;
                    if (mode != LazyThreadSafetyMode.PublicationOnly)
                    {
                        this.m_valueFactory = Lazy <T> .PUBLICATION_ONLY_OR_ALREADY_INITIALIZED;
                    }
                    return(new Lazy <T> .Boxed(valueFactory()));
                }
                catch (Exception ex)
                {
                    if (mode != LazyThreadSafetyMode.PublicationOnly)
                    {
                        this.m_boxed = new Lazy <T> .LazyInternalExceptionHolder(ex);
                    }
                    throw;
                }
            }
            try
            {
                result = new Lazy <T> .Boxed((T)((object)Activator.CreateInstance(typeof(T))));
            }
            catch (MissingMethodException)
            {
                Exception ex2 = new MissingMemberException(Environment2.GetResourceString("Lazy_CreateValue_NoParameterlessCtorForT"));
                if (mode != LazyThreadSafetyMode.PublicationOnly)
                {
                    this.m_boxed = new Lazy <T> .LazyInternalExceptionHolder(ex2);
                }
                throw ex2;
            }
            return(result);
        }
Пример #7
0
 public OperationCanceledException2() : base(Environment2.GetResourceString("OperationCanceled"))
 {
 }
Пример #8
0
 public AggregateException(params Exception[] innerExceptions) : this(Environment2.GetResourceString("AggregateException_ctor_DefaultMessage"), innerExceptions)
 {
 }
Пример #9
0
 public AggregateException(IEnumerable <Exception> innerExceptions) : this(Environment2.GetResourceString("AggregateException_ctor_DefaultMessage"), innerExceptions)
 {
 }
Пример #10
0
 public AggregateException() : base(Environment2.GetResourceString("AggregateException_ctor_DefaultMessage"))
 {
     this.m_innerExceptions = new ReadOnlyCollection <Exception>(new Exception[0]);
 }