/// <summary>Adds the null valued properties to the content section of a syndication entry</summary> /// <param name="currentRoot">Current root node</param> /// <param name="currentContent">Current collection to which property is to be added</param> private void AddNullValuesToContent(EpmNullValuedPropertyNode currentRoot, DictionaryContent currentContent) { foreach (EpmNullValuedPropertyNode node in currentRoot.Children) { bool found; DictionaryContent c = currentContent.Lookup(node.Name, out found); Debug.Assert(node.ResourceType != null, "node.ResourceType != null"); switch (node.ResourceType.ResourceTypeKind) { case ResourceTypeKind.ComplexType: if (!found) { // If a complex property is not found in content, it is either not being projected // or all of its properties are mapped and all of them have KeepInContent=false Debug.Assert(c == null, "when look up not found, c should be null."); if (node.Element != null) { Debug.Assert(node.Children.Count > 0, "If the property represented by the current node is not null, there must be children nodes."); // The complex property is not null, but some of its descendant properties are null. // We need to serialize the type name of the complex property. c = new DictionaryContent(); currentContent.Add(node.Name, node.ResourceType.FullName, c); } else { Debug.Assert(node.Children.Count == 0, "If the property represented by the current node is not null, there must not be any children node."); // The complex property is null, we write out m:null='true'. currentContent.AddNull(node.ResourceType.FullName, node.Name); } } if (c != null) { // Only add the children properties if the complex property is not null. this.AddNullValuesToContent(node, c); } break; case ResourceTypeKind.Primitive: Debug.Assert(c == null, "DictionaryContent not expected for primitive properties."); Debug.Assert(node.Element == null, "node.Element == null"); if (!found) { currentContent.AddNull(node.ResourceType.FullName, node.Name); } // if found, use the value in currentContent, we don't need to do anything here. break; case ResourceTypeKind.EntityType: Debug.Assert(false, "We cannot map navigation properties with friendly feeds."); break; } } }
/// <summary>Delegates to each of custom and syndication serializers for serializing content</summary> /// <param name="content">Content in which to write null valued properties</param> /// <param name="provider">Data Service provider used for rights verification.</param> internal void Serialize(DictionaryContent content, DataServiceProviderWrapper provider) { if (this.NeedEpmSerialization) { Debug.Assert(this.epmSyndicationSerializer != null, "ResourceType with mapping implies a valid syndication content serializer"); this.epmSyndicationSerializer.Serialize(provider); Debug.Assert(this.epmCustomSerializer != null, "ResourceType with mapping implies a valid custom content serializer"); this.epmCustomSerializer.Serialize(provider); this.nullValuedProperties.AddNullValuesToContent(content); } else { Debug.Assert(this.targetItem != null, "Must always have target content item"); this.targetItem.Authors.Add(new SyndicationPerson(null, String.Empty, null)); } }
private bool SourceHasChanged(string sourcePath, string args) { if (!File.Exists(sourcePath)) { return(true); } string hash; using (var stream = File.OpenRead(sourcePath)) { var hasher = hasherSource.Value; hash = BitConverter.ToString(hasher.ComputeHash(stream)); } var result = false; var hashKey = new DictionaryKey(sourcePath, args); var hashEntry = new DictionaryContent(); lock (hashDb) { if (!hashDb.TryGetValue(hashKey, out hashEntry)) { result = true; } else if (hashEntry.Modified) { return(true); } else { result = (hashDb[hashKey].Hash != hash); } if (result) { hashDb[hashKey] = new DictionaryContent(hash, true); } #if DEBUG Console.WriteLine("Check of file {0} resulted in {1}, key {2}, hash {3}, in db {4}", sourcePath, result, hashKey, hash, hashDbFile); #endif } return(result); }
/// <summary>Adds the null valued properties to the content section</summary> /// <param name="content">Content to which null properties are to be added</param> internal void AddNullValuesToContent(DictionaryContent content) { this.AddNullValuesToContent(this.root, content); }