private string GetViewEdit() { var sb = new StringBuilder(); Process(sb, "\n public " + ClassType.Name + " Item;\n", b => { b.h1.text(ClassType.Name + " Edit").end.enter().enter(); b.form("post", "<%= UrlTo.Action(\"update\").Parameters(Item.Id) %>").enter(); var ctx = ModelContext.GetInstance(ClassType); foreach (MemberHandler m in ctx.Info.Members) { if (!m.Is.RelationField && !m.Is.DbGenerate && !m.Is.AutoSavedValue) { string n = ClassType.Name.ToLower() + "_" + m.Name.ToLower(); string n1 = ClassType.Name.ToLower() + "[" + m.Name.ToLower() + "]"; b.include(" ").p.label.attr("for", n).text(m.Name).end.br .include(ControlMapper.Map(m, n, n1, "<%= Item." + m.Name + " %>")).end.enter(); } } b.input.name("commit").type("submit").value("Update").end.enter().end.enter().enter(); b.include("<%= LinkTo.Title(\"Show\").Action(\"show\").Parameters(Item.Id) %>").enter(); b.include("<%= LinkTo.Title(\"Back\").Action(\"list\") %>").enter(); }); return(sb.ToString()); }
public SpiceObjectMappings() { Controls = new ControlMapper(); Components = new EntityGeneratorMapper(); Models = new ModelGeneratorMapper(); Waveforms = new WaveformMapper(); Exporters = new ExporterMapper(); // Register waveform generators Waveforms.Map("SINE", new SineGenerator()); Waveforms.Map("SIN", new SineGenerator()); Waveforms.Map("PULSE", new PulseGenerator()); Waveforms.Map("PWL", new PwlGenerator()); // Register exporters Exporters.Map(new[] { "V", "VI", "VR", "VM", "VDB", "VPH", "VP" }, new VoltageExporter()); Exporters.Map(new[] { "I", "IR", "II", "IM", "IDB", "IP" }, new CurrentExporter()); Exporters.Map("@", new PropertyExporter()); // Register model generators Models.Map(new[] { "R", "C", "RES" }, new RLCModelGenerator()); Models.Map("D", new DiodeModelGenerator()); Models.Map(new[] { "NPN", "PNP" }, new BipolarModelGenerator()); Models.Map(new[] { "SW", "CS", "VSWITCH", "ISWITCH" }, new SwitchModelGenerator()); Models.Map(new[] { "PMOS", "NMOS" }, new MosfetModelGenerator()); Models.Map(new[] { "NJF", "PJF" }, new JFETModelGenerator()); // Register controls Controls.Map("ST_R", new StRegisterControl()); Controls.Map("STEP_R", new StepRegisterControl()); Controls.Map("PARAM", new ParamControl()); Controls.Map("SPARAM", new SParamControl()); Controls.Map("FUNC", new FuncControl()); Controls.Map("GLOBAL", new GlobalControl()); Controls.Map("CONNECT", new ConnectControl()); Controls.Map("DISTRIBUTION", new DistributionControl()); Controls.Map("OPTIONS", new OptionsControl()); Controls.Map("TEMP", new TempControl()); Controls.Map("ST", new StControl()); Controls.Map("STEP", new StepControl()); Controls.Map("MC", new McControl()); Controls.Map("TRAN", new TransientControl(Exporters)); Controls.Map("AC", new ACControl(Exporters)); Controls.Map("DC", new DCControl(Exporters)); Controls.Map("OP", new OPControl(Exporters)); Controls.Map("NOISE", new NoiseControl(Exporters)); Controls.Map("LET", new LetControl()); Controls.Map("SAVE", new SaveControl(Exporters, new ExportFactory())); Controls.Map("PLOT", new PlotControl(Exporters, new ExportFactory())); Controls.Map("PRINT", new PrintControl(Exporters, new ExportFactory())); Controls.Map("IC", new ICControl()); Controls.Map("NODESET", new NodeSetControl()); // Register component generators Components.Map(new[] { "R", "L", "C", "K" }, new RLCKGenerator()); Components.Map(new[] { "B" }, new ArbitraryBehavioralGenerator()); Components.Map(new[] { "V", "H", "E" }, new VoltageSourceGenerator()); Components.Map(new[] { "I", "G", "F" }, new CurrentSourceGenerator()); Components.Map(new[] { "S", "W" }, new SwitchGenerator()); Components.Map("Q", new BipolarJunctionTransistorGenerator()); Components.Map("D", new DiodeGenerator()); Components.Map("M", new MosfetGenerator()); Components.Map("X", new SubCircuitGenerator()); Components.Map("J", new JFETGenerator()); Components.Map("T", new LosslessTransmissionLineGenerator()); Components.Map("BVDelay", new VoltageDelayGenerator()); }
private string GetViewNew() { var sb = new StringBuilder(); Process(sb, null, delegate(HtmlBuilder b) { string cn = ClassType.Name; b.h1.text("New " + cn).end.enter().enter(); b.form("post", "<%= UrlTo.Action(\"create\") %>").enter(); var ctx = ModelContext.GetInstance(ClassType); foreach (MemberHandler m in ctx.Info.Members) { if (!m.Is.RelationField && !m.Is.DbGenerate && !m.Is.AutoSavedValue) { string n = cn.ToLower() + "_" + m.Name.ToLower(); string n1 = cn.ToLower() + "[" + m.Name.ToLower() + "]"; b.include(" ").p.label.attr("for", n).text(m.Name).end.br.include(ControlMapper.Map(m, n, n1, null)).end.enter(); } } b.include(" ").input.name("commit").type("submit").value("Create").end.enter().end.enter().enter(); b.include("<%= LinkTo.Title(\"Back\").Action(\"list\") %>").enter(); }); return(sb.ToString()); }