/// <summary> /// Signal that the <see cref="IResolvable"/> is no longer valid. /// </summary> /// <param name="cache"> /// The <see cref="IObjectCache"/> to change. /// </param> /// <param name="resource"> /// The <see cref="IResolvable"/> to remove. /// </param> /// <exception cref="ArgumentNullException"> /// When <paramref name="cache"/> or <paramref name="resource"/> is <b>null</b>. /// </exception> /// <remarks> /// Removes the <paramref name="resource"/> from the <paramref name="cache"/> and any associated backing stores. /// No <see cref="Exception"/> is <c>thrown</c> if the resource does not exist in the cache. /// </remarks> public static void Invalidate(this IObjectCache cache, IResolvable resource) { Guard.IsNotNull(cache, "cache"); Guard.IsNotNull(resource, "resource"); cache.Invalidate(resource.Uri); }
static IEnumerator Wait <T>(T operation, IResolvable <T> task) { yield return(operation); _operations.Remove(operation); task.Resolve(operation); }
/// <summary> /// Signal that the <see cref="IResolvable"/> is no longer required in the cache. /// </summary> /// <param name="cache"> /// The <see cref="IObjectCache"/> to change. /// </param> /// <param name="resource"> /// The <see cref="IResolvable"/> to remove. /// </param> /// <exception cref="ArgumentNullException"> /// When <paramref name="cache"/> or <paramref name="resource"/> is <b>null</b>. /// </exception> /// <remarks> /// Removes the <paramref name="resource"/> from the <paramref name="cache"/>. This may place the resource into an associated backing store, /// based on the policies of the cache. No <see cref="Exception"/> is <c>thrown</c> if /// the resource does not exist in the store. /// </remarks> public static void Evict(this IObjectCache cache, IResolvable resource) { Guard.IsNotNull(cache, "cache"); Guard.IsNotNull(resource, "resource"); cache.Evict(resource.Uri); }
/// <summary> /// Creates a loop statement. /// </summary> public LoopStatement() { resolvable = new ResolvableImpl(this); statements = ParentSetList <SequentialStatement> .Create(this); scope = Scopes.createScope(this, resolvable); }
public override void ModifyObject(Game game, IResolvable resolvable) { if (resolvable == target) { (resolvable as Card).Modifiers.Add(modifier); } }
public override void UnmodifyObject(Game game, IResolvable resolvable) { if (resolvable == target) { modifiers.ForEach(modifier => target.Modifiers.Remove(modifier)); } }
/// <summary> /// This method removes a spell from the stack and puts it in its owner's graveyard. If the given spell is not on the stack, then this effect does nothing. /// </summary> /// <param name="card">This spell is the spell that is to be countered.</param> public void Counter(IResolvable obj) { if (Stack.Contains(obj)) { Stack <IResolvable> temp = new Stack <IResolvable>(Stack.Count); IResolvable topmost = null; do { topmost = Stack.Pop(); if (topmost == obj) { break; } temp.Push(topmost); topmost = null; } while (Stack.Count > 0); while (temp.Count > 0) { Stack.Push(temp.Pop()); } if (topmost != null) { if (topmost is Card) { (topmost as Card).Owner.Graveyard.Add(topmost as Card); CardHasChangedZones?.Invoke(this, topmost as Card, Common.Enums.Zone.Stack, Common.Enums.Zone.Graveyard); } } } CheckStateBasedActions(); }
public InterfaceT Resolve <InterfaceT>(string alias, string resolverName = "") { int resultError; InterfaceT result = default; IResolvable resolvable = ServersHolder.GetResolvable(ref alias, out resultError); if (resultError == 0) { IResolverHandler resolverHandler = resolvable.GetResolver <InterfaceT>(Resolvable.RESOLVER_DEF, out _); resolverHandler.InvokeResolver(); result = (InterfaceT)resolverHandler.ResolverParam; resolverHandler = resolvable.GetResolver <InterfaceT>(Resolvable.RESOLVER_CRT, out _); resolverHandler.SetParam(ref result); resolverHandler.InvokeResolver(); result = (InterfaceT)resolverHandler.ResolverParam; if ((result != default) && !string.IsNullOrEmpty(resolverName)) { resolverHandler = resolvable.GetResolver <InterfaceT>(resolverName, out _); resolverHandler.SetParam(ref result); resolverHandler.InvokeResolver(); if (resolverHandler.OnlyOnce) { resolvable.RemoveResolver <InterfaceT>(resolverName, out _); } } } return(result); }
public DeclareAttack(Unit attacker, Unit defender, IResolvable attack) { Identity = GameEvents.DeclareAttack; Source = attacker; Attacker = attacker; Defender = defender; Attack = attack; }
/// <summary> /// Creates a library declarative region. /// </summary> /// <param name="identifier">the identifier of the library</param> public LibraryDeclarativeRegion(string identifier) { files = ParentSetList <VhdlFile> .Create(this); resolvable = new ResolvableImpl(this); scope = Scopes.createScope(this, resolvable); this.identifier = identifier; }
public void StopCopying(Card target, IResolvable source) { if (IsCopying == target) { IsCopying = null; } Modifiers.RemoveAll(c => c.Source == source); }
private void DeclareNewVariable(Identifier key, IResolvable value) { if (ReferenceTables.ContainsIdentifier(key)) { Exceptions.Add(new RedeclaredVariableWarning("Redeclared variable detected: " + key, key.SourceLocation)); } ReferenceTables.SetReference(key, value); }
/// <summary> /// Resolves the specified instance. /// </summary> /// <typeparam name="T">The type to resolve.</typeparam> /// <param name="resolvable">The resolvable implementation.</param> /// <returns>Resolved instance.</returns> /// <exception cref="System.ArgumentNullException">resolvable</exception> public static T Resolve <T>(this IResolvable resolvable) { if (resolvable == null) { throw new ArgumentNullException("resolvable"); } return(Resolve <T>(resolvable, new Parameter[0])); }
public static T Resolve <T>(this IResolvable resolvable, params Parameter[] additionalParameters) { if (resolvable == null) { throw new ArgumentNullException("resolvable"); } return((T)resolvable.Resolve(typeof(T), additionalParameters)); }
public void Revert(IPoolable target, string alias) { IResolvable resolvable = ServersHolder.GetResolvable(ref alias, out int resultError); if (resultError == 0) { resolvable.InstanceFactory.Reserve(ref target); } }
public static T ResolveKeyed <T>(this IResolvable resolvable, object key) { if (resolvable == null) { throw new ArgumentNullException("resolvable"); } return((T)resolvable.ResolveKeyed(typeof(T), key)); }
public static Cost Parse(IResolvable source, string manaCost) { var manaAmounts = ManaParser.Parse(manaCost); if (manaAmounts == null) { return(new NoCost(source)); } return(new ManaCost(source, manaAmounts)); }
/// <summary> /// Creates a package body. /// </summary> /// <param name="pack">the associated package</param> public PackageBody(PackageDeclaration pack) : base(pack) { declarations = VhdlCollections.CreateDeclarationList <PackageBodyDeclarativeItem>(); resolvable = new ResolvableImpl(this); scope = Scopes.createScope(this, declarations, resolvable, new LibraryUnitResolvable(this)); this.pack = pack; pack.PackageBody = this; }
/// <summary> /// Creates an architecture. /// </summary> /// <param name="identifier">the architectures identifier</param> /// <param name="entity">the associated entity</param> public Architecture(string identifier, Entity entity) : base(entity) { declarations = VhdlCollections.CreateDeclarationList <BlockDeclarativeItem>(); statements = VhdlCollections.CreateLabeledElementList <ConcurrentStatement>(this); this.identifier = identifier; this.entity = entity; resolvable = new ResolvableImpl(this); scope = Scopes.createScope(this, declarations, statements, resolvable, new LibraryUnitResolvable(this)); entity.AddArchitecture(this); }
public override void UnmodifyObject(Game game, IResolvable resolvable) { if (resolvable is Card) { var card = resolvable as Card; if (card.Modifiers.Contains(modifier)) { card.Modifiers.Remove(modifier); } } }
public void RemoveCounters(IResolvable source, int amount, CounterType counter) { for (int i = 0; i < amount; i++) { if (counters.Contains(counter)) { counters.Remove(counter); } } CountersRemoved?.Invoke(this, source, counter, amount); }
/// <summary> /// /// </summary> /// <param name="resolvable"></param> private void PushOntoStack(IResolvable resolvable, Common.Enums.Zone previousZone) { Stack.Push(resolvable); if (resolvable is Card) { CardHasChangedZones(this, resolvable as Card, previousZone, Common.Enums.Zone.Stack); } else if (resolvable is Ability) { AbilityHasEnteredStack?.Invoke(this, resolvable as Ability); } }
/// <summary> /// 撤销已定义在解析器中的一个解析器函数 /// </summary> public int RevokeResolver <InterfaceT>(string alias, string resolverName, ResolveDelegate <InterfaceT> target) { int statu = 0; IResolvable resolvable = ServersHolder.GetResolvable(ref alias, out statu); if (statu == 0) { "error".Log(resolvable == default, "Resolvable is null when MakeResolver, alias is " + alias); resolvable.RevokeResolver(resolverName, target); } return(statu); }
/// <summary> /// Initializes a new instance of the <see cref="Resolutions" /> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="resolvable">The resolvable.</param> public Resolutions( [CanBeNull] Resolutions parent, [NotNull] IResolvable resolvable) : base(resolvable.IsCaseSensitive, resolvable.ResolveOuterTags, resolvable.ResolveControls) { if (resolvable == null) { throw new ArgumentNullException("resolvable"); } Parent = parent; _resolver = resolvable.Resolve; }
public int MakeResolver <InterfaceT>(string alias, string resolverName, ResolveDelegate <InterfaceT> target) { int statu = 0; IResolvable resolvable = ServersHolder.GetResolvable(ref alias, out statu); if (statu == 0) { Tester.Instance.Log(TesterBaseApp.Instance, TesterBaseApp.LOG, resolvable == default, "error: Resolvable is null when MakeResolver, alias is " + alias); resolvable.SetResolver(resolverName, target, out statu, false, true); } return(statu); }
static private ResolvableInjectable <IResolvable <TResolvableValue>, TInjectable, TTarget, TResolvableValue, TInjectableValue> AsResolvableInjectableBase <TInjectable, TTarget, TResolvableValue, TInjectableValue>(MemberInfo memberInfo, Type defaultType, Func <IInjectionExpression, TInjectable> injectableFactory) where TInjectable : IInjectable <TTarget, TInjectableValue> where TResolvableValue : TInjectableValue { Attribute[] attributes = memberInfo.Attributes(); ResolvableAttributeBase resolvableAttribute = attributes.ResolvableAttribute(); IResolvable <TResolvableValue> resolvable = resolvableAttribute.GetResolvable <TResolvableValue>(defaultType, attributes); TInjectable injectable = injectableFactory(resolvableAttribute.GetInjectionScenario(defaultType)); return(new ResolvableInjectable <IResolvable <TResolvableValue>, TInjectable, TTarget, TResolvableValue, TInjectableValue>(resolvable, injectable)); }
static public IResolvable AsResolvable(this ParameterInfo parameterInfo) { Attribute[] attributes = parameterInfo.Attributes(); IResolvable resolvable = attributes.ResolvableAttribute().GetResolvable(parameterInfo.ParameterType, attributes); if (parameterInfo.HasDefaultValue) { resolvable = new DefaultableResolvable(resolvable, parameterInfo.DefaultValue); } return(resolvable); }
public GrabbedStreamMetadata(Uri originalUri, Uri resourceUri, string name, Size resolution, int bandwidth, MediaFormat format, MediaFormat outputFormat, IResolvable <GrabbedStream> stream) { OriginalUri = originalUri; ResourceUri = resourceUri; Name = name; Resolution = resolution; Bandwidth = bandwidth; StreamFormat = format; OutputFormat = outputFormat; Stream = stream; }
public void Copy(Card target, IResolvable source) { // Can't copy itself if (target == this) { return; } while (target.IsCopying != null) { target = target.IsCopying; } IsCopying = target; copyingSource = source; Modifiers.Add(new StringModifier(source, nameof(Name), target.Name)); Modifiers.Add(new StringModifier(source, nameof(Text), target.Text)); Modifiers.Add(new StringModifier(source, nameof(FlavorText), target.FlavorText)); Modifiers.Add(new BooleanModifier(source, nameof(IsLegendary), target.IsLegendary)); Modifiers.Add(new BooleanModifier(source, nameof(IsSnow), target.IsSnow)); Modifiers.Add(new CostModifier(source, nameof(Cost), target.Cost.Copy(this))); Modifiers.Add(new PowerToughnessModifier(source, nameof(BasePowerFunc), target.BasePowerFunc)); Modifiers.Add(new PowerToughnessModifier(source, nameof(BaseToughnessFunc), target.BaseToughnessFunc)); Modifiers.Add(new CardTypeModifier(source, nameof(Types), ModifierMode.Override, null)); foreach (var type in target.Types) { Modifiers.Add(new CardTypeModifier(source, nameof(Types), ModifierMode.Add, type)); } Modifiers.Add(new StringModifier(source, nameof(Subtypes), null)); if (target.Subtypes != null) { foreach (var subtype in target.Subtypes) { Modifiers.Add(new StringModifier(source, nameof(Subtypes), ModifierMode.Add, subtype)); } } Modifiers.Add(new StaticAbilityModifier(source, nameof(StaticAbilities), ModifierMode.Override, null)); foreach (var staticAbility in target.StaticAbilities) { Modifiers.Add(new StaticAbilityModifier(source, nameof(StaticAbilities), ModifierMode.Add, staticAbility)); } Modifiers.Add(new AbilityModifier(source, nameof(Abilities), ModifierMode.Override, null)); foreach (var ability in target.Abilities) { Modifiers.Add(new AbilityModifier(this, nameof(Abilities), ModifierMode.Add, ability.Copy(this))); } }
/// <summary> /// 重新注册解析器的解析器函数,并返回旧的解析器函数 /// </summary> public ResolveDelegate <InterfaceT> Reregister <InterfaceT>(ResolveDelegate <InterfaceT> target, string alias) { ResolveDelegate <InterfaceT> raw = default; IResolvable resolvable = ServersHolder.GetResolvable(ref alias, out int resultError); if (resultError == 0) { IResolverCacher <InterfaceT> resolverHandler = resolvable.GetResolver <InterfaceT>(Resolvable.RESOLVER_INIT, out _) as IResolverCacher <InterfaceT>; raw = resolverHandler.DelegateTarget; resolverHandler.SetDelegate(target); } return(raw); }
public override void UnmodifyObject(Game game, IResolvable resolvable) { if (resolvable == Target) { modifiers.ForEach(modifier => { if (Target.Modifiers.Contains(modifier)) { Target.Modifiers.Remove(modifier); } }); } }
private ITerminalWrapper GetValue(IResolvable key) { if (_referenceLookupTable.ContainsKey(key)) { return(_referenceLookupTable[key]); } if (key is Expression) { return(GetValue((Expression)key)); } throw new QLError("Reference not initialised"); }
public bool ContainsReference(IResolvable key) { return _referenceLookupTable.ContainsKey(key); }
private ITerminalWrapper GetValue(IResolvable key) { if (_referenceLookupTable.ContainsKey(key)) { return _referenceLookupTable[key]; } if(key is Expression) return GetValue((Expression)key); throw new QLError("Reference not initialised"); }
/// <summary> /// Initializes a new instance of the <see cref="FormatChunk" /> class. /// </summary> /// <param name="resolver">The resolver.</param> /// <param name="tag">The tag.</param> /// <param name="alignment">The alignment.</param> /// <param name="format">The format.</param> /// <param name="value">The value.</param> internal FormatChunk( [CanBeNull] IResolvable resolver, [CanBeNull] string tag, int alignment, [CanBeNull] string format, Optional<object> value = default(Optional<object>)) { Resolver = resolver; Tag = tag; IsControl = !string.IsNullOrEmpty(tag) && tag[0] == FormatBuilder.ControlChar; Alignment = alignment; Format = format; if (!value.IsAssigned) return; IsResolved = true; Value = value.Value; }
public void SetReference(Identifier key, IResolvable value) { _identifierLookupTable[key] = value; }
/// <summary> /// Initializes a new instance of the <see cref="FormatChunk"/> class. /// </summary> /// <param name="resolver">The resolver.</param> /// <param name="tag">The tag.</param> /// <param name="alignment">The alignment.</param> /// <param name="format">The format.</param> /// <param name="isResolved">if set to <see langword="true" /> [is resolved].</param> /// <param name="value">The value.</param> /// <param name="isControl">if set to <see langword="true" /> [is control].</param> internal FormatChunk( [CanBeNull] IResolvable resolver, [CanBeNull] string tag, int alignment, [CanBeNull] string format, bool isResolved, [CanBeNull] object value, bool isControl) { Resolver = resolver; Tag = tag; Alignment = alignment; Format = format; IsResolved = isResolved; Value = value; IsControl = isControl; }
/// <summary> /// Creates a clone of the <see cref="FormatChunk" />, changing the resolved value. /// </summary> /// <param name="chunk">The chunk.</param> /// <param name="value">The value.</param> public FormatChunk([NotNull] FormatChunk chunk, Optional<object> value) { if (chunk == null) throw new ArgumentNullException("chunk"); Resolver = chunk.Resolver; Tag = chunk.Tag; IsControl = chunk.IsControl; Alignment = chunk.Alignment; Format = chunk.Format; DeepCopyChunks(chunk, this); if (!value.IsAssigned) return; IsResolved = true; Value = value.Value; }
/// <summary> /// Initializes a new instance of the <see cref="FormatChunk" /> class. /// </summary> /// <param name="resolver">The resolver.</param> /// <param name="tag">The tag.</param> /// <param name="alignment">The alignment.</param> /// <param name="format">The format.</param> internal FormatChunk( [CanBeNull] IResolvable resolver, [NotNull] string tag, [CanBeNull] string alignment, [CanBeNull] string format) { if (tag == null) throw new ArgumentNullException("tag"); Resolver = resolver; Tag = tag; IsControl = tag.Length > 0 && tag[0] == FormatBuilder.ControlChar; if (alignment != null) int.TryParse(alignment, out Alignment); Format = format; }
public void SetValue(IResolvable key, ITerminalWrapper value) { _referenceLookupTable[key] = value; }