protected internal override void Invalidate(VFXModel model, InvalidationCause cause) { if (cause == InvalidationCause.kSettingChanged) { var graph = GetGraph(); if (graph != null && subgraph != null && m_Subgraph.GetResource() != null) { var otherGraph = m_Subgraph.GetResource().GetOrCreateGraph(); if (otherGraph == graph || otherGraph.subgraphDependencies.Contains(graph.GetResource().visualEffectObject)) { m_Subgraph = null; // prevent cyclic dependencies. } if (otherGraph != m_UsedSubgraph) { RecreateCopy(); } if (graph.GetResource().isSubgraph) // BuildSubgraphDependencies is called for vfx by recompilation, but in subgraph we must call it explicitely { graph.BuildSubgraphDependencies(); } } else if (m_UsedSubgraph != null) { RecreateCopy(); } } base.Invalidate(model, cause); }
/// <summary> /// Invalidate any relationships eminating from the from or to type of a /// relationship with the securesFrom or securesTo flags set, respectively. /// </summary> /// <param name="entities"> /// The entities being saved or deleted. /// </param> /// <param name="cause"> /// Whether the operation is a save or delete. /// </param> /// <param name="preActionModifiedRelatedEntities"> /// A map of entity ID to any changes. This may be null. Entities that appear in /// <paramref name="entities"/> may lack a corresponding entry. Similarly, there /// may be additional entities /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="entities"/> may be null. /// </exception> public override void OnEntityChange(IList <IEntity> entities, InvalidationCause cause, Func <long, EntityChanges> preActionModifiedRelatedEntities) { Relationship relationship; EntityType fromType; EntityType toType; base.OnEntityChange(entities, cause, preActionModifiedRelatedEntities); // There should be no need to be recursive since all relationships involved // in a security check are added. Similarly, this invalidates relationships // without the appropriate flag but these will not be cached, anyway. foreach (IEntity entity in entities) { relationship = entity.As <Relationship>(); if (relationship != null) { fromType = relationship.FromType; toType = relationship.ToType; if ((relationship.SecuresFrom ?? false) && fromType != null) { IEnumerable <long> fromTypeRelationships = fromType.Relationships.Concat(fromType.ReverseRelationships).Select(e => e.Id); InvalidateRelationshipTypes(fromTypeRelationships); } if ((relationship.SecuresTo ?? false) && toType != null) { IEnumerable <long> toTypeRelationships = toType.Relationships.Concat(toType.ReverseRelationships).Select(e => e.Id); InvalidateRelationshipTypes(toTypeRelationships); } } } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { if (cause == InvalidationCause.kSettingChanged || cause == InvalidationCause.kExpressionInvalidated) { if (cause == InvalidationCause.kSettingChanged) { if (m_Subgraph != null) { var graph = GetGraph(); if (graph != null) // that case it will be checked in OnAdded { var otherGraph = m_Subgraph.GetResource().GetOrCreateGraph(); if (otherGraph == graph || otherGraph.subgraphDependencies.Contains(graph.GetResource().visualEffectObject)) { m_Subgraph = null; // prevent cyclic dependencies. } } } if (m_Subgraph != null || object.ReferenceEquals(m_Subgraph, null) || m_UsedSubgraph == null || m_UsedSubgraph != m_Subgraph.GetResource().GetOrCreateGraph()) // do not recreate subchildren if the subgraph is not available but is not null { RecreateCopy(); } } base.OnInvalidate(model, cause); PatchInputExpressions(); } else { base.OnInvalidate(model, cause); } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { var outputSlotSpaceable = outputSlots.Where(o => o.spaceable); bool needUpdateInputSpaceable = false; foreach (var output in outputSlotSpaceable) { var currentSpaceForSlot = GetOutputSpaceFromSlot(output); if (currentSpaceForSlot != output.space) { output.space = currentSpaceForSlot; needUpdateInputSpaceable = true; } } //If one of output slot has changed its space, expression tree for inputs, //and more generally, current operation expression graph is invalid. //=> Trigger invalidation on input is enough to recompute the graph from this operator if (needUpdateInputSpaceable) { var inputSlotSpaceable = inputSlots.Where(o => o.spaceable); foreach (var input in inputSlotSpaceable) { input.Invalidate(InvalidationCause.kSpaceChanged); } } if (cause == InvalidationCause.kConnectionChanged) { ResyncSlots(true); } base.OnInvalidate(model, cause); }
protected override sealed void OnInvalidate(VFXModel model, InvalidationCause cause) { if (cause == InvalidationCause.kConnectionChanged || cause == InvalidationCause.kSpaceChanged) { if (IsMasterSlot() && direction == Direction.kInput && spaceable && HasLink()) { var linkedSlot = m_LinkedSlots.First(); if (linkedSlot.spaceable && linkedSlot.space != (VFXCoordinateSpace)int.MaxValue) { space = linkedSlot.space; } } } //Propagate space change to children if (cause == InvalidationCause.kSpaceChanged) { if (IsMasterSlot()) { InvalidateExpressionTree(); } if (direction == Direction.kOutput) { PropagateToChildren(s => { foreach (var slot in s.m_LinkedSlots) { slot.Invalidate(cause); } }); } } base.OnInvalidate(model, cause); }
/// <summary> /// Notify of entity changes. /// </summary> public void OnEntityChange(IList <IEntity> entities, InvalidationCause cause, Func <long, EntityChanges> preActionModifiedRelatedEntities) { foreach (ICacheInvalidator cacheInvalidator in _cacheInvalidators) { cacheInvalidator.OnEntityChange(entities, cause, preActionModifiedRelatedEntities); } }
public void BasicTest(InvalidationCause invalidationCause) { CachingReportToQueryConverter cachingReportToQueryConverter; Report report; StructuredQuery structuredQuery; ItemsRemovedEventHandler <CachingReportToQueryConverterKey> itemsRemovedEventHandler; List <long> itemsRemoved; using (var ctx = EDC.ReadiNow.Database.DatabaseContext.GetContext(true, preventPostSaveActionsPropagating: true)) { report = TestQueries.Entities().ToReport(); report.Save(); ctx.CommitTransaction(); } cachingReportToQueryConverter = Factory.Current.Resolve <CachingReportToQueryConverter>(); Assert.That(cachingReportToQueryConverter, Is.Not.Null, "Not report to query converter cache found"); Assert.That(cachingReportToQueryConverter, Is.Not.Null, "Not report to query converter cache found"); itemsRemoved = new List <long>(); itemsRemovedEventHandler = (sender, args) => itemsRemoved.AddRange(args.Items.Select(key => key.ReportId)); structuredQuery = cachingReportToQueryConverter.Convert(report, null); try { cachingReportToQueryConverter.Cache.ItemsRemoved += itemsRemovedEventHandler; Assert.That(cachingReportToQueryConverter.Cache, Has.Exactly(1).Property("Key").Property("ReportId").EqualTo(report.Id)); Assert.That(cachingReportToQueryConverter.Cache, Has.Exactly(1).Property("Value").Property("StructuredQuery").SameAs(structuredQuery)); using (var ctx = EDC.ReadiNow.Database.DatabaseContext.GetContext(true, preventPostSaveActionsPropagating: true)) { if (invalidationCause == InvalidationCause.Save) { report.Save(); } else if (invalidationCause == InvalidationCause.Delete) { report.Delete(); } else { Assert.Fail("Unknown invalidation cause"); } ctx.CommitTransaction(); } Assert.That(cachingReportToQueryConverter.Cache, Has.Exactly(0).Property("Key").EqualTo(report.Id)); Assert.That(itemsRemoved, Has.Exactly(1).EqualTo(report.Id)); } finally { cachingReportToQueryConverter.Cache.ItemsRemoved -= itemsRemovedEventHandler; } }
public void OnEntityChange(IList <IEntity> entities, InvalidationCause cause, Func <long, EntityChanges> preActionModifiedRelatedEntities) { if (_caches.Count > 0 && AreMetadata(entities)) { InvalidateMetadataCaches(RequestContext.TenantId); } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { base.OnInvalidate(model, cause); if (cause == InvalidationCause.kSettingChanged) { UpdateValidOutputs(); } }
void InvalidateChildren(VFXModel model, InvalidationCause cause) { foreach (var child in children) { child.OnInvalidate(model, cause); child.InvalidateChildren(model, cause); } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { if (model == this && cause == InvalidationCause.kConnectionChanged) { ResyncSlots(false); // To add/remove stripIndex } base.OnInvalidate(model, cause); }
protected internal virtual void Invalidate(VFXModel model, InvalidationCause cause) { OnInvalidate(model, cause); if (m_Parent != null) { m_Parent.Invalidate(model, cause); } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { base.OnInvalidate(model, cause); if (owner is VFXModel) { ((VFXModel)owner).Invalidate(model, cause); // Forward invalidate event to owner } }
public void OnOriginalSlotModified(VFXModel original, InvalidationCause cause) { if (cause == InvalidationCause.kParamChanged) { m_OriginalToCopy[original as VFXSlot].value = (original as VFXSlot).value; Invalidate(InvalidationCause.kParamChanged); } }
protected internal override void Invalidate(VFXModel model, InvalidationCause cause) { base.Invalidate(model, cause); foreach (VFXContext owner in owners) { owner.Invalidate(model, cause); } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { if (model == this && cause == InvalidationCause.kSettingChanged) { ResyncSlots(true); } base.OnInvalidate(model, cause); }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { if (cause == InvalidationCause.kSettingChanged && (subgraph != null || object.ReferenceEquals(m_Subgraph, null))) { RecreateCopy(); } base.OnInvalidate(model, cause); }
protected internal override void Invalidate(VFXModel model, InvalidationCause cause) { base.Invalidate(model, cause); var owner = this.owner; if (owner != null) { owner.Invalidate(this, cause); } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { if (m_EntryCount < 1) { m_EntryCount = 1; } if (m_EntryCount > 32) { m_EntryCount = 32; } base.OnInvalidate(model, cause); }
protected internal override void Invalidate(VFXModel model, InvalidationCause cause) { base.Invalidate(model, cause); if (cause == InvalidationCause.kSettingChanged) // As data settings are supposed to be implicitely context settings at the same time, throw an invalidate for each contexts { foreach (VFXContext owner in owners) { owner.Invalidate(owner, cause); } } }
/// <summary> /// Notify a cache when an entity is saved or deleted. /// </summary> /// <param name="entities">The entities being saved or deleted. This cannot be null.</param> /// <param name="cause">Whether the operation is a save or delete.</param> /// <param name="preActionModifiedRelatedEntities">Modified fields and related entities. This cannot be null.</param> public void OnEntityChange(IList <IEntity> entities, InvalidationCause cause, Func <long, EntityChanges> preActionModifiedRelatedEntities) { if (InvalidationCause.Delete != cause || entities == null) { return; } if (entities.Any(e => e.Is <EntityType>())) { Instance.Clear(); } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { if (cause == InvalidationCause.kConnectionChanged) { if (model == this) { ResyncSlots(false); // To add/remove stripIndex } RefreshErrors(GetGraph()); } base.OnInvalidate(model, cause); }
protected virtual void OnInvalidate(VFXModel model, InvalidationCause cause) { if (onInvalidateDelegate != null) { Profiler.BeginSample("VFXEditor.OnInvalidateDelegate"); try { onInvalidateDelegate(model, cause); } finally { Profiler.EndSample(); } } }
public void Invalidate(InvalidationCause cause) { Modified(); string sampleName = GetType().Name + "-" + name + "-" + cause; Profiler.BeginSample("VFXEditor.Invalidate" + sampleName); try { Invalidate(this, cause); } finally { Profiler.EndSample(); } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { base.OnInvalidate(model, cause); if (cause == InvalidationCause.kStructureChanged || cause == InvalidationCause.kConnectionChanged || cause == InvalidationCause.kExpressionInvalidated || cause == InvalidationCause.kSettingChanged) { if (hasBeenCompiled || CanBeCompiled()) { Invalidate(InvalidationCause.kExpressionGraphChanged); } } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { base.OnInvalidate(model, cause); if (cause == InvalidationCause.kSettingChanged) { //Delete incompatible blocks foreach (var block in children.ToList()) { if (!Accept(block)) { RemoveChild(block); } } } }
protected override void OnInvalidate(VFXModel model, InvalidationCause cause) { if (cause == InvalidationCause.kSettingChanged || cause == InvalidationCause.kExpressionInvalidated) { if (cause == InvalidationCause.kSettingChanged && (m_Subgraph != null || object.ReferenceEquals(m_Subgraph, null))) // do not recreate subchildren if the subgraph is not available but is not null { RecreateCopy(); } base.OnInvalidate(model, cause); PatchInputExpressions(); } else { base.OnInvalidate(model, cause); } }
protected override sealed void OnInvalidate(VFXModel model, InvalidationCause cause) { //Detect spaceable input slot & set output slot as a result (if one output slot is spaceable) var inputSlotWithExpression = new List <VFXSlot>(); GetSlotPredicateRecursive(inputSlotWithExpression, inputSlots, s => s.IsMasterSlot()); var inputSlotSpaceable = inputSlots.Where(o => o.spaceable); if (inputSlotSpaceable.Any() || inputSlots.Count == 0) { var outputSlotWithExpression = new List <VFXSlot>(); GetSlotPredicateRecursive(outputSlotWithExpression, outputSlots, s => s.IsMasterSlot()); var outputSlotSpaceable = outputSlots.Where(o => o.spaceable); bool needUpdateInputSpaceable = false; foreach (var output in outputSlotSpaceable) { var currentSpaceForSlot = GetOutputSpaceFromSlot(output); if (currentSpaceForSlot != output.space) { output.space = currentSpaceForSlot; needUpdateInputSpaceable = true; } } //If one of output slot has changed its space, expression tree for inputs, //and more generally, current operation expression graph is invalid. //=> Trigger invalidation on input is enough to recompute the graph from this operator if (needUpdateInputSpaceable) { foreach (var input in inputSlotSpaceable) { input.Invalidate(InvalidationCause.kSpaceChanged); } } } if (cause == InvalidationCause.kConnectionChanged) { ResyncSlots(true); } base.OnInvalidate(model, cause); }
public void Invalidate(InvalidationCause cause) { if (cause != InvalidationCause.kExpressionGraphChanged && cause != InvalidationCause.kExpressionInvalidated) { Modified(); } string sampleName = GetType().Name + "-" + name + "-" + cause; Profiler.BeginSample("VFXEditor.Invalidate" + sampleName); try { Invalidate(this, cause); } finally { Profiler.EndSample(); } }
protected sealed override void OnInvalidate(VFXModel model, InvalidationCause cause) { base.OnInvalidate(model, cause); if (isOutput) { return; } if (cause == InvalidationCause.kSettingChanged) { var valueExpr = m_ExprSlots.Select(t => t.DefaultExpression(valueMode)).ToArray(); bool valueExprChanged = true; if (m_ValueExpr.Length == valueExpr.Length) { valueExprChanged = false; for (int i = 0; i < m_ValueExpr.Length; ++i) { if (m_ValueExpr[i].ValueMode != valueExpr[i].ValueMode || m_ValueExpr[i].valueType != valueExpr[i].valueType) { valueExprChanged = true; break; } } } if (valueExprChanged) { m_ValueExpr = valueExpr; outputSlots[0].InvalidateExpressionTree(); Invalidate(InvalidationCause.kExpressionGraphChanged); // As we need to update exposed list event if not connected to a compilable context } /* TODO : Allow VisualEffectApi to update only exposed name */ else if (exposed) { Invalidate(InvalidationCause.kExpressionGraphChanged); } } if (cause == InvalidationCause.kParamChanged) { UpdateDefaultExpressionValue(); } }