コード例 #1
0
        public TypeSelectorGroup FindSubGroup(string path)
        {
            if (path.IsNullOrEmpty() || path.All(c => c == ' '))
            {
                return(this);
            }

            var splitPath = path.Split('/').ToList();
            var name      = splitPath.First();

            var subgroup = Subgroups.FirstOrAdd(group => @group.Name == name, () => new TypeSelectorGroup(name));

            if (splitPath.Count == 1)
            {
                return(subgroup);
            }

            var newPath = string.Join("/", splitPath.GetRange(1, splitPath.Count - 1).ToArray());

            return(subgroup.FindSubGroup(newPath));
        }
コード例 #2
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a OrganizationGroup.</param>
        /// <param name="IncludeCryptoHash">Whether to include the cryptograhical hash value of this object.</param>
        public virtual JObject ToJSON(Boolean Embedded = false,
                                      InfoStatus ExpandOrganizations           = InfoStatus.ShowIdOnly,
                                      InfoStatus ExpandParentGroup             = InfoStatus.ShowIdOnly,
                                      InfoStatus ExpandSubgroups               = InfoStatus.ShowIdOnly,
                                      InfoStatus ExpandAttachedFiles           = InfoStatus.ShowIdOnly,
                                      InfoStatus IncludeAttachedFileSignatures = InfoStatus.ShowIdOnly,
                                      Boolean IncludeCryptoHash = true)
        {
            var JSON = JSONObject.Create(

                Members.SafeAny() && ExpandOrganizations != InfoStatus.Hidden
                               ? ExpandSubgroups.Switch(
                    () => new JProperty("memberIds", new JArray(Members.SafeSelect(organization => organization.Id.ToString()))),
                    () => new JProperty("members", new JArray(Members.SafeSelect(organization => organization.ToJSON(Embedded: true,
                                                                                                                     //ExpandParentGroup:  InfoStatus.Hidden,
                                                                                                                     //ExpandSubgroups:    InfoStatus.Expand,
                                                                                                                     IncludeCryptoHash:  IncludeCryptoHash)))))
                               : null,

                ParentGroup != null && ExpandParentGroup != InfoStatus.Hidden
                               ? ExpandParentGroup.Switch(
                    () => new JProperty("parentGroupId", ParentGroup.Id.ToString()),
                    () => new JProperty("parentGroup", ParentGroup.ToJSON()))
                               : null,

                Subgroups.SafeAny() && ExpandSubgroups != InfoStatus.Hidden
                               ? ExpandSubgroups.Switch(
                    () => new JProperty("subgroupsIds", new JArray(Subgroups.SafeSelect(subgroup => subgroup.Id.ToString()))),
                    () => new JProperty("subgroups", new JArray(Subgroups.SafeSelect(subgroup => subgroup.ToJSON(Embedded:           true,
                                                                                                                 ExpandParentGroup:  InfoStatus.Hidden,
                                                                                                                 ExpandSubgroups:    InfoStatus.Expanded,
                                                                                                                 IncludeCryptoHash:  IncludeCryptoHash)))))
                               : null

                );

            return(JSON);
        }
コード例 #3
0
 public bool IsEmpty()
 {
     return(Subgroups.IsEmpty() && GroupTypes.IsEmpty());
 }
コード例 #4
0
 public void Add(AdaptiveSubgroup element)
 {
     Subgroups.Add(element);
     element.Parent = this;
 }