public TagCfg PackTag(TagAbstract tag, StoreContext context) { var config = new TagCfg { ClassName = this.ClassName, Name = tag.Name, DisplayName = tag.DisplayName, Description = tag.Description, Format = tag.Format, Access = tag.Access, ValueType = tag.ValueType, Custom = PackTagSpecific(tag), TagsToTagsGroups = new List <TagsToTagsGroups>(), }; foreach (var tagsGroup in tag.Groups.Values) { var storedGroup = context.TagsGroups.GetOrCreate(tg => tg.Name == tagsGroup.Name); storedGroup.Name = tagsGroup.Name; storedGroup.Min = tagsGroup.Min; storedGroup.Description = tagsGroup.Description; var ttg = config.TagsToTagsGroups.FirstOrDefault(o => o.TagsGroupCfg.Name == storedGroup.Name); if (ttg == default) { ttg = context.TagsToTagsGroups.GetOrCreate(o => o.TagsGroupCfg.Name == storedGroup.Name && o.TagCfg.Id == config.Id); ttg.TagCfg = config; ttg.TagsGroupCfg = storedGroup; } config.TagsToTagsGroups.Add(ttg); } return(config); }
public TagAbstract UnpackTag(TagCfg config) { var t = UnpackTagSpecific(config.Custom); t.Name = config.Name; t.DisplayName = config.DisplayName; t.Description = config.Description; t.Format = config.Format; t.Access = config.Access; t.ValueType = config.ValueType; return(t); }