示例#1
0
 private Boxed CreateValue()
 {
     try
     {
         return(valueFactory != null
             ? new Boxed(valueFactory())
             : new Boxed(default(T)));
     }
     catch (Exception ex)
     {
         boxed = new UnLazyInternalExceptionHolder(ex);
         throw;
     }
 }
示例#2
0
        private T LazyInitValue()
        {
            Boxed boxed = null;

            lock (syncRoot)
            {
                if (this.boxed == null)
                {
                    boxed      = CreateValue();
                    this.boxed = boxed;
                }
                else
                {
                    boxed = this.boxed as Boxed;
                    if (boxed == null)
                    {
                        UnLazyInternalExceptionHolder holder = this.boxed as UnLazyInternalExceptionHolder;
                        holder.edi.Throw();
                    }
                }
            }
            return(boxed.value);
        }