PrepForRemoting() private method

private PrepForRemoting ( ) : Exception
return Exception
Beispiel #1
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(Environment.GetResourceString("Lazy_Value_RecursiveCallsToValue"));
                    }
                    Func <T> valueFactory = this.m_valueFactory;
                    if (mode != LazyThreadSafetyMode.PublicationOnly)
                    {
                        this.m_valueFactory = Lazy <T> .PUBLICATION_ONLY_OR_ALREADY_INITIALIZED;
                    }
                    result = new Lazy <T> .Boxed(valueFactory());

                    return(result);
                }
                catch (Exception arg_5B_0)
                {
                    Exception exception = arg_5B_0;
                    if (mode != LazyThreadSafetyMode.PublicationOnly)
                    {
                        this.m_boxed = new Lazy <T> .LazyInternalExceptionHolder(exception.PrepForRemoting());
                    }
                    throw;
                }
            }
            try
            {
                result = new Lazy <T> .Boxed((T)Activator.CreateInstance(typeof(T)));
            }
            catch (MissingMethodException)
            {
                Exception exception2 = new MissingMemberException(Environment.GetResourceString("Lazy_CreateValue_NoParameterlessCtorForT"));
                if (mode != LazyThreadSafetyMode.PublicationOnly)
                {
                    this.m_boxed = new Lazy <T> .LazyInternalExceptionHolder(exception2);
                }
                throw exception2;
            }
            return(result);
        }