Ejemplo n.º 1
0
        public bool Equals(AliasData other)
        {
            if(ReferenceEquals(other, null))
                return false;

            return
                EqualityComparer<String>.Default.Equals(this.Name, other.Name)
             && EqualityComparer<String>.Default.Equals(this.Expression, other.Expression)
             ;
        }
Ejemplo n.º 2
0
        private void Add(ICommandManager commandManager, IPlugin plugin, AliasData unparsedAlias, 
            IExpression alias, bool store)
        {
            ushort arity = alias.Arity;
            QualifiedNameTypes qualifiedName =
                QualifiedAliasName(plugin.Name, unparsedAlias.Name, arity);

            if(_aliases.ContainsKey(qualifiedName) || _commands.ContainsKey(qualifiedName))
                throw new InvalidOperationException("Alias with name " + unparsedAlias.Name + " and arity " + arity
                    + " already exists.");

            AliasCommand command = new AliasCommand(plugin, unparsedAlias.Name,
                "Alias for (" + ControlCodes.Bold(unparsedAlias.Expression) + ")", false, alias);
            commandManager.Add(command);

            _unqualifiedAliases.Add(unparsedAlias.Name, arity);
            _commands.Add(qualifiedName, command);
            _aliases.Add(qualifiedName, unparsedAlias);
            if(store)
                Aliases.Add(unparsedAlias);
        }