Exemple #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);
        }
Exemple #2
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
                });
            });
        }