Esempio n. 1
0
        public void Dispose()
        {
            if (_securityDisabler != null)
            {
                _securityDisabler.Dispose();
                _securityDisabler = null;
            }

            if (_siteContextSwitcher != null)
            {
                _siteContextSwitcher.Dispose();
                _siteContextSwitcher = null;
            }

            if (_languageSwitcher != null)
            {
                _languageSwitcher.Dispose();
                _languageSwitcher = null;
            }

            if (_databaseSwitcher != null)
            {
                _databaseSwitcher.Dispose();
                _databaseSwitcher = null;
            }

            if (_userSwitcher != null)
            {
                _userSwitcher.Dispose();
                _userSwitcher = null;
            }
        }
 public void Dispose()
 {
     _tds.Dispose();
     _fd.Dispose();
     _ed.Dispose();
     _sd.Dispose();
 }
Esempio n. 3
0
        public static void SitecoreContentImport(DataTable table, string language, string displayName)
        {
            var _sourceLanguage = LanguageManager.GetLanguage(language);
            var _masterDb       = ScHelpers.GetDatabase(Constants.DatabaseNames.Master);

            foreach (DataRow row in table.Rows)
            {
                string text = row["ID"].ToString();
                if (string.IsNullOrEmpty(text))
                {
                    return;
                }
                Item item = _masterDb.GetItem(text, _sourceLanguage);
                if (item == null)
                {
                    return;
                }
                for (int i = 3; i < table.Columns.Count; i++)
                {
                    string fieldName = table.Columns[i].ColumnName;
                    Field  val       = item.Fields.Where(x => x.Name.Equals(fieldName)).FirstOrDefault();
                    if (val != null)
                    {
                        string value = row[val.Name].ToString();
                        using (SecurityDisabler val2 = new SecurityDisabler())
                        {
                            try
                            {
                                item.Editing.BeginEdit();
                                val.Value = value;
                                item.Editing.EndEdit();
                            }
                            finally
                            {
                                val2?.Dispose();
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(displayName) && displayName.ToLower().Equals("true"))
                    {
                        using (SecurityDisabler val3 = new SecurityDisabler())
                        {
                            try
                            {
                                item.Editing.BeginEdit();
                                item.Appearance.DisplayName = row["Name"].ToString();
                                item.Editing.EndEdit();
                            }
                            finally
                            {
                                val3?.Dispose();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _item.Editing.EndEdit();

            if (_securityDisabler != null)
            {
                _securityDisabler.Dispose();
            }

            _disposed = true;
        }
        public void TearDown()
        {
            var providers = GetProviders(_db);
            var toRemove  = providers.Where(x => x is GlassDataProvider).ToList();

            toRemove.ForEach(x => providers.Remove(x));

            var path       = "/sitecore/templates/glasstemplates";
            var rootFolder = _db.GetItem(path);

            if (rootFolder != null)
            {
                rootFolder.Delete();
            }
            _disabler.Dispose();

            _db           = null;
            _dataProvider = null;
            _disabler     = null;
        }