static public object FromBasic(IHasIdentity basic) { string argumentType = basic.GetType().ToString(); switch (argumentType) { // ----- Is there any way to make self-writing code here through replication or similar, so // ----- that every case doesn't need to be listed? // ------------ COMMUNICATION CLASSES ------------ case "Swarmops.Basic.Types.BasicCommunicationTurnaround": return(CommunicationTurnaround.FromBasic((BasicCommunicationTurnaround)basic)); case "Swarmops.Basic.Types.Communications.BasicOutboundComm": return(OutboundComm.FromBasic((BasicOutboundComm)basic)); case "Swarmops.Basic.Types.Communications.BasicOutboundCommRecipient": return(OutboundCommRecipient.FromBasic((BasicOutboundCommRecipient)basic)); // ----------- FINANCIAL CLASSES ---------- case "Swarmops.Basic.Types.BasicExpenseClaim": return(ExpenseClaim.FromBasic((BasicExpenseClaim)basic)); case "Swarmops.Basic.Types.Financial.BasicCashAdvance": return(CashAdvance.FromBasic((BasicCashAdvance)basic)); case "Swarmops.Basic.Types.BasicInboundInvoice": return(InboundInvoice.FromBasic((BasicInboundInvoice)basic)); case "Swarmops.Basic.Types.Financial.BasicFinancialAccount": return(FinancialAccount.FromBasic((BasicFinancialAccount)basic)); case "Swarmops.Basic.Types.Financial.BasicFinancialTransaction": return(FinancialTransaction.FromBasic((BasicFinancialTransaction)basic)); case "Swarmops.Basic.Types.BasicFinancialValidation": return(FinancialValidation.FromBasic((BasicFinancialValidation)basic)); case "Swarmops.Basic.Types.BasicOutboundInvoice": return(OutboundInvoice.FromBasic((BasicOutboundInvoice)basic)); case "Swarmops.Basic.Types.BasicOutboundInvoiceItem": return(OutboundInvoiceItem.FromBasic((BasicOutboundInvoiceItem)basic)); case "Swarmops.Basic.Types.BasicPayment": return(Payment.FromBasic((BasicPayment)basic)); case "Swarmops.Basic.Types.BasicPaymentGroup": return(PaymentGroup.FromBasic((BasicPaymentGroup)basic)); case "Swarmops.Basic.Types.BasicPayout": return(Payout.FromBasic((BasicPayout)basic)); case "Swarmops.Basic.Types.BasicPayrollAdjustment": return(PayrollAdjustment.FromBasic((BasicPayrollAdjustment)basic)); case "Swarmops.Basic.Types.BasicPayrollItem": return(PayrollItem.FromBasic((BasicPayrollItem)basic)); case "Swarmops.Basic.Types.BasicSalary": return(Salary.FromBasic((BasicSalary)basic)); case "Swarmops.Basic.Types.Financial.BasicFinancialTransactionTagSet": return(FinancialTransactionTagSet.FromBasic((BasicFinancialTransactionTagSet)basic)); case "Swarmops.Basic.Types.Financial.BasicFinancialTransactionTagType": return(FinancialTransactionTagType.FromBasic((BasicFinancialTransactionTagType)basic)); // ------------ GOVERNANCE CLASSES ------------ case "Swarmops.Basic.Types.BasicBallot": return(Ballot.FromBasic((BasicBallot)basic)); case "Swarmops.Basic.Types.BasicMeetingElectionCandidate": return(MeetingElectionCandidate.FromBasic((BasicInternalPollCandidate)basic)); case "Swarmops.Basic.Types.BasicMeetingElection": return(MeetingElection.FromBasic((BasicInternalPoll)basic)); case "Swarmops.Basic.Types.BasicMeetingElectionVote": return(MeetingElectionVote.FromBasic((BasicInternalPollVote)basic)); case "Swarmops.Basic.Types.Governance.BasicMotion": return(Motion.FromBasic((BasicMotion)basic)); case "Swarmops.Basic.Types.Governance.BasicMotionAmendment": return(MotionAmendment.FromBasic((BasicMotionAmendment)basic)); // ------------ PARLEY/ACTIVISM CLASSES ------------ case "Swarmops.Basic.Types.BasicExternalActivity": return(ExternalActivity.FromBasic((BasicExternalActivity)basic)); case "Swarmops.Basic.Types.BasicParley": return(Parley.FromBasic((BasicParley)basic)); case "Swarmops.Basic.Types.BasicParleyAttendee": return(ParleyAttendee.FromBasic((BasicParleyAttendee)basic)); case "Swarmops.Basic.Types.BasicParleyOption": return(ParleyOption.FromBasic((BasicParleyOption)basic)); case "Swarmops.Basic.Types.BasicPerson": return(Person.FromBasic((BasicPerson)basic)); // ------------------ FAIL ---------------- default: throw new NotImplementedException("Unimplemented argument type: " + argumentType); } }
protected void RepeaterAmendments_ItemCreated(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem)) { Label labelDesignation = (Label)item.FindControl("LabelDesignation"); Label labelText = (Label)item.FindControl("LabelText"); Label labelRecommended = (Label)item.FindControl("LabelRecommended"); Literal literalRadioGroup1 = (Literal)item.FindControl("LiteralRadioGroupYes"); Literal literalRadioGroup2 = (Literal)item.FindControl("LiteralRadioGroupNo"); Literal literalRadioGroup3 = (Literal)item.FindControl("LiteralRadioGroupAbstain"); Literal literalCheckedYes = (Literal)item.FindControl("LiteralCheckedYes"); Literal literalCheckedNo = (Literal)item.FindControl("LiteralCheckedNo"); Literal literalCheckedAbstain = (Literal)item.FindControl("LiteralCheckedAbstain"); MotionAmendment amendment = (MotionAmendment)item.DataItem; string text = amendment.Text; if (text.Length > 100) { text = text.Substring(0, 97) + "..."; } labelDesignation.Text = String.Format("{0}-{1:D3}", motionDesignations[amendment.MotionId], amendment.SequenceNumber); labelText.Text = text; string radioGroupName = "A" + amendment.Identity; literalRadioGroup1.Text = radioGroupName; literalRadioGroup2.Text = radioGroupName; literalRadioGroup3.Text = radioGroupName; Literal literalToCheck = null; string recommendationString = null; int recommendation = amendment.Identity % 3; // Read this from new table; "AmendmentVotingList" or something like that switch (recommendation) { case 0: recommendationString = "NEJ"; literalToCheck = literalCheckedNo; break; case 1: recommendationString = "JA"; literalToCheck = literalCheckedYes; break; case 2: recommendationString = "AVSTÅR"; literalToCheck = literalCheckedAbstain; break; default: throw new InvalidOperationException("This is not possible; the switch should have caught all cases."); } // literalToCheck.Text = "checked"; labelRecommended.Text = recommendationString; } }