Example #1
0
        public UiContext Register(Guid contextGuid)
        {
            var result = _contextManager.Value.GetUiContextCookie(contextGuid, out var cookie);

            if (result < 0)
            {
                return(DummyContext);
            }
            lock (this)
            {
                var registeredContext = _registeredContexts[(int)cookie];
                if (registeredContext != DependencyProperty.UnsetValue)
                {
                    return((UiContext)registeredContext);
                }

                if (_eventCookie == 0)
                {
                    //var instance = ExecutionContextTrackerHelper.Instance;
                    //var contextElementGuid = instance?.SetAndGetContextElement(new Guid("{C64A39C6-DA78-4B8F-AFDF-EA3FE13E9389}"), Guid.Empty) ?? Guid.Empty;
                    try
                    {
                        _contextManager.Value.AdviseContextEvents(this, out _eventCookie);
                    }
                    finally
                    {
                        //instance?.SetContextElement(new Guid("{C64A39C6-DA78-4B8F-AFDF-EA3FE13E9389}"), contextElementGuid);
                    }
                }

                _contextManager.Value.IsUiContextActive(cookie, out var active);
                var uiContext = new UiContext(contextGuid, cookie, active);
                _registeredContexts[(int)cookie] = uiContext;
                return(uiContext);
            }
        }
Example #2
0
 public void SetContext(UiContext context)
 {
     _contextManager.Value.SetUiContext(context.Cookie, context.IsActive);
 }