public void TypesTaggedWithNetworkPackageAreResolved() { var typesTaggedWithNetworkPackage = new List <Type>(); var attributeProfiles = new List <string>(); AttributeResolver.DoWithAllTypesWithAttribute <NetworkPackageAttribute>((type, attribute) => { typesTaggedWithNetworkPackage.Add(type); attributeProfiles.Add(attribute.Profile); }); var expectedTypes = new List <Type> { typeof(Package), typeof(AnotherPackage) }; CollectionAssert.AreEqual(expectedTypes, typesTaggedWithNetworkPackage); var expectedProfiles = new List <string> { "Test", "SameTest" }; CollectionAssert.AreEqual(expectedProfiles, attributeProfiles); }
public Invoker(HeroData data) { Gold = data.Gold; Level = data.Level; HeroName = data.HeroName; Armor = data.Armor; HP = data.HP; Mana = data.Mana; Strength = data.Strength; Agility = data.Agility; Intelligence = data.Intelligence; MainAtribute = new AttributeResolver(3); AttackType = "Дальний бой"; Attack = data.Attack; }
static ProtocolResolver() { protocolProvider = new ProtocolManager(); //find NetworkPackages and cache their types AttributeResolver.DoWithAllTypesWithAttribute <NetworkPackageAttribute>( (type, attribute) => { byte id = CreateMessageFlowArguments(GemNetwork.GetMesssageId(attribute.Profile), type, attribute.Profile); attribute.Id = id; protocolProvider[attribute.Profile].Add(id, new TypeAndAttribute { Type = type, Attribute = attribute }); }); }
private void ResolveAttributeToCommand <TAttribute>(Type objectWithCommand, Action <CommandCallback, TAttribute> action) where TAttribute : Attribute { var methods = objectWithCommand.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance) .Where(m => m.GetCustomAttributes(typeof(TAttribute), false).Length > 0); foreach (var methodInfo in methods) { CommandCallback callback; try { callback = (CommandCallback)Delegate.CreateDelegate(typeof(CommandCallback), null, methodInfo, true); AttributeResolver.Find <TAttribute>(methodInfo, attribute => action(callback, attribute)); } catch (Exception ex) { this.Error("Failed to much delegate with CommandAttribute in {0} with the CommandCallback delegate. {1}", objectWithCommand, ex.Message); } } }
protected MetricsHelper(AttributeResolver attributes) { _attributes = attributes; }
public IList <IToken> chunks; // useful for ANTLR IDE developers public ActionAST(ActionAST node) : base(node) { this.resolver = node.resolver; this.chunks = node.chunks; }
public PropertyBindingProcessor(Dictionary <BindingType, IBinder> binders) { _attributeResolver = new AttributeResolver(); _binders = binders; }
public IList<IToken> chunks; // useful for ANTLR IDE developers public ActionAST(ActionAST node) : base(node) { this.resolver = node.resolver; this.chunks = node.chunks; }