private static ObjectType GetObjectTypeForObject(IHasIdentity objectToIdentify)
        {
            //string objectTypeString = objectToIdentify.GetType().ToString();

            //// Strip namespace

            //int lastPeriodIndex = objectTypeString.LastIndexOf('.');
            //objectTypeString = objectTypeString.Substring(lastPeriodIndex + 1);

            string objectTypeString = objectToIdentify.GetType().Name;

            // At this point, we should be able to cast the string to an ObjectType enum
            try
            {
                return((ObjectType)Enum.Parse(typeof(ObjectType), objectTypeString));
            }
            catch
            {
                //That failed. This could be a subclass, try upwards.
                Type parentType = objectToIdentify.GetType().BaseType;
                while (parentType != typeof(Object))
                {
                    try
                    {
                        return((ObjectType)Enum.Parse(typeof(ObjectType), parentType.Name));
                    }
                    catch
                    {
                        parentType = parentType.BaseType;
                    }
                }
            }
            throw new InvalidCastException("GetObjectTypeForObject could not identify object of type " +
                                           objectToIdentify.GetType().Name);
        }
示例#2
0
        private static string GetObjectDetails(IHasIdentity identifiableObject)
        {
            switch (identifiableObject.GetType().Name)
            {
            case "ExpenseClaim":
                ExpenseClaim claim = (ExpenseClaim)identifiableObject;

                return("<strong>" +
                       String.Format(Global.Financial_ExpenseClaimLongSpecification, claim.Identity) +
                       ":</strong> " + claim.Organization.Currency.Code + " " +
                       (claim.AmountCents / 100.0).ToString("N2") + ". " +
                       HttpUtility.HtmlEncode(GetValidationDetails(claim.Validations)) + " " +
                       GetDocumentDetails(claim.Documents, claim));

            case "CashAdvance":
                CashAdvance advance = (CashAdvance)identifiableObject;

                return("<strong>" +
                       String.Format(Global.Financial_CashAdvanceSpecification, advance.Identity) +
                       ":</strong> " + advance.Organization.Currency.Code + " " +
                       (advance.AmountCents / 100.0).ToString("N2") + ". " +
                       HttpUtility.HtmlEncode(GetValidationDetails(advance.Validations)));

            case "InboundInvoice":
                InboundInvoice invoice = (InboundInvoice)identifiableObject;

                return("<strong>" +
                       String.Format(Global.Financial_InboundInvoiceSpecification, invoice.Identity) +
                       ":</strong> " + invoice.Organization.Currency.Code + " " +
                       (invoice.AmountCents / 100.0).ToString("N2") + ". " +
                       GetValidationDetails(invoice.Validations) + " " +
                       GetDocumentDetails(invoice.Documents, invoice));

            case "Salary":
                Salary salary = (Salary)identifiableObject;

                return("<strong>" +
                       String.Format(Global.Financial_SalaryIdentity, salary.Identity) +
                       ":</strong> " +
                       String.Format(Resources.Pages.Ledgers.InspectLedgers_TxDetail_SalaryDetail,
                                     salary.PayrollItem.Organization.Currency.Code,
                                     salary.BaseSalaryCents / 100.0,                             // base salary
                                     (salary.GrossSalaryCents - salary.BaseSalaryCents) / 100.0, // before-tax adjustments
                                     salary.GrossSalaryCents / 100.0,                            // before-tax adjusted salary
                                     salary.SubtractiveTaxCents / 100.0,                         // tax deduction
                                     (salary.NetSalaryCents + salary.SubtractiveTaxCents -
                                      salary.GrossSalaryCents) / 100.0,                          // after-tax adjustments
                                     salary.NetSalaryCents / 100.0) +                            // actual payout amount
                       " " + GetValidationDetails(salary.Validations));

            default:
                throw new NotImplementedException("Unhandled object type in GetObjectDetails: " +
                                                  identifiableObject.GetType().Name);
            }
        }
        static private FinancialDependencyType GetFinancialDependencyType(IHasIdentity foreignObject)
        {
            if (foreignObject is ExpenseClaim)
            {
                return(FinancialDependencyType.ExpenseClaim);
            }
            else if (foreignObject is InboundInvoice)
            {
                return(FinancialDependencyType.InboundInvoice);
            }
            else if (foreignObject is OutboundInvoice)
            {
                return(FinancialDependencyType.OutboundInvoice);
            }
            else if (foreignObject is Salary)
            {
                return(FinancialDependencyType.Salary);
            }
            else if (foreignObject is Payout)
            {
                return(FinancialDependencyType.Payout);
            }
            else if (foreignObject is PaymentGroup)
            {
                return(FinancialDependencyType.PaymentGroup);
            }
            else if (foreignObject is FinancialTransaction)
            {
                return(FinancialDependencyType.FinancialTransaction);
            }

            throw new NotImplementedException("Unidentified dependency encountered in GetFinancialDependencyType:" +
                                              foreignObject.GetType().ToString());
        }
