Beispiel #1
0
        void IModule.ModifyGame(HGame game)
        {
            var unresolved = new Dictionary <string, IList <string> >();

            foreach (PropertyInfo property in GetAllProperties(GetType()))
            {
                var messageIdAtt = property.GetCustomAttribute <MessageIdAttribute>();
                if (string.IsNullOrWhiteSpace(messageIdAtt?.Hash))
                {
                    continue;
                }

                ushort[] ids = game.GetMessageIds(messageIdAtt.Hash);
                if (ids != null)
                {
                    property.SetValue(this, ids[0]);
                }
                else
                {
                    if (!unresolved.TryGetValue(messageIdAtt.Hash, out IList <string> users))
                    {
                        users = new List <string>();
                        unresolved.Add(messageIdAtt.Hash, users);
                    }
                    users.Add("Property: " + property.Name);
                }
            }
            foreach (DataCaptureAttribute dataCaptureAtt in _unknownDataAttributes)
            {
                if (string.IsNullOrWhiteSpace(dataCaptureAtt.Identifier))
                {
                    continue;
                }

                ushort[] ids = game.GetMessageIds(dataCaptureAtt.Identifier);
                if (ids != null)
                {
                    AddCallback(dataCaptureAtt, ids[0]);
                }
                else
                {
                    var identifiers = (dataCaptureAtt.IsOutgoing ? Out : (Identifiers)In);
                    if (identifiers.TryGetId(dataCaptureAtt.Identifier, out ushort id))
                    {
                        AddCallback(dataCaptureAtt, id);
                    }
                    else
                    {
                        if (!unresolved.TryGetValue(dataCaptureAtt.Identifier, out IList <string> users))
                        {
                            users = new List <string>();
                            unresolved.Add(dataCaptureAtt.Identifier, users);
                        }
                        users.Add(dataCaptureAtt.GetType().Name + ": " + dataCaptureAtt.Method.Name);
                    }
                }
            }
            if (unresolved.Count > 0)
            {
                throw new HashResolvingException(game.Revision, unresolved);
            }
            ModifyGame(game);
        }