示例#1
0
        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);
        }
示例#2
0
 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;
 }
示例#3
0
        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
                });
            });
        }
示例#4
0
文件: Terminal.cs 项目: gmich/Gem
        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);
                }
            }
        }
示例#5
0
 protected MetricsHelper(AttributeResolver attributes)
 {
     _attributes = attributes;
 }
示例#6
0
        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;
 }
示例#8
0
        public IList<IToken> chunks; // useful for ANTLR IDE developers

        public ActionAST(ActionAST node)
            : base(node)
        {
            this.resolver = node.resolver;
            this.chunks = node.chunks;
        }