Exemple #1
0
        public void UpdateDataTypes(IEnumerable <int> dataTypeIds, Func <int, PublishedContentType> getContentType)
        {
            var lockInfo = new WriteLockInfo();

            try
            {
                Lock(lockInfo);

                var contentTypes = _contentTypesById
                                   .Where(kvp =>
                                          kvp.Value.Value != null &&
                                          kvp.Value.Value.PropertyTypes.Any(p => dataTypeIds.Contains(p.DataType.Id)))
                                   .Select(kvp => kvp.Value.Value)
                                   .Select(x => getContentType(x.Id))
                                   .Where(x => x != null) // poof, gone, very unlikely and probably an anomaly
                                   .ToArray();

                var contentTypeIdsA  = contentTypes.Select(x => x.Id).ToArray();
                var contentTypeNodes = new Dictionary <int, List <int> >();
                foreach (var id in contentTypeIdsA)
                {
                    contentTypeNodes[id] = new List <int>();
                }
                foreach (var link in _contentNodes.Values)
                {
                    var node = link.Value;
                    if (node != null && contentTypeIdsA.Contains(node.ContentType.Id))
                    {
                        contentTypeNodes[node.ContentType.Id].Add(node.Id);
                    }
                }

                foreach (var contentType in contentTypes)
                {
                    // again, weird situation
                    if (contentTypeNodes.ContainsKey(contentType.Id) == false)
                    {
                        continue;
                    }

                    foreach (var id in contentTypeNodes[contentType.Id])
                    {
                        _contentNodes.TryGetValue(id, out LinkedNode <ContentNode> link);
                        if (link?.Value == null)
                        {
                            continue;
                        }
                        var node = new ContentNode(link.Value, contentType, _publishedSnapshotAccessor, _variationContextAccessor);
                        SetValueLocked(_contentNodes, id, node);
                        if (_localDb != null)
                        {
                            RegisterChange(id, node.ToKit());
                        }
                    }
                }
            }
            finally
            {
                Release(lockInfo);
            }
        }
 private PublishedMember(IMember member, ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
     : base(contentNode, contentData, publishedSnapshotAccessor, variationContextAccessor)
 {
     _member = member;
 }