PetCenter.Referencias.Inyeccion/Inyeccion/CicloVidaPorPeticion.cs
/// <summary>
/// Establece el valor de contexto.
/// </summary>
/// <param name="newValue"></param>
Establece el valor de contexto.
Establece el valor de contexto .
public override void SetValue(object newValue)
        {
            if (OperationContext.Current != null)
            {
                var containerExtension = OperationContext.Current.Extensions.Find<ContainerExtension>();
                if (containerExtension == null)
                {
                    containerExtension = new ContainerExtension()
                    {
                        Value = newValue
                    };
                    OperationContext.Current.Extensions.Add(containerExtension);
                }
            }
            else if (HttpContext.Current != null)
            {
                if (HttpContext.Current.Items[_key.ToString()] == null)
                    HttpContext.Current.Items[_key.ToString()] = newValue;
            }
            else
            {
                CallContext.SetData(_key.ToString(), newValue);
            }
        }
public override void SetValue ( object newValue ) { if ( OperationContext . Current != null ) { var containerExtension = OperationContext . Current . Extensions . Find < ContainerExtension > ( ) ; if ( containerExtension == null ) { containerExtension = new ContainerExtension ( ) { Value = newValue } ; OperationContext . Current . Extensions . Add ( containerExtension ) ; } } else if ( HttpContext . Current != null ) { if ( HttpContext . Current . Items [ _key . ToString ( ) ] == null ) HttpContext . Current . Items [ _key . ToString ( ) ] = newValue ; } else { CallContext . SetData ( _key . ToString ( ) , newValue ) ; } }
Establece el valor de contexto.
Establece el valor de contexto .
//WCF without HttpContext environment //HttpContext avaiable ( ASP.NET ..) //Not in WCF or ASP.NET Environment, UnitTesting, WinForms, WPF etc.
newValue
object
None