示例#4
0
        internal static object FromBasic(IHasIdentity basic)
        {
            MethodInfo basicConverterMethod = null;
            Type       basicType            = basic.GetType();

            if (_converterLookup.ContainsKey(basicType))
            {
                basicConverterMethod = _converterLookup[basicType];
            }
            else
            {
                Assembly logicAssembly = typeof(SingularFactory).Assembly;
                Assembly basicAssembly = typeof(BasicPerson).Assembly;

                System.Type[] logicTypes =
                    logicAssembly.GetTypes().Where(type => type.IsSubclassOf(basicType)).ToArray();

                if (logicTypes.Length > 1)
                {
                    throw new InvalidOperationException("More than one type in Swarmops.Logic derives from " +
                                                        basicType.ToString());
                }
                if (logicTypes.Length == 0)
                {
                    // There are no matching types in Swarmops.Logic; look through registered assemblies

                    foreach (Assembly foreignAssembly in _assemblyLookup.Values)
                    {
                        logicTypes = foreignAssembly.GetTypes().Where(type => type.IsSubclassOf(basicType)).ToArray();
                        if (logicTypes.Length == 1)
                        {
                            break;
                        }
                    }

                    if (logicTypes.Length == 0)
                    {
                        throw new InvalidOperationException(
                                  "Unable to find higher-order class for base type " + basicType.ToString() + "; if it's in a plugin, was the higher-order assembly registered with SingularFactory?");
                    }
                }

                Type logicType = logicTypes[0];

                basicConverterMethod = logicType.GetMethod("FromBasic", BindingFlags.Static | BindingFlags.Public);

                if (basicConverterMethod == null)
                {
                    throw new InvalidOperationException(
                              "Unable to find a public static method named \"" + logicType.ToString() + ".FromBasic (" + basicType.ToString() + ")\" in a loaded assembly");
                }

                _converterLookup[basicType] = basicConverterMethod;
            }

            object result = basicConverterMethod.Invoke(null, new object[] { basic });

            return(result);
        }
示例#5
0
        public void CreateAffectedObject (IHasIdentity affectedObject)
        {
            string className = affectedObject.GetType().ToString();
            int dotIndex = className.LastIndexOf('.');

            className = className.Substring(dotIndex + 1); // assumes there's always at least one dot in a class name
            

            SwarmDb.GetDatabaseForWriting().CreateSwarmopsLogEntryAffectedObject(this.Identity, className, affectedObject.Identity);
        }
示例#6
0
        public void CreateAffectedObject(IHasIdentity affectedObject)
        {
            string className = affectedObject.GetType().ToString();
            int    dotIndex  = className.LastIndexOf('.');

            className = className.Substring(dotIndex + 1); // assumes there's always at least one dot in a class name


            SwarmDb.GetDatabaseForWriting().CreateSwarmopsLogEntryAffectedObject(this.Identity, className, affectedObject.Identity);
        }
示例#7
0
        private static FinancialDependencyType GetDependencyType(IHasIdentity foreignObject)
        {
            if (foreignObject is ExpenseClaim)
            {
                return(FinancialDependencyType.ExpenseClaim);
            }
            if (foreignObject is InboundInvoice)
            {
                return(FinancialDependencyType.InboundInvoice);
            }

            throw new NotImplementedException("Unimplemented dependency type:" + foreignObject.GetType());
        }
示例#8
0
        private static string GetForeignTypeString(IHasIdentity foreignObject)
        {
            string typeString = "";

            foreach (object attribute in foreignObject.GetType().GetCustomAttributes(typeof(DbRecordType), true))
            {
                if (attribute is DbRecordType)
                {
                    typeString = ((DbRecordType)attribute).TypeName;
                }
            }
            if (typeString == "")
            {
                typeString = foreignObject.GetType().ToString();

                if (typeString.Contains("."))
                {
                    int periodIndex = typeString.LastIndexOf('.');
                    typeString = typeString.Substring(periodIndex + 1);
                }
            }

            return(typeString);
        }
示例#9
0
        private static string GetDocumentDetails(Documents documents, IHasIdentity identifiableObject)
        {
            string docLink        = string.Empty;
            string objectIdString = identifiableObject.GetType().Name + identifiableObject.Identity;

            foreach (Document document in documents)
            {
                docLink += "<a href='/Pages/v5/Support/StreamUpload.aspx?DocId=" + document.Identity +
                           "' class='FancyBox_Gallery' rel='" + objectIdString + "'>&nbsp;</a>";
            }

            return("Documents were uploaded by " + documents[0].UploadedByPerson.Canonical + " at " +
                   documents[0].UploadedDateTime.ToString("yyyy-MMM-dd HH:mm") +
                   ". <a href='#' class='linkViewDox' objectId='" + objectIdString +
                   "'>View documents.</a><span class='hiddenDocLinks'>" + docLink + "</span>");
        }
示例#10
0
        public static object FromBasic(IHasIdentity basic)
        {
            // ASSUMPTION: We're assuming that the type to be created exists in the "Logic" assembly, and that we can bind permanently in a lookup

            MethodInfo basicConverterMethod = null;
            Type       basicType            = basic.GetType();

            if (_converterLookup.ContainsKey(basicType))
            {
                basicConverterMethod = _converterLookup[basicType];
            }
            else
            {
                Assembly logicAssembly = typeof(SingularFactory).Assembly;
                Assembly basicAssembly = typeof(BasicPerson).Assembly;

                System.Type[] logicTypes =
                    logicAssembly.GetTypes().Where(type => type.IsSubclassOf(basicType)).ToArray();

                if (logicTypes.Length > 1)
                {
                    throw new InvalidOperationException("More than one type in Swarmops.Logic derives from " +
                                                        basicType.ToString());
                }
                if (logicTypes.Length == 0)
                {
                    throw new InvalidOperationException(
                              "Unable to find higher-order class in Swarmops.Logic for base type " + basicType.ToString());
                }

                Type logicType = logicTypes[0];

                basicConverterMethod = logicType.GetMethod("FromBasic", BindingFlags.Static | BindingFlags.Public);

                if (basicConverterMethod == null)
                {
                    throw new InvalidOperationException(
                              "Unable to find a public static method named \"" + logicType.ToString() + ".FromBasic (" + basicType.ToString() + ")\" in the Swarmops.Logic assembly");
                }

                _converterLookup[basicType] = basicConverterMethod;
            }

            object result = basicConverterMethod.Invoke(null, new object[] { basic });

            return(result);
        }
示例#11
0
        static FinancialDependencyType GetDependencyType(IHasIdentity foreignObject)
        {
            if (foreignObject is ExpenseClaim)
            {
                return(FinancialDependencyType.ExpenseClaim);
            }
            if (foreignObject is InboundInvoice)
            {
                return(FinancialDependencyType.InboundInvoice);
            }
            if (foreignObject is Salary)
            {
                return(FinancialDependencyType.Salary);
            }

            throw new NotImplementedException("Unknown dependency: " + foreignObject.GetType().ToString());
        }
示例#12
0
        public static DocumentType GetDocumentTypeForObject(IHasIdentity foreignObject)
        {
            if (foreignObject == null)
            {
                // docs uploaded; foreign object not yet constructed

                return(DocumentType.Unknown);
            }
            else if (foreignObject is Person)
            {
                return(DocumentType.PersonPhoto);
            }
            else if (foreignObject is ExpenseClaim)
            {
                return(DocumentType.ExpenseClaim);
            }
            else if (foreignObject is FinancialTransaction)
            {
                return(DocumentType.FinancialTransaction);
            }
            else if (foreignObject is TemporaryIdentity)
            {
                return(DocumentType.Temporary);
            }
            else if (foreignObject is InboundInvoice)
            {
                return(DocumentType.InboundInvoice);
            }
            else if (foreignObject is PaperLetter)
            {
                return(DocumentType.PaperLetter);
            }
            else if (foreignObject is ExternalActivity)
            {
                return(DocumentType.ExternalActivityPhoto);
            }
            else
            {
                throw new ArgumentException("Unrecognized foreign object type:" + foreignObject.GetType().ToString());
            }
        }
示例#13
0
        public static DocumentType GetDocumentTypeForObject (IHasIdentity foreignObject)
        {
            if (foreignObject == null)
            {
                // docs uploaded; foreign object not yet constructed

                return DocumentType.Unknown;
            }
            else if (foreignObject is Person)
            {
                return DocumentType.PersonPhoto;
            }
            else if (foreignObject is ExpenseClaim)
            {
                return DocumentType.ExpenseClaim;
            }
            else if (foreignObject is FinancialTransaction)
            {
                return DocumentType.FinancialTransaction;
            }
            else if (foreignObject is TemporaryIdentity)
            {
                return DocumentType.Temporary;
            }
            else if (foreignObject is InboundInvoice)
            {
                return DocumentType.InboundInvoice;
            }
            else if (foreignObject is PaperLetter)
            {
                return DocumentType.PaperLetter;
            }
            else if (foreignObject is ExternalActivity)
            {
                return DocumentType.ExternalActivityPhoto;
            }
            else
            {
                throw new ArgumentException("Unrecognized foreign object type:" + foreignObject.GetType().ToString());
            }
        }
示例#14
0
        public bool CanAccess(IHasIdentity identifiableObject, AccessType accessType = AccessType.Write)
        {
            // Tests if this Authority can access a certain object. Add new object types as needed by the logic.
            // This is a very general case of the CanSeePerson() function.

            PositionAssignment testAssignment = identifiableObject as PositionAssignment;

            if (testAssignment != null)
            {
                // shortcut, for now

                return(HasSystemAccess(accessType));
            }

            throw new NotImplementedException("Authority.CanAccess is not implemented for type " + identifiableObject.GetType().FullName);
        }
示例#15
0
        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);
            }
        }
示例#16
0
        static private ObjectType GetObjectTypeForObject (IHasIdentity objectToIdentify)
        {
            //string objectTypeString = objectToIdentify.GetType().ToString();

            //// Strip namespace

            //int lastPeriodIndex = objectTypeString.LastIndexOf('.');
            //objectTypeString = objectTypeString.Substring(lastPeriodIndex + 1);

            string objectTypeString = objectToIdentify.GetType().Name;

            // At this point, we should be able to cast the string to an ObjectType enum
            try
            {
                return (ObjectType)Enum.Parse(typeof(ObjectType), objectTypeString);
            }
            catch
            {
                //That failed. This could be a subclass, try upwards.
                Type parentType = objectToIdentify.GetType().BaseType; 
                while (parentType != typeof(Object))
                {
                    try
                    {
                        return (ObjectType)Enum.Parse(typeof(ObjectType), parentType.Name);
                    }
                    catch
                    {
                        parentType = parentType.BaseType;
                    }
                }
            }
            throw new InvalidCastException("GetObjectTypeForObject could not identify object of type " + objectToIdentify.GetType().Name);
        }
示例#17
0
        static private FinancialDependencyType GetFinancialDependencyType (IHasIdentity foreignObject)
        {
            if (foreignObject is ExpenseClaim)
            {
                return FinancialDependencyType.ExpenseClaim;
            }
            else if (foreignObject is InboundInvoice)
            {
                return FinancialDependencyType.InboundInvoice;
            }
            else if (foreignObject is OutboundInvoice)
            {
                return FinancialDependencyType.OutboundInvoice;
            }
            else if (foreignObject is Salary)
            {
                return FinancialDependencyType.Salary;
            }
            else if (foreignObject is Payout)
            {
                return FinancialDependencyType.Payout;
            }
            else if (foreignObject is PaymentGroup)
            {
                return FinancialDependencyType.PaymentGroup;
            }
            else if (foreignObject is FinancialTransaction)
            {
                return FinancialDependencyType.FinancialTransaction;
            }

            throw new NotImplementedException("Unidentified dependency encountered in GetFinancialDependencyType:" +
                                          foreignObject.GetType().ToString());
        }
示例#18
0
        private static string GetForeignTypeString (IHasIdentity foreignObject)
        {
            string typeString = "";
            foreach (object attribute in foreignObject.GetType().GetCustomAttributes(typeof(DbRecordType), true))
            {
                if (attribute is DbRecordType)
                {
                    typeString = ((DbRecordType)attribute).TypeName;
                }
            }
            if (typeString == "")
            {
                typeString = foreignObject.GetType().ToString();

                if (typeString.Contains("."))
                {
                    int periodIndex = typeString.LastIndexOf('.');
                    typeString = typeString.Substring(periodIndex + 1);
                }
            }

            return typeString;
        }
示例#19
0
 private static string GetForeignTypeString(IHasIdentity foreignObject)
 {
     return(GetForeignTypeString(foreignObject.GetType()));
 }
示例#20
0
        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);

            }


        }