Exemplo n.º 1
0
        public void Dispose()
        {
            if (_orgServiceCreate)
            {
                var orgService          = ContextContainer.GetValue <IOrganizationService>(ContextTypes.OrgService);
                var orgServiceDiposable = orgService as IDisposable;

                if (orgServiceDiposable != null)
                {
                    using (orgServiceDiposable)
                    {
                    }
                }

                ContextContainer.SetValue <IOrganizationService>(ContextTypes.OrgService, null);
            }

            if (_dictionaryCreate)
            {
                var dict    = ContextContainer.GetValue <Dictionary <string, object> >(ContextTypes.Dictionary);
                var strDict = BinarySerializerHelper.Serializer <Dictionary <string, object> >(dict);
                _context.SharedVariables["dictionary"] = strDict;

                ContextContainer.SetValue <Dictionary <string, object> >(ContextTypes.Dictionary, null);
            }

            if (_currentUserCreate)
            {
                ContextContainer.SetValue <ICurrentUserInfoContext>(ContextTypes.CurrentUser, null);
            }

            if (_currentOrganizationCreate)
            {
                ContextContainer.SetValue <Guid>(ContextTypes.CurrentOrganization, Guid.Empty);
            }

            if (_orgServiceFactoryCreate)
            {
                ContextContainer.SetValue <IOrganizationServiceFactory>(ContextTypes.OrgServiceFactory, null);
            }

            if (_tracingServiceCreate)
            {
                ContextContainer.SetValue <IConfigurationService>(ContextTypes.TracingService, null);
            }
        }