public bool loadInstantReactions(XmlNode node, LinkedList<IReaction> reactions) { XmlNodeList IReactionsList = node.SelectNodes("instantReaction"); bool b = true; foreach (XmlNode IReaction in IReactionsList) { InstantReaction ir = new InstantReaction(); foreach (XmlNode attr in IReaction) { switch (attr.Name) { case "name": ir.setName(attr.InnerText); break; case "reactants": loadInstantReactionReactants(attr, ir); break; case "products": loadInstantReactionProducts(attr, ir); break; } } reactions.AddLast(ir); } return b; }
/*! * \brief Build an Instant reaction with a InstantReactionProperties class * \param props The properties * \return Return a new reaction or null if it fail. */ public static IReaction buildInstantReactionFromProps(InstantReactionProperties props) { if (props == null) { return(null); } InstantReaction reaction = new InstantReaction(); reaction.setName(props.name); reaction.setEnergyCost(props.energyCost); Product newReactant; foreach (Product r in props.reactants) { newReactant = new Product(r); reaction.addReactant(newReactant); } Product newProd; foreach (Product p in props.products) { newProd = new Product(p); reaction.addProduct(newProd); } return(reaction); }
public static IReaction buildInstantReactionFromProps(InstantReactionProprieties props) { InstantReaction reaction = new InstantReaction(); reaction.setName(props.name); Product newReactant; foreach (Product r in props.reactants) { newReactant = new Product(r); reaction.addReactant(newReactant); } Product newProd; foreach (Product p in props.products) { newProd = new Product(p); reaction.addProduct(newProd); } return reaction; }
/*! \brief Build an Instant reaction with a InstantReactionProperties class \param props The properties \return Return a new reaction or null if it fail. */ public static IReaction buildInstantReactionFromProps(InstantReactionProperties props) { if (props == null) return null; InstantReaction reaction = new InstantReaction(); reaction.setName(props.name); reaction.setEnergyCost(props.energyCost); Product newReactant; foreach (Product r in props.reactants) { newReactant = new Product(r); reaction.addReactant(newReactant); } Product newProd; foreach (Product p in props.products) { newProd = new Product(p); reaction.addProduct(newProd); } return reaction; }