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);
                }
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
 static Tree()
 {
     DataEventSystemFacade.SubscribeToDataDeleted <IPageStructure>(OnPageStructureDeleted, true);
     DataEventSystemFacade.SubscribeToDataAfterUpdate <IMediaFileFolder>(OnMediaFolderChanged, true);
 }
Пример #4
0
 /// <exclude />
 static TemplateInfo()
 {
     DataEventSystemFacade.SubscribeToDataAfterUpdate <IXmlPageTemplate>(PageTemplate_Changed, true);
     DataEventSystemFacade.SubscribeToDataDeleted <IXmlPageTemplate>(PageTemplate_Changed, true);
     DataEventSystemFacade.SubscribeToStoreChanged <IXmlPageTemplate>(PageTemplate_StoreChanged, true);
 }
        private static void AddNewType(Type interfaceType)
        {
            List <DataAssociationAttribute> attributes = interfaceType.GetCustomAttributesRecursively <DataAssociationAttribute>().ToList();

            if (attributes.Count == 0)
            {
                return;
            }

            var dataAssociationInfos = new Dictionary <Type, DataAssociationInfo>();

            foreach (DataAssociationAttribute attribute in attributes)
            {
                if (attribute.AssociationType == DataAssociationType.None)
                {
                    throw new ArgumentException(string.Format("The associationType on the attribute '{0}' on the interface type '{1}' may not be '{2}'", typeof(DataAssociationAttribute), interfaceType, DataAssociationType.None));
                }
                if (attribute.AssociatedInterfaceType == null)
                {
                    throw new ArgumentNullException(string.Format("The associatedInterfaceType on the attribute '{0}' on the interface type '{1}' is null", typeof(DataAssociationAttribute), interfaceType));
                }

                List <Type> associatedTypes;

                Type associatedInterface = attribute.AssociatedInterfaceType;

                if (_associatedTypes.TryGetValue(associatedInterface, out associatedTypes) == false)
                {
                    associatedTypes = new List <Type>();

                    _associatedTypes.Add(associatedInterface, associatedTypes);

                    DataEventSystemFacade.SubscribeToDataAfterUpdate(associatedInterface, OnAfterDataUpdated, false);
                }

                associatedTypes.Add(interfaceType);


                PropertyInfo propertyInfo =
                    (from pi in interfaceType.GetAllProperties()
                     where pi.Name == attribute.ForeignKeyPropertyName
                     select pi).FirstOrDefault();

                if (propertyInfo == null)
                {
                    throw new ArgumentException(string.Format("The foreign key property name '{0}' set on the attribute '{1}' does not exist on the interface '{2}'", attribute.ForeignKeyPropertyName, typeof(DataAssociationAttribute), interfaceType));
                }



                var dataAssociationInfo = new DataAssociationInfo
                {
                    AssociatedInterfaceType = associatedInterface,
                    ForeignKeyPropertyName  = attribute.ForeignKeyPropertyName,
                    ForeignKeyPropertyInfo  = propertyInfo,
                    AssociationType         = attribute.AssociationType,
                };

                Verify.IsFalse(dataAssociationInfos.ContainsKey(associatedInterface), "Failed to register interface '{0}'. Data association already exist, type: '{1}'".FormatWith(interfaceType, associatedInterface));
                dataAssociationInfos.Add(associatedInterface, dataAssociationInfo);

                if (!DataProviderRegistry.AllInterfaces.Contains(associatedInterface))
                {
                    Log.LogCritical("DataReferenceRegistry", string.Format("The one type '{0}' is associated to the non supported data type '{1}'", interfaceType, associatedInterface));
                }
            }

            _dataAssociations.Add(interfaceType, dataAssociationInfos);
        }