public CloneExclusion(ExclusionMode mode, string propertyName = null, RawPtr pointer = null, AssetsObject pointerTarget = null, Type type = null) { Mode = mode; PropertyName = propertyName; Pointer = pointer; Type = type; PointerTarget = pointerTarget; }
private void OverwriteExclusive(object key) { if (key != Key) { Key = key; this.Children.Clear(); mode = ExclusionMode.Empty; } }
///// <summary> ///// Store an exclusive child inside this node. ///// </summary> ///// <param name="v">Bound variable holding the key for the child</param> ///// <param name="overwrite">If true, this will overwrite any existing child with a different value.</param> ///// <returns>The child node</returns> ///// <exception cref="KBExclusionException">If a non-exclusive child has already been written.</exception> //public ELNode StoreExclusive(Variable v, bool overwrite) //{ // return StoreExclusive(v.Value, overwrite); //} /// <summary> /// Store an exclusive child inside this node. /// </summary> /// <param name="key">Key for the child</param> /// <param name="overwrite">If true, this will overwrite any existing child with a different value.</param> /// <returns>The child node</returns> /// <exception cref="ELNodeExclusionException">If a non-exclusive child has already been written.</exception> public ELNode StoreExclusive(object key, bool overwrite) { switch (mode) { case ExclusionMode.Empty: { mode = ExclusionMode.Exclusive; var result = new ELNode(this, key); if (this.Children.Count == 0) { this.Children = new List <ELNode> { result } } ; else { this.Children.Add(result); } return(result); } case ExclusionMode.NonExclusive: throw new ELNodeExclusionException("Exclusive store on non-exclusive node.", this, key); case ExclusionMode.Exclusive: if (overwrite) { if (this.Children.Count > 0) { this.Children[0].OverwriteExclusive(key); } else { this.Children.Add(new ELNode(this, key)); } } else if (key != this.Children[0].Key) { throw new ELNodeExclusionException("Exclusive store doesn't match previous store.", this, key); } return(this.Children[0]); default: throw new InvalidOperationException("Invalid exclusion mode"); } }
public RandomExhaust(List <Type> list, ExclusionMode exclusionMode, int exclusionNumber = 1, string persistencyKey = "", int maxSizeSaved = 30, bool useFirstToPick = false, Type firstToPick = default(Type)) { this.list = list; this.exclusionMode = exclusionMode; this.persistencyKey = persistencyKey; this.maxSizeSaved = maxSizeSaved; this.exclusionNumber = exclusionNumber; this.useFirstToPick = useFirstToPick; this.firstToPick = firstToPick; if (persistent) { LoadExcludingList(); UpdateExcludingList(); } }
/// <summary> /// Store an exclusive child inside this node. /// </summary> /// <param name="key">Key for the child</param> /// <param name="overwrite">If true, this will overwrite any existing child with a different value.</param> /// <returns>The child node</returns> /// <exception cref="KBExclusionException">If a non-exclusive child has already been written.</exception> public KnowledgeBaseEntry StoreExclusive(object key, bool overwrite) { switch (mode) { case ExclusionMode.Empty: { mode = ExclusionMode.Exclusive; var result = new KnowledgeBaseEntry(this, key); if (this.Children == EmptyChildren) { this.Children = new List <KnowledgeBaseEntry> { result } } ; else { this.Children.Add(result); } return(result); } case ExclusionMode.NonExclusive: throw new KBExclusionException("Exclusive store on non-exclusive node."); case ExclusionMode.Exclusive: if (overwrite) { this.Children[0].OverwriteExclusive(key); } else if (key != this.Children[0].Key) { throw new KBExclusionException("Exclusive store doesn't match previous store."); } return(this.Children[0]); default: throw new InvalidOperationException("Invalid exclusion mode"); } }
public static ExclusionMode GetExclusionMode(this IEnumerable <CloneExclusion> exclus, object targetObject, PropertyInfo propInfo) { if (exclus == null) { return(ExclusionMode.None); } ExclusionMode mode = ExclusionMode.None; foreach (var e in exclus) { if (e.Matches(targetObject, propInfo)) { if (e.Mode > mode) { mode = e.Mode; } } } return(mode); }
///// <summary> ///// Store a non-exclusive child inside this node. ///// </summary> ///// <param name="v">Bound variable holding the key for the child</param> ///// <returns>The child node</returns> ///// <exception cref="KBExclusionException">If an exclusive child has already been written.</exception> //public ELNode StoreNonExclusive(Variable v) //{ // return StoreNonExclusive(v.Value); //} /// <summary> /// Store a non-exclusive child inside this node. /// </summary> /// <param name="key">Key for the new child</param> /// <returns>The child node</returns> /// <exception cref="ELNodeExclusionException">If an exclusive child has already been written.</exception> public ELNode StoreNonExclusive(object key) { ELNode result = null; switch (mode) { case ExclusionMode.Empty: { mode = ExclusionMode.NonExclusive; result = new ELNode(this, key); if (this.Children == EmptyChildren) { this.Children = new List <ELNode> { result } } ; else { this.Children.Add(result); } } break; case ExclusionMode.Exclusive: throw new ELNodeExclusionException("Non-exclusive store on exclusive node.", this, key); case ExclusionMode.NonExclusive: foreach (var c in this.Children) { if (c.Key == key) { return(c); } } this.Children.Add(result = new ELNode(this, key)); break; } return(result); }
/// <summary> /// Store a non-exclusive child inside this node. /// </summary> /// <param name="key">Key for the new child</param> /// <returns>The child node</returns> /// <exception cref="KBExclusionException">If an exclusive child has already been written.</exception> public KnowledgeBaseEntry StoreNonExclusive(object key) { KnowledgeBaseEntry result = null; switch (mode) { case ExclusionMode.Empty: { mode = ExclusionMode.NonExclusive; result = new KnowledgeBaseEntry(this, key); if (this.Children == EmptyChildren) { this.Children = new List <KnowledgeBaseEntry> { result } } ; else { this.Children.Add(result); } } break; case ExclusionMode.Exclusive: throw new KBExclusionException("Non-exclusive store on exclusive node."); case ExclusionMode.NonExclusive: foreach (var c in this.Children) { if (c.Key == key) { return(c); } } this.Children.Add(result = new KnowledgeBaseEntry(this, key)); break; } return(result); }
public RandomExhaustAudioClip(List <AudioClip> list, ExclusionMode exclusionMode, int exclusionNumber = 1, string persistencyKey = "", int maxSizeSaved = 30) : base(list, exclusionMode, exclusionNumber, persistencyKey, maxSizeSaved) { }
/// <summary> /// Initializes a new instance of the <see cref="RandomExhaustInt"/> class with a list of numbers ranging from rangeStart to rangeEnd (included). /// </summary> public RandomExhaustInt(int rangeStart, int rangeEnd, ExclusionMode exclusionMode, int exclusionNumber = 1, string persistencyKey = "", int maxSizeSaved = 30) : base(Enumerable.Range(rangeStart, rangeEnd - rangeStart + 1).ToList(), exclusionMode, exclusionNumber, persistencyKey, maxSizeSaved) { }
public CloneExclusion(ExclusionMode mode) { Mode = mode; }
private void OverwriteExclusive(object key) { Key = key; this.Children.Clear(); mode = ExclusionMode.Empty; }
/// <summary> /// Store a non-exclusive child inside this node. /// </summary> /// <param name="key">Key for the new child</param> /// <returns>The child node</returns> /// <exception cref="KBExclusionException">If an exclusive child has already been written.</exception> public KnowledgeBaseEntry StoreNonExclusive(object key) { KnowledgeBaseEntry result =null; switch (mode) { case ExclusionMode.Empty: { mode = ExclusionMode.NonExclusive; result = new KnowledgeBaseEntry(this, key); if (this.Children == EmptyChildren) this.Children = new List<KnowledgeBaseEntry> { result }; else this.Children.Add(result); } break; case ExclusionMode.Exclusive: throw new KBExclusionException("Non-exclusive store on exclusive node."); case ExclusionMode.NonExclusive: foreach (var c in this.Children) { if (c.Key == key) return c; } this.Children.Add(result = new KnowledgeBaseEntry(this, key)); break; } return result; }
/// <summary> /// Store an exclusive child inside this node. /// </summary> /// <param name="key">Key for the child</param> /// <param name="overwrite">If true, this will overwrite any existing child with a different value.</param> /// <returns>The child node</returns> /// <exception cref="KBExclusionException">If a non-exclusive child has already been written.</exception> public KnowledgeBaseEntry StoreExclusive(object key, bool overwrite) { switch (mode) { case ExclusionMode.Empty: { mode = ExclusionMode.Exclusive; var result = new KnowledgeBaseEntry(this, key); if (this.Children == EmptyChildren) this.Children = new List<KnowledgeBaseEntry> { result }; else this.Children.Add(result); return result; } case ExclusionMode.NonExclusive: throw new KBExclusionException("Exclusive store on non-exclusive node."); case ExclusionMode.Exclusive: if (overwrite) this.Children[0].OverwriteExclusive(key); else if (key != this.Children[0].Key) throw new KBExclusionException("Exclusive store doesn't match previous store."); return this.Children[0]; default: throw new InvalidOperationException("Invalid exclusion mode"); } }