Ejemplo n.º 1
0
        public static Organizations FromArray(BasicOrganization[] organizationArray)
        {
            var result = new Organizations {
                Capacity = (organizationArray.Length * 11 / 10)
            };

            foreach (BasicOrganization basic in organizationArray)
            {
                result.Add(Organization.FromBasic(basic));
            }

            return(result);
        }
Ejemplo n.º 2
0
        public Organizations GetMasterOrganizations()
        {
            if (Identity == Organization.UPSEid || Inherits(Organization.UPSEid))
            {
                // HACK: Hardcoded

                return(Organizations.FromSingle(FromIdentity(Organization.PPSEid)));
            }
            else
            {
                return(new Organizations());
            }
        }
Ejemplo n.º 3
0
        public static Organizations FromArray(Organization[] organizationArray)
        {
            var result = new Organizations {
                Capacity = (organizationArray.Length * 11 / 10)
            };

            foreach (Organization organization in organizationArray)
            {
                result.Add(organization);
            }

            return(result);
        }
Ejemplo n.º 4
0
        public bool Inherits(int prospectiveParentOrganizationId)
        {
            // Returns true if prospectiveParent is a parent of ours.

            Organizations line = GetLine();

            for (int index = 0; index < line.Count - 1; index++)
            {
                if (line[index].Identity == prospectiveParentOrganizationId)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        public static Organizations LogicalOr(Organizations set1, Organizations set2)
        {
            // If either set is invalid, return the other
            // (a null is different from an empty set)

            if (set1 == null)
            {
                return(set2);
            }

            if (set2 == null)
            {
                return(set1);
            }

            // Build table, eliminating duplicates

            var table = new Dictionary <int, Organization>();

            foreach (Organization org in set1)
            {
                table[org.Identity] = org;
            }

            foreach (Organization org in set2)
            {
                table[org.Identity] = org;
            }

            // Assemble result

            var result = new Organizations();

            foreach (Organization org in table.Values)
            {
                result.Add(org);
            }

            return(result);
        }
Ejemplo n.º 6
0
        public static Organizations LogicalAnd(Organizations set1, Organizations set2)
        {
            // If either set is invalid, return the other
            // (a null is different from an empty set)

            if (set1 == null)
            {
                return(set2);
            }

            if (set2 == null)
            {
                return(set1);
            }

            var set2Lookup = new Dictionary <int, bool>();

            // Build set2's lookup table

            foreach (Organization org in set2)
            {
                set2Lookup[org.Identity] = true;
            }

            // Build result

            var result = new Organizations();

            foreach (Organization org in set1)
            {
                if (set2Lookup.ContainsKey(org.Identity))
                {
                    result.Add(org);
                }
            }

            return(result);
        }
Ejemplo n.º 7
0
 public Organizations GetTree()
 {
     return(Organizations.FromArray(OrganizationCache.GetOrganizationTree(Identity)));
     //return Organizations.FromArray(SwarmDb.GetDatabaseForReading().GetOrganizationTree(Identity));
 }
Ejemplo n.º 8
0
 public Organizations LogicalOr(Organizations set2)
 {
     return(LogicalOr(this, set2));
 }