// Convert ObjectTypes to DSOP_DOWNLEVEL_FLAGS
        private uint GetDownLevelFilter()
        {
            uint downlevelFilter = 0;

            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.Users))
            {
                downlevelFilter |= DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_USERS;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.Groups))
            {
                downlevelFilter |= DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_LOCAL_GROUPS |
                                   DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_GLOBAL_GROUPS;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.Computers))
            {
                downlevelFilter |= DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_COMPUTERS;
            }
            // Contacts not available in downlevel scopes
            //if ((allowedTypes & ObjectTypes.Contacts) == ObjectTypes.Contacts)
            // Exclude build in groups if not selected
            if ((AllowedObjectTypes & ObjectTypes.BuiltInGroups) == 0)
            {
                downlevelFilter |= DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_EXCLUDE_BUILTIN_GROUPS;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.WellKnownPrincipals))
            {
                downlevelFilter |= DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_ALL_WELLKNOWN_SIDS;
                // This includes all the following:
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_WORLD |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_AUTHENTICATED_USER |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_ANONYMOUS |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_BATCH |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_CREATOR_OWNER |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_CREATOR_GROUP |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_DIALUP |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_INTERACTIVE |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_NETWORK |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_SERVICE |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_SYSTEM |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_TERMINAL_SERVER |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_LOCAL_SERVICE |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_NETWORK_SERVICE |
                //DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_REMOTE_LOGON;
            }
            return(downlevelFilter);
        }
        // Convert ObjectTypes to DSOP_FILTER_FLAGS_FLAGS
        private uint GetUpLevelFilter()
        {
            uint uplevelFilter = 0;

            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.Users))
            {
                uplevelFilter |= DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_USERS;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.Groups))
            {
                uplevelFilter |= DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_UNIVERSAL_GROUPS_DL |
                                 DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_UNIVERSAL_GROUPS_SE |
                                 DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_GLOBAL_GROUPS_DL |
                                 DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_GLOBAL_GROUPS_SE |
                                 DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_DOMAIN_LOCAL_GROUPS_DL |
                                 DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_DOMAIN_LOCAL_GROUPS_SE;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.Computers))
            {
                uplevelFilter |= DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_COMPUTERS;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.Contacts))
            {
                uplevelFilter |= DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_CONTACTS;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.BuiltInGroups))
            {
                uplevelFilter |= DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_BUILTIN_GROUPS;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.WellKnownPrincipals))
            {
                uplevelFilter |= DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_WELL_KNOWN_PRINCIPALS;
            }
            if (AllowedObjectTypes.IsFlagSet(ObjectTypes.ServiceAccounts))
            {
                uplevelFilter |= DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_SERVICE_ACCOUNTS;
            }
            if (ShowAdvancedView)
            {
                uplevelFilter |= DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_INCLUDE_ADVANCED_VIEW;
            }
            return(uplevelFilter);
        }
 public void FilterHits(List <GameObjectRayHit> hits)
 {
     hits.RemoveAll(item => !AllowedObjectTypes.Contains(item.HitObject.GetGameObjectType()) ||
                    IgnoreObjects.Contains(item.HitObject) || !LayerEx.IsLayerBitSet(_layerMask, item.HitObject.layer));
 }
 public void FilterOverlaps(List <GameObject> gameObjects)
 {
     gameObjects.RemoveAll(item => !AllowedObjectTypes.Contains(item.GetGameObjectType()) ||
                           IgnoreObjects.Contains(item) || !LayerEx.IsLayerBitSet(_layerMask, item.layer));
 }
        public override int GetHashCode()
        {
            int hashCode = 1892852076;

            if (Type != null)
            {
                hashCode += Type.GetHashCode();
            }

            if (Name != null)
            {
                hashCode += Name.GetHashCode();
            }

            if (Description != null)
            {
                hashCode += Description.GetHashCode();
            }

            if (SourceApplication != null)
            {
                hashCode += SourceApplication.GetHashCode();
            }

            if (AllowedObjectTypes != null)
            {
                hashCode += AllowedObjectTypes.GetHashCode();
            }

            if (SellerVisibility != null)
            {
                hashCode += SellerVisibility.GetHashCode();
            }

            if (AppVisibility != null)
            {
                hashCode += AppVisibility.GetHashCode();
            }

            if (StringConfig != null)
            {
                hashCode += StringConfig.GetHashCode();
            }

            if (NumberConfig != null)
            {
                hashCode += NumberConfig.GetHashCode();
            }

            if (SelectionConfig != null)
            {
                hashCode += SelectionConfig.GetHashCode();
            }

            if (CustomAttributeUsageCount != null)
            {
                hashCode += CustomAttributeUsageCount.GetHashCode();
            }

            if (Key != null)
            {
                hashCode += Key.GetHashCode();
            }

            return(hashCode);
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is CatalogCustomAttributeDefinition other &&
                   ((Type == null && other.Type == null) || (Type?.Equals(other.Type) == true)) &&
                   ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) &&
                   ((Description == null && other.Description == null) || (Description?.Equals(other.Description) == true)) &&
                   ((SourceApplication == null && other.SourceApplication == null) || (SourceApplication?.Equals(other.SourceApplication) == true)) &&
                   ((AllowedObjectTypes == null && other.AllowedObjectTypes == null) || (AllowedObjectTypes?.Equals(other.AllowedObjectTypes) == true)) &&
                   ((SellerVisibility == null && other.SellerVisibility == null) || (SellerVisibility?.Equals(other.SellerVisibility) == true)) &&
                   ((AppVisibility == null && other.AppVisibility == null) || (AppVisibility?.Equals(other.AppVisibility) == true)) &&
                   ((StringConfig == null && other.StringConfig == null) || (StringConfig?.Equals(other.StringConfig) == true)) &&
                   ((NumberConfig == null && other.NumberConfig == null) || (NumberConfig?.Equals(other.NumberConfig) == true)) &&
                   ((SelectionConfig == null && other.SelectionConfig == null) || (SelectionConfig?.Equals(other.SelectionConfig) == true)) &&
                   ((CustomAttributeUsageCount == null && other.CustomAttributeUsageCount == null) || (CustomAttributeUsageCount?.Equals(other.CustomAttributeUsageCount) == true)) &&
                   ((Key == null && other.Key == null) || (Key?.Equals(other.Key) == true)));
        }