private static void DoInitialize() { _processControllers = new Dictionary <Type, IProcessController>(); foreach (Type processControllerType in ProcessControllerRegistry.ProcessControllerTypes) { IProcessController processController = (IProcessController)Activator.CreateInstance(processControllerType); _processControllers.Add(processControllerType, processController); } if (!RuntimeInformation.IsUnittest) { foreach (Type dataType in DataFacade.GetAllInterfaces()) { Dictionary <Type, Type> processControllerTypes = ProcessControllerRegistry.GetProcessControllerTypes(dataType); foreach (var kvp in _controlledTypes) { if (kvp.Key.IsAssignableFrom(dataType)) { if (!processControllerTypes.ContainsKey(kvp.Value)) { throw new InvalidOperationException(string.Format("The data type {0} is inheriting the interface {1} but has not been assigned a {2} process controller", dataType, kvp.Key, kvp.Value)); } } } } } DataEventSystemFacade.SubscribeToDataAfterUpdate <IProcessControlled>(OnAfterDataUpdated, false); DataEventSystemFacade.SubscribeToDataAfterBuildNew <IProcessControlled>(OnDataBuildNew, false); }
public static void OnInitialized() { DataEventSystemFacade.SubscribeToDataBeforeUpdate <NewsItem>(NewsFacade.SetTitleUrl, true); DataEventSystemFacade.SubscribeToDataBeforeAdd <NewsItem>(NewsFacade.SetTitleUrl, true); DataUrls.RegisterGlobalDataUrlMapper <NewsItem>(new NewsDataUrlMapper()); }
private void UnsubscribeFromEvents(IEnumerable <CacheDependentEntry> dependentEntities) { foreach (var dependentEntry in dependentEntities) { if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Add)) { DataEventSystemFacade.UnsubscribeToDataAfterAdd(dependentEntry.EntityType, ResetCache); } if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Update)) { DataEventSystemFacade.UnsubscribeToDataAfterUpdate(dependentEntry.EntityType, ResetCache); } if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Deleted)) { DataEventSystemFacade.UnsubscribeToDataDeleted(dependentEntry.EntityType, ResetCache); } if (dependentEntry.Operations > 0) { DataEventSystemFacade.UnsubscribeToStoreChanged(dependentEntry.EntityType, ResetCacheOnUnhandledChange); } } }
public XmlDataTypeStore(DataTypeDescriptor dataTypeDescriptor, Type dataProviderHelperType, Type dataIdClassType, IEnumerable <XmlDataTypeStoreDataScope> xmlDateTypeStoreDataScopes, bool isGeneratedDataType) { DataTypeDescriptor = dataTypeDescriptor ?? throw new ArgumentNullException(nameof(dataTypeDescriptor)); DataProviderHelperType = dataProviderHelperType ?? throw new ArgumentNullException(nameof(dataProviderHelperType)); DataIdClassType = dataIdClassType ?? throw new ArgumentNullException(nameof(dataIdClassType)); IsGeneratedDataType = isGeneratedDataType; _xmlDateTypeStoreDataScopes = xmlDateTypeStoreDataScopes.Evaluate(); var ordering = new List <Func <XElement, IComparable> >(); foreach (string key in dataTypeDescriptor.KeyPropertyNames) { XName localKey = key; ordering.Add(f => (string)f.Attribute(localKey) ?? ""); } Func <IEnumerable <XElement>, IOrderedEnumerable <XElement> > orderer = f => ordering.Skip(1).Aggregate(f.OrderBy(ordering.First()), Enumerable.ThenBy); foreach (XmlDataTypeStoreDataScope xmlDataTypeStoreDataScope in _xmlDateTypeStoreDataScopes) { DataScopeIdentifier dataScopeIdentifier = DataScopeIdentifier.Deserialize(xmlDataTypeStoreDataScope.DataScopeName); CultureInfo culture = CultureInfo.CreateSpecificCulture(xmlDataTypeStoreDataScope.CultureName); Type dataType = dataTypeDescriptor.GetInterfaceType(); Action cacheFlush = () => DataEventSystemFacade.FireExternalStoreChangedEvent(dataType, dataScopeIdentifier.ToPublicationScope(), culture); XmlDataProviderDocumentCache.RegisterExternalFileChangeAction(xmlDataTypeStoreDataScope.Filename, cacheFlush); XmlDataProviderDocumentWriter.RegisterFileOrderer(xmlDataTypeStoreDataScope.Filename, orderer); } }
private static void SubscribeToEvents() { DataEventSystemFacade.SubscribeToDataAfterUpdate <IUserPermissionDefinition>(OnUserPermissionChanged, true); DataEventSystemFacade.SubscribeToDataAfterAdd <IUserPermissionDefinition>(OnUserPermissionChanged, true); DataEventSystemFacade.SubscribeToDataDeleted <IUserPermissionDefinition>(OnUserPermissionChanged, true); DataEventSystemFacade.SubscribeToStoreChanged <IUserPermissionDefinition>(OnUserPermissionStoreChanged, true); }
static UserSettingsImpl() { DataEventSystemFacade.SubscribeToDataAfterAdd <IUserSettings>(OnUserSettingsChanged, true); DataEventSystemFacade.SubscribeToDataAfterUpdate <IUserSettings>(OnUserSettingsChanged, true); DataEventSystemFacade.SubscribeToDataDeleted <IUserSettings>(OnUserSettingsChanged, true); DataEventSystemFacade.SubscribeToStoreChanged <IUserSettings>(OnUserStoreChanged, true); }
public TransformCache() { DataEventSystemFacade.SubscribeToDataAfterAdd <IMediaFile>(OnDataChanged, true); // DataEventSystemFacade.SubscribeToDataAfterMove<IMediaFile>(OnDataChanged); DataEventSystemFacade.SubscribeToDataBeforeUpdate <IMediaFile>(OnDataChanged, true); DataEventSystemFacade.SubscribeToDataDeleted <IMediaFile>(OnDataChanged, true); }
static DataBasedUserGroupPermissionDefinitionProvider() { DataEventSystemFacade.SubscribeToDataAfterUpdate <IUserGroupPermissionDefinition>(OnUserGroupPermissionChanged, true); DataEventSystemFacade.SubscribeToDataAfterAdd <IUserGroupPermissionDefinition>(OnUserGroupPermissionChanged, true); DataEventSystemFacade.SubscribeToDataDeleted <IUserGroupPermissionDefinition>(OnUserGroupPermissionChanged, true); DataEventSystemFacade.SubscribeToStoreChanged <IUserGroupPermissionDefinition>(OnUserGroupPermissionStoreChanged, true); }
static HostnameBindingsFacade() { DataEventSystemFacade.SubscribeToDataBeforeAdd <IUrlConfiguration>(OnBeforeUpdatingHostnameConfiguration, true); DataEventSystemFacade.SubscribeToDataBeforeUpdate <IUrlConfiguration>(OnBeforeUpdatingHostnameConfiguration, true); DataEventSystemFacade.SubscribeToDataBeforeAdd <IHostnameBinding>(OnBeforeUpdatingHostnameBinding, true); DataEventSystemFacade.SubscribeToDataBeforeUpdate <IHostnameBinding>(OnBeforeUpdatingHostnameBinding, true); }
static PageStructureInfo() { DataEventSystemFacade.SubscribeToStoreChanged<IPage>(OnPagesChanged, true); DataEventSystemFacade.SubscribeToStoreChanged<IPageStructure>(OnPageStructureChanged, true); DataEventSystemFacade.SubscribeToStoreChanged<ISystemActiveLocale>((a, b) => ClearCachedData(), true); DataEventSystemFacade.SubscribeToStoreChanged<IHostnameBinding>((a, b) => ClearCachedData(), true); DataEventSystemFacade.SubscribeToStoreChanged<IUrlConfiguration>((a, b) => ClearCachedData(), true); }
public QueryCache(string name, Expression <Func <TDataType, TPropertyType> > propertyGetter, int size) { _innerCache = new Cache <string, ExtendedNullable <TDataType> >(name, size); _propertyGetter = propertyGetter; DataEventSystemFacade.SubscribeToDataAfterAdd <TDataType>(OnDataChanged, true); DataEventSystemFacade.SubscribeToDataAfterUpdate <TDataType>(OnDataChanged, true); DataEventSystemFacade.SubscribeToDataDeleted <TDataType>(OnDataChanged, true); _typeIsLocalizable = DataLocalizationFacade.IsLocalized(typeof(TDataType)); }
public static void OnInitialized() { DataEventSystemFacade.SubscribeToDataBeforeUpdate <Entries>(BlogFacade.SetTitleUrl, true); DataEventSystemFacade.SubscribeToDataBeforeAdd <Entries>(BlogFacade.SetTitleUrl, true); DataEventSystemFacade.SubscribeToDataAfterAdd <Entries>(BlogFacade.ClearRssFeedCache, true); DataEventSystemFacade.SubscribeToDataAfterUpdate <Entries>(BlogFacade.ClearRssFeedCache, true); DataEventSystemFacade.SubscribeToDataDeleted <Entries>(BlogFacade.ClearRssFeedCache, true); DataUrls.RegisterGlobalDataUrlMapper <Entries>(new BlogEntryDataUrlMapper()); UrlToEntityTokenFacade.Register(new BlogUrlToEntityTokenMapper()); }
public DataHookMapper(EntityToken parentEntityToken) { if (parentEntityToken == null) { throw new ArgumentNullException("parentEntityToken"); } DataEventSystemFacade.SubscribeToDataAfterAdd <T>(OnDataAddedOrDeleted, false); DataEventSystemFacade.SubscribeToDataDeleted <T>(OnDataAddedOrDeleted, false); DataEventSystemFacade.SubscribeToStoreChanged <T>(OnStoreChanged, false); this.ParentEntityToken = parentEntityToken; }
public void Start() { DataEventSystemFacade.SubscribeToDataAfterAdd(_interfaceType, (sender, args) => CatchAll(() => GetActionContainer().Add(() => Data_OnAfterAdd(sender, args))), true); DataEventSystemFacade.SubscribeToDataAfterUpdate(_interfaceType, (sender, args) => CatchAll(() => GetActionContainer().Add(() => Data_OnAfterUpdate(sender, args))), true); DataEventSystemFacade.SubscribeToDataDeleted(_interfaceType, (sender, args) => CatchAll(() => GetActionContainer().Add(() => Data_OnDeleted(sender, args))), true); }
private static void EnsureSubscribtion(Type type) { if (!_subscribedTo.Contains(type)) { lock (_subscribedTo) { if (!_subscribedTo.Contains(type)) { _subscribedTo.Add(type); DataEventSystemFacade.SubscribeToStoreChanged(type, (sender, storeEventArgs) => IncreaseTableVersion(type, DataScopeIdentifier.FromPublicationScope(storeEventArgs.PublicationScope), storeEventArgs.Locale), false); } } } }
private static void SubscribeToDataEvents() { DataEvents <IPage> .OnAfterAdd += SitemapUpdateAfterPageChanged; DataEvents <IPage> .OnDeleted += SitemapUpdateAfterPageChanged; foreach (var typeFullName in _dataTypesToIncludeFromConfig) { var type = Type.GetType(typeFullName); if (type == null) { continue; } DataEventSystemFacade.SubscribeToDataAfterAdd(type, SitemapUpdateAfterPageChanged, true); DataEventSystemFacade.SubscribeToDataDeleted(type, SitemapUpdateAfterPageChanged, true); } }
internal MediaFileProvider(string rootDirectory, string storeId, string storeDescription, string storeTitle) { _workingDirectory = PathUtil.Resolve(rootDirectory); if (!C1Directory.Exists(_workingDirectory)) { C1Directory.CreateDirectory(_workingDirectory); } _storeId = storeId; _storeTitle = storeTitle; _storeDescription = storeDescription; DataEventSystemFacade.SubscribeToStoreChanged <IMediaFileData>(ClearQueryCache, false); DataEventSystemFacade.SubscribeToStoreChanged <IMediaFolderData>(ClearQueryCache, false); _mediaUrlProvider = new DefaultMediaUrlProvider(storeId); MediaUrls.RegisterMediaUrlProvider(storeId, _mediaUrlProvider); }
private ChangeEventsSingleton() { DataEventSystemFacade.SubscribeToStoreChanged <IMethodBasedFunctionInfo>(OnDataChanged, true); DataEventSystemFacade.SubscribeToDataDeleted <IInlineFunction>(OnDataChanged, true); DataEventSystemFacade.SubscribeToStoreChanged <IInlineFunction>(OnStoreChanged, true); string folderToWatch = PathUtil.Resolve(GlobalSettingsFacade.InlineCSharpFunctionDirectory); DirectoryUtils.EnsureDirectoryExists(folderToWatch); _codeDirectoryFileSystemWatcher = new C1FileSystemWatcher(folderToWatch) { NotifyFilter = NotifyFilters.LastWrite, EnableRaisingEvents = true, IncludeSubdirectories = true }; _codeDirectoryFileSystemWatcher.Changed += OnFileWatcherEvent; }
private void SubscribeToEvents(IEnumerable <CacheDependentEntry> dependentEntities) { foreach (var dependentEntry in dependentEntities) { if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Add)) { DataEventSystemFacade.SubscribeToDataAfterAdd(dependentEntry.EntityType, ResetCache, true); } if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Update)) { DataEventSystemFacade.SubscribeToDataAfterUpdate(dependentEntry.EntityType, ResetCache, true); } if (dependentEntry.Operations.HasFlag(CacheDependentOperations.Deleted)) { DataEventSystemFacade.SubscribeToDataDeleted(dependentEntry.EntityType, ResetCache, true); } } }
/// <exclude /> public override void Initialize(string name, NameValueCollection attributes) { StoreEventHandler handler = (sender, e) => SiteMapContainer.ClearCache(); DataEventSystemFacade.SubscribeToStoreChanged <IPage>(handler, true); DataEventSystemFacade.SubscribeToStoreChanged <IPageStructure>(handler, true); DataEventSystemFacade.SubscribeToStoreChanged <ISystemActiveLocale>(handler, true); if (attributes != null) { bool extranetEnabled; if (bool.TryParse(attributes["extranetEnabled"], out extranetEnabled)) { ExtranetEnabled = extranetEnabled; } attributes.Remove("extranetEnabled"); } base.Initialize(name, attributes); }
public void Initialize() { using (_resourceLocker.Locker) { if (!GlobalInitializerFacade.IsReinitializingTheSystem) { DataEventSystemFacade.SubscribeToDataAfterAdd <IDataItemTreeAttachmentPoint>(OnUpdateTreeAttachmentPoints, true); DataEventSystemFacade.SubscribeToDataDeleted <IDataItemTreeAttachmentPoint>(OnUpdateTreeAttachmentPoints, true); DataEventSystemFacade.SubscribeToStoreChanged <IDataItemTreeAttachmentPoint>(OnTreeAttachmentPointsStoreChange, true); GeneratedTypesFacade.SubscribeToUpdateTypeEvent(OnDataTypeChanged); var treeAuxiliaryAncestorProvider = new C1Console.Trees.TreeAuxiliaryAncestorProvider(); AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <TreeSimpleElementEntityToken>(treeAuxiliaryAncestorProvider, true); AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <TreeFunctionElementGeneratorEntityToken>(treeAuxiliaryAncestorProvider, true); AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <TreeDataFieldGroupingElementEntityToken>(treeAuxiliaryAncestorProvider, true); AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <DataEntityToken>(treeAuxiliaryAncestorProvider, true); AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <TreePerspectiveEntityToken>(treeAuxiliaryAncestorProvider, true); _resourceLocker.Resources.PersistentAttachmentPoints = new Dictionary <string, List <IAttachmentPoint> >(); LoadAllTrees(); InitializeTreeAttachmentPoints(); TreeSharedRootsFacade.Clear(); var fileWatcher = new C1FileSystemWatcher(TreeDefinitionsFolder, "*.xml"); fileWatcher.Created += OnReloadTrees; fileWatcher.Deleted += OnReloadTrees; fileWatcher.Changed += OnReloadTrees; fileWatcher.Renamed += OnReloadTrees; fileWatcher.EnableRaisingEvents = true; _resourceLocker.Resources.FileSystemWatcher = fileWatcher; _resourceLocker.Resources.RootEntityToken = ElementFacade.GetRootsWithNoSecurity().First().ElementHandle.EntityToken; } } }
public static void Initialize() { ServiceBusListener.Register(new CommonEventMessageProcessor() { EventName = "ProductUpdatedEvent", Action = SitemapGeneratorScheduler.RegenerateSitemapJob }); ServiceBusListener.Start(); DataEvents <IPage> .OnAfterAdd += new DataEventHandler(SitemapUpdateAfterPageChanged); DataEvents <IPage> .OnDeleted += new DataEventHandler(SitemapUpdateAfterPageChanged); foreach (var typeFullName in _dataTypesToIncludeFromConfig) { var type = Type.GetType(typeFullName); if (type == null) { continue; } DataEventSystemFacade.SubscribeToDataAfterAdd(type, SitemapUpdateAfterPageChanged, true); DataEventSystemFacade.SubscribeToDataDeleted(type, SitemapUpdateAfterPageChanged, true); } }
public DataGroupingProviderHelper(ElementProviderContext elementProviderContext) { _elementProviderContext = elementProviderContext; _undefinedLabelValue = StringResourceSystemFacade.GetString("Composite.Plugins.GeneratedDataTypesElementProvider", "UndefinedLabelTemplate"); this.FolderOpenIcon = GetIconHandle("datagroupinghelper-folder-open"); this.FolderClosedIcon = GetIconHandle("datagroupinghelper-folder-closed"); this.OnCreateLeafElement = d => new Element(_elementProviderContext.CreateElementHandle(d.GetDataEntityToken())); this.OnGetDataScopeIdentifier = t => DataScopeIdentifier.Administrated; this.OnAddActions = (e, p) => e; AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <DataEntityToken>(this); AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <DataGroupingProviderHelperEntityToken>(this); DataEventSystemFacade.SubscribeToDataAfterUpdate(typeof(IData), (sender, args) => { if (!OnOwnsType(args.DataType)) { return; } var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(args.DataType); IEnumerable <DataFieldDescriptor> groupingDataFieldDescriptors = from dfd in dataTypeDescriptor.Fields where dfd.GroupByPriority != 0 orderby dfd.GroupByPriority select dfd; if (groupingDataFieldDescriptors.Any()) { EntityTokenCacheFacade.ClearCache(args.Data.GetDataEntityToken()); } }, false); }
/// <exclude /> public XsltBasedFunctionProvider() { DataEventSystemFacade.SubscribeToStoreChanged <IXsltFunction>(OnDataChanged, false); }
private void InitializeTreeAttachmentPoints() { lock (_reloadAttachmentPointsSyncRoot) { ClearAttachmentPoints <DynamicDataItemAttachmentPoint>(); IEnumerable <IDataItemTreeAttachmentPoint> attachmentPoints = DataFacade.GetData <IDataItemTreeAttachmentPoint>().Evaluate(); foreach (IDataItemTreeAttachmentPoint attachmentPoint in attachmentPoints) { Tree tree = GetTree(attachmentPoint.TreeId); if (tree == null) { string treePath = Path.Combine(TreeDefinitionsFolder, attachmentPoint.TreeId); if (!C1File.Exists(treePath)) // This ensures that invalid, but existing trees does not remove these attachment points { if (DataFacade.WillDeleteSucceed(attachmentPoint)) { Log.LogWarning("TreeFacade", "A data item attachment points is referring a non existing tree '{0}' and is deleted", attachmentPoint.TreeId); // Preventing events so this method won't call itself recursively DataFacade.Delete(attachmentPoint, true, CascadeDeleteType.Allow); } } continue; } Type interfaceType = TypeManager.GetType(attachmentPoint.InterfaceType); object keyValue = ValueTypeConverter.Convert(attachmentPoint.KeyValue, interfaceType.GetKeyProperties()[0].PropertyType); var position = (ElementAttachingProviderPosition)Enum.Parse(typeof(ElementAttachingProviderPosition), attachmentPoint.Position); var dataItemTreeAttachmentPoint = new DynamicDataItemAttachmentPoint { InterfaceType = interfaceType, KeyValue = keyValue, Position = position }; // Log.LogVerbose("TreeFacade", string.Format("Tree with id '{0}' is dynamically attached to the data type '{1}' with key value of '{2}'", attachmentPoint.TreeId, interfaceType, keyValue)); tree.AttachmentPoints.Add(dataItemTreeAttachmentPoint); DataEventSystemFacade.SubscribeToDataDeleted(interfaceType, OnDataItemDeleted, false); } using (_resourceLocker.ReadLocker) { foreach (var kvp in _resourceLocker.Resources.PersistentAttachmentPoints) { Tree tree = GetTree(kvp.Key); if (tree == null) { continue; } tree.AttachmentPoints.AddRange(kvp.Value); } } } }
static Tree() { DataEventSystemFacade.SubscribeToDataDeleted <IPageStructure>(OnPageStructureDeleted, true); DataEventSystemFacade.SubscribeToDataAfterUpdate <IMediaFileFolder>(OnMediaFolderChanged, true); }
public FavoriteFunctionsProvider() { DataEventSystemFacade.SubscribeToDataAfterAdd <IFavoriteFunction>(OnDataChanged, false); DataEventSystemFacade.SubscribeToDataDeleted <IFavoriteFunction>(OnDataChanged, false); }
static ManagedParameterProfiles() { DataEventSystemFacade.SubscribeToStoreChanged <IParameter>((a, b) => ClearParametersCache(), true); }
static UserGroupFacade() { DataEventSystemFacade.SubscribeToStoreChanged <IUser>(OnDataChanged, true); DataEventSystemFacade.SubscribeToStoreChanged <IUserGroup>(OnDataChanged, true); DataEventSystemFacade.SubscribeToStoreChanged <IUserUserGroupRelation>(OnDataChanged, true); }
public static void OnInitialized() { DataEventSystemFacade.SubscribeToDataBeforeAdd <ApiKey>(OnAddApiKey); }