public bool Añadir(Restricciones restriccion, string valor, bool excepcionPorIncompativilidad = false) { //usar | para saber si es compatible la restriccion con el tipo sino puede añadir=false bool añadir = ((int)restriccion & (int)TipoBaseRestriccion) != (int)TipoBaseRestriccion; if (!añadir && excepcionPorIncompativilidad) { throw new XsdException("El tipo base " + TipoBaseRestriccion.ToString().Substring(1) + " no puede con la restriccion \"" + restriccion + "\""); } //Controlo compatibilidad if (TipoBaseRestriccion.Equals(TiposBaseXsd.Boolean)) { if (restriccion.Equals(Restricciones.Enumeration) || restriccion.Equals(Restricciones.Length) || restriccion.Equals(Restricciones.MinLength) || restriccion.Equals(Restricciones.MaxLength)) { if (excepcionPorIncompativilidad) { throw new XsdException("El tipo base Boolean no puede con la restriccion \"" + restriccion + "\""); } } añadir = false; } else if (TipoBaseRestriccion.Equals(TiposBaseXsd.ENTITIES) || TipoBaseRestriccion.Equals(TiposBaseXsd.IDREFS) || TipoBaseRestriccion.Equals(TiposBaseXsd.NMTOKENS)) { if (restriccion.Equals(Restricciones.Pattern)) { if (excepcionPorIncompativilidad) { throw new XsdException("El tipo base " + TipoBaseRestriccion.ToString().Substring(1) + " no puede con la restriccion \"" + restriccion + "\""); } } añadir = false; } if (añadir) { if (!restricciones.Existeix(restriccion)) { restricciones.Afegir(restriccion, null); } restricciones[restriccion] = valor; } return(añadir); //visual studio lo omite... //quitar restricines que sean incompatibles entre ellas...y si es true lanzar excepcion //usar switch con el toString de la restriccion }