void IXmlSerializable.ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                return;
            }

            // Move past container
            if (!reader.Read())
            {
                throw new XmlException("Error in Deserialization of Dictionary");
            }

            // reader.ReadStartElement(DictionaryNodeName);
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                reader.ReadStartElement(Map <TKey, TVal> .ItemNodeName);
                reader.ReadStartElement(Map <TKey, TVal> .KeyNodeName);
                var key = (TKey)KeySerializer.Deserialize(reader);
                reader.ReadEndElement();
                reader.ReadStartElement(Map <TKey, TVal> .ValueNodeName);
                var value = (TVal)ValueSerializer.Deserialize(reader);
                reader.ReadEndElement();
                reader.ReadEndElement();
                Add(key, value);
                reader.MoveToContent();
            }

            // reader.ReadEndElement();
            reader.ReadEndElement();             // Read End Element to close Read of containing node
        }
    /// <summary>
    /// Returns all the keys in storage.
    /// </summary>
    /// <returns></returns>
    public async Task <IEnumerable <SerializedKey> > LoadKeysAsync()
    {
        var list = new List <SerializedKey>();

        if (!_directory.Exists)
        {
            _directory.Create();
        }

        var files = _directory.GetFiles(KeyFilePrefix + "*" + KeyFileExtension);

        foreach (var file in files)
        {
            var id = file.Name.Substring(4);
            try
            {
                using (var reader = new StreamReader(file.OpenRead()))
                {
                    var json = await reader.ReadToEndAsync();

                    var item = KeySerializer.Deserialize <SerializedKey>(json);
                    list.Add(item);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error reading file: " + file.Name);
            }
        }

        return(list);
    }
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                return;
            }

            if (!reader.Read())
            {
                throw new System.Xml.XmlException("Error in Deserialization of Dictionary");
            }

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                reader.ReadStartElement(ItemNodeName);
                reader.ReadStartElement(KeyNodeName);
                TKey key = (TKey)KeySerializer.Deserialize(reader);
                reader.ReadEndElement();
                reader.ReadStartElement(ValueNodeName);
                TVal value = (TVal)ValueSerializer.Deserialize(reader);
                reader.ReadEndElement();
                reader.ReadEndElement();
                Add(key, value);
                reader.MoveToContent();
            }

            reader.ReadEndElement();
        }
Beispiel #4
0
        void IXmlSerializable.ReadXml(XmlReader i_Reader)
        {
            if (i_Reader.IsEmptyElement)
            {
                return;
            }

            // Move past container
            if (!i_Reader.Read())
            {
                throw new XmlException("Error in Deserialization of Dictionary");
            }

            while (i_Reader.NodeType != XmlNodeType.EndElement)
            {
                i_Reader.ReadStartElement(k_ItemNodeName);
                i_Reader.ReadStartElement(k_KeyNodeName);
                TKey key = (TKey)KeySerializer.Deserialize(i_Reader);
                i_Reader.ReadEndElement();
                i_Reader.ReadStartElement(k_ValueNodeName);
                TVal value = (TVal)ValueSerializer.Deserialize(i_Reader);
                i_Reader.ReadEndElement();
                i_Reader.ReadEndElement();
                this.Add(key, value);
                i_Reader.MoveToContent();
            }
            //reader.ReadEndElement();

            i_Reader.ReadEndElement(); // Read End Element to close Read of containing node
        }
        void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                return;
            }
            if (!reader.Read())
            {
                throw new XmlException("Error in Deserialization of Dictionary");
            }

            //HERE IS THE TRICK
            if (reader is KnownTypesXmlReader)
            {
                SetKnownTypes(((KnownTypesXmlReader)reader).ExtraTypes);
            }

            //reader.ReadStartElement(DictionaryNodeName);
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                reader.ReadStartElement(ItemNodeName);
                reader.ReadStartElement(KeyNodeName);
                TKey key = (TKey)KeySerializer.Deserialize(reader);
                reader.ReadEndElement();
                reader.ReadStartElement(ValueNodeName);
                TVal value = (TVal)ValueSerializer.Deserialize(reader);
                reader.ReadEndElement();
                reader.ReadEndElement();
                this.Add(key, value);
                reader.MoveToContent();
            }
            //reader.ReadEndElement();

            reader.ReadEndElement();             // Read End Element to close Read of containing node
        }
Beispiel #6
0
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized.</param>
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            bool wasEmpty = reader.IsEmptyElement;

            reader.Read();

            if (wasEmpty)
            {
                return;
            }

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                reader.ReadStartElement(keyItem);


                reader.ReadStartElement(keyKey);
                var key = (TKey)KeySerializer.Deserialize(reader);
                reader.ReadEndElement();

                reader.ReadStartElement(keyValue);
                var value = (TValue)ValueSerializer.Deserialize(reader);
                reader.ReadEndElement();

                Add(key, value);

                reader.ReadEndElement();
                reader.MoveToContent();
            }
            reader.ReadEndElement();
        }
 /// <exception cref="ArgumentNullException">any argument is null</exception>
 public CipherFormPresenter(ICipherForm cipherForm,
                            IList <FileSystemEntity> inputFileEntities,
                            IRsaFactory rsaFactory,
                            KeySerializer keySerializer,
                            ICommandsContainer commandsContainer,
                            IFileUnifier fileUnifier,
                            IEnvironmentHelper environmentHelper,
                            IMessageHelper messageHelper,
                            Options options)
 {
     Checker.CheckNull(cipherForm, keySerializer, commandsContainer);
     this.cipherForm                   = cipherForm;
     this.inputFileEntities            = inputFileEntities;
     this.rsaFactory                   = rsaFactory;
     this.keySerializer                = keySerializer;
     this.commandsContainer            = commandsContainer;
     this.fileUnifier                  = fileUnifier;
     this.environmentHelper            = environmentHelper;
     this.messageHelper                = messageHelper;
     this.options                      = options;
     cipherForm.InputFileEntities      = inputFileEntities;
     cipherForm.TotalLength            = GetTotalLength();
     cipherForm.OutputFileName         = GetOutputFileName();
     cipherForm.ZipСompression         = options.ZipСompression;
     cipherForm.Cipher                += cipherForm_Cipher;
     cipherForm.CancelCipher          += cipherForm_CancelCipher;
     cipherForm.OutputFileNameChanged += cipherForm_OutputFileNameChanged;
     cipherForm.PublicKeyChanged      += cipherForm_PublicKeyChanged;
 }
Beispiel #8
0
        public Task <Message <TKey, TValue> > ProduceAsync(string topic, TKey key, TValue val, DateTime?timestamp = null, int?partition = null, bool blockIfQueueFull = true)
        {
            var handler = new TypedTaskDeliveryHandlerShim(key, val);

            producer.ProduceAsync(topic, KeySerializer?.Serialize(key), ValueSerializer?.Serialize(val), handler, timestamp, partition, blockIfQueueFull);
            return(handler.Task);
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new instance of <see cref="EntityToSerialize"/>.
        /// </summary>
        /// <param name="entity">The entity itself.</param>
        /// <param name="resourceType">The type of the entity.</param>
        /// <param name="resourceSetWrapper">The resource set the entity belongs to.</param>
        /// <param name="provider">The wrapper for the current service provider.</param>
        /// <param name="absoluteServiceUri">The absolute service URI.</param>
        /// <returns>The new instance of <see cref="EntityToSerialize"/></returns>
        internal static EntityToSerialize Create(object entity, ResourceType resourceType, ResourceSetWrapper resourceSetWrapper, DataServiceProviderWrapper provider, Uri absoluteServiceUri)
        {
            Debug.Assert(provider != null, "provider != null");
            Debug.Assert(provider.DataService != null, "provider.DataService != null");
            Debug.Assert(provider.DataService.Configuration != null, "provider.DataService.Configuration != null");
            Debug.Assert(provider.DataService.Configuration.DataServiceBehavior != null,
                         "provider.DataService.Configuration.DataServiceBehavior != null");

            KeySerializer keySerializer = KeySerializer.Create(provider.DataService.Configuration.DataServiceBehavior.GenerateKeyAsSegment);

            Func <ResourceProperty, object> getPropertyValue = p =>
            {
                object keyValue = WebUtil.GetPropertyValue(provider, entity, resourceType, p, null);
                if (keyValue == null)
                {
                    throw new InvalidOperationException(Service.Strings.Serializer_NullKeysAreNotSupported(p.Name));
                }

                return(keyValue);
            };

            bool includeTypeSegment = resourceSetWrapper.ResourceType != resourceType;

            return(Create(entity, resourceType, resourceSetWrapper.Name, includeTypeSegment, getPropertyValue, keySerializer, absoluteServiceUri));
        }
 /// <summary>Generates an object from its XML representation.</summary>
 /// <param name="reader">
 ///     The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized.
 /// </param>
 void IXmlSerializable.ReadXml(XmlReader reader)
 {
     if (reader.IsEmptyElement)
     {
         return;
     }
     // Move past container
     if (reader.NodeType == XmlNodeType.Element && !reader.Read())
     {
         throw new XmlException("Error in Deserialization of SerializableDictionary");
     }
     while (reader.NodeType != XmlNodeType.EndElement)
     {
         var key   = (TKey)KeySerializer.Deserialize(reader);
         var value = (TVal)ValueSerializer.Deserialize(reader);
         Add(key, value);
         reader.MoveToContent();
     }
     // Move past container
     if (reader.NodeType == XmlNodeType.EndElement)
     {
         reader.ReadEndElement();
     }
     else
     {
         throw new XmlException("Error in Deserialization of SerializableDictionary");
     }
 }
Beispiel #11
0
    void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
    {
        if (reader.IsEmptyElement)
        {
            return;
        }

        // Move past container
        if (!reader.Read())
        {
            throw new XmlException("Error in Deserialization of Dictionary");
        }

        //reader.ReadStartElement(DictionaryNodeName);
        while (reader.NodeType != XmlNodeType.EndElement)
        {
            reader.ReadStartElement(ItemNodeName);
            reader.ReadStartElement(KeyNodeName);
            TKey key = (TKey)KeySerializer.Deserialize(reader);
            reader.ReadEndElement();
            reader.ReadStartElement(ValueNodeName);
            TVal valor = (TVal)ValueSerializer.Deserialize(reader);
            reader.ReadEndElement();
            reader.ReadEndElement();
            this.Add(key, valor);
            reader.MoveToContent();
        }
        //reader.ReadEndElement();

        reader.ReadEndElement();     // Read End Element to close Read of containing node
        //Debug.Log("IXmlSerializable.ReadXml");
    }
Beispiel #12
0
        private void Produce(string topic, TKey key, TValue val, DateTime?timestamp, int partition, bool blockIfQueueFull, IDeliveryHandler <TKey, TValue> deliveryHandler)
        {
            var handler  = new TypedDeliveryHandlerShim(key, val, deliveryHandler);
            var keyBytes = KeySerializer?.Serialize(key);
            var valBytes = ValueSerializer?.Serialize(val);

            producer.Produce(topic, valBytes, 0, valBytes == null ? 0 : valBytes.Length, keyBytes, 0, keyBytes == null ? 0 : keyBytes.Length, timestamp, partition, blockIfQueueFull, handler);
        }
 /// <summary>Converts an object into its XML representation.</summary>
 /// <param name="writer">
 ///     The <see cref="T:System.Xml.XmlWriter"/> stream to which the object is serialized.
 /// </param>
 void IXmlSerializable.WriteXml(XmlWriter writer)
 {
     foreach (KeyValuePair <TKey, TVal> pair in this)
     {
         KeySerializer.Serialize(writer, pair.Key);
         ValueSerializer.Serialize(writer, pair.Value);
     }
 }
Beispiel #14
0
 /// <summary>
 /// Returns an enumerator that iterates through the collection.
 /// </summary>
 /// <returns>
 /// An enumerator that can be used to iterate through the collection.
 /// </returns>
 public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator()
 {
     foreach (var hashKey in RedisDb.HashKeys(RedisKey))
     {
         var redisValue = RedisDb.HashGet(RedisKey, hashKey);
         yield return(new KeyValuePair <TKey, TValue>(KeySerializer.Deserialize <TKey>(hashKey), ValueSerializer.Deserialize <TValue>(redisValue)));
     }
 }
Beispiel #15
0
        public virtual async Task <ISet <TItem> > GetValueOrEmptyAsync(TKey key)
        {
            var setMap = (ISetMap <TKey, TItem>)Map;
            var items  = await setMap.GetValueOrEmptyAsync(key);

            await Scope.AddKeyAsync(Identifier, KeySerializer.Serialize(key)).ConfigureAwait(false);

            return(_removeOnEmptySet ? new SetWrapper(key, items, _scope, Identifier, _keySerializer) : items);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="serviceBaseUri">The base URI of the service. This will be used as the base URI for all entity containers.</param>
        /// <param name="urlConvention">The specific url convention to use.</param>
        internal ODataConventionalUriBuilder(Uri serviceBaseUri, UrlConvention urlConvention)
        {
            Debug.Assert(serviceBaseUri != null && serviceBaseUri.IsAbsoluteUri, "serviceBaseUri != null && serviceBaseUri.IsAbsoluteUri");
            Debug.Assert(urlConvention != null, "urlConvention != null");

            this.serviceBaseUri = serviceBaseUri;
            this.urlConvention = urlConvention;
            this.keySerializer = KeySerializer.Create(this.urlConvention);
        }
Beispiel #17
0
        public void Serialize_should_return_bytes_from_guid()
        {
            var sut = new KeySerializer <Guid>();

            var expectedGuid = Guid.NewGuid();
            var result       = sut.Serialize(expectedGuid, default);

            result.Should().BeEquivalentTo(expectedGuid.ToByteArray());
        }
Beispiel #18
0
 public AesManaged GetAesManaged()
 {
     if (aesManaged == null)
     {
         aesManaged     = new AesManaged();
         aesManaged.IV  = KeySerializer.StringToByteArray(IV);
         aesManaged.Key = KeySerializer.StringToByteArray(Key);
     }
     return(aesManaged);
 }
 public void SetUp()
 {
     decipherForm      = new Mock <IDecipherForm>();
     rsaFactory        = new Mock <IRsaFactory>();
     keySerializer     = new KeySerializer(new BigNumberHexSerializer());
     environmentHelper = new Mock <IEnvironmentHelper>();
     messageHelper     = new Mock <IMessageHelper>();
     commandsContainer = new Mock <ICommandsContainer>();
     fileUnifier       = new Mock <IFileUnifier>();
 }
        public void Init()
        {
            this.keyProperty1 = new ResourceProperty("Key1", ResourcePropertyKind.Key | ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(string)));
            this.keyProperty2 = new ResourceProperty("Key2", ResourcePropertyKind.Key | ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(int)));

            this.defaultSerializer = KeySerializer.Create(UrlConvention.CreateWithExplicitValue(false));
            this.segmentSerializer = KeySerializer.Create(UrlConvention.CreateWithExplicitValue(true));

            this.singleKeyProperty = new[] { this.keyProperty1 };
            this.compositeKey = new[] { this.keyProperty1, this.keyProperty2 };
        }
        public void Init()
        {
            this.keyProperty1 = new ResourceProperty("Key1", ResourcePropertyKind.Key | ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(string)));
            this.keyProperty2 = new ResourceProperty("Key2", ResourcePropertyKind.Key | ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(int)));

            this.defaultSerializer = KeySerializer.Create(false);
            this.segmentSerializer = KeySerializer.Create(true);

            this.singleKeyProperty = new[] { this.keyProperty1 };
            this.compositeKey      = new[] { this.keyProperty1, this.keyProperty2 };
        }
Beispiel #22
0
 public SerializedKey Protect(RsaKeyContainer key)
 {
     ProtectWasCalled = true;
     return(new SerializedKey
     {
         Id = key.Id,
         KeyType = key.KeyType,
         Created = DateTime.UtcNow,
         Data = KeySerializer.Serialize(key),
     });
 }
Beispiel #23
0
        public void Serialize_should_return_json_bytes_from_class()
        {
            var sut = new KeySerializer <DummyMessage>();

            var message      = DummyMessage.New();
            var jsonMessage  = JsonSerializer.Serialize(message);
            var expectedData = Encoding.UTF8.GetBytes(jsonMessage);

            var result = sut.Serialize(message, default);

            result.Should().BeEquivalentTo(expectedData);
        }
Beispiel #24
0
 /// <summary>
 /// Gets or sets the <see cref="TValue"/> with the specified key.
 /// </summary>
 /// <value>
 /// The <see cref="TValue"/>.
 /// </value>
 /// <param name="key">The key.</param>
 /// <returns></returns>
 public TValue this[TKey key]
 {
     get
     {
         var redisValue = RedisDb.HashGet(RedisKey, KeySerializer.Serialize(key));
         return(redisValue.IsNull ? default(TValue) : ValueSerializer.Deserialize <TValue>(redisValue));
     }
     set
     {
         Add(key, value);
     }
 }
Beispiel #25
0
        /// <summary>
        /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1" /> to an <see cref="T:System.Array" />, starting at a particular <see cref="T:System.Array" /> index.
        /// </summary>
        /// <param name="array">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.ICollection`1" />. The <see cref="T:System.Array" /> must have zero-based indexing.</param>
        /// <param name="arrayIndex">The zero-based index in <paramref name="array" /> at which copying begins.</param>
        public void CopyTo(KeyValuePair <TKey, TValue>[] array, int arrayIndex)
        {
            var values = RedisDb.HashGetAll(RedisKey);

            for (var i = 0; i < values.Length; i++)
            {
                var key   = KeySerializer.Deserialize <TKey>(values[i].Name);
                var value = ValueSerializer.Deserialize <TValue>(values[i].Value);

                array[i + arrayIndex] = new KeyValuePair <TKey, TValue>(key, value);
            }
        }
Beispiel #26
0
 public SerializedKey Protect(KeyContainer key)
 {
     ProtectWasCalled = true;
     return(new SerializedKey
     {
         Id = key.Id,
         Algorithm = key.Algorithm,
         IsX509Certificate = key.HasX509Certificate,
         Created = DateTime.UtcNow,
         Data = KeySerializer.Serialize(key),
     });
 }
 void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer)
 {
     foreach (System.Collections.Generic.KeyValuePair <TKey, TVal> kvp in this)
     {
         writer.WriteStartElement(ItemNodeName);
         writer.WriteStartElement(KeyNodeName);
         KeySerializer.Serialize(writer, kvp.Key);
         writer.WriteEndElement();
         writer.WriteStartElement(ValueNodeName);
         ValueSerializer.Serialize(writer, kvp.Value);
         writer.WriteEndElement();
         writer.WriteEndElement();
     }
 }
 void IXmlSerializable.WriteXml(XmlWriter writer)
 {
     foreach (var kvp in this)
     {
         writer.WriteStartElement(ItemNodeName);
         writer.WriteStartElement(KeyNodeName);
         KeySerializer.Serialize(writer, kvp.Key);
         writer.WriteEndElement();
         writer.WriteStartElement(ValueNodeName);
         ValueSerializer.Serialize(writer, kvp.Value);
         writer.WriteEndElement();
         writer.WriteEndElement();
     }
 }
Beispiel #29
0
 void IXmlSerializable.WriteXml(XmlWriter i_Writer)
 {
     //writer.WriteStartElement(DictionaryNodeName);
     foreach (KeyValuePair <TKey, TVal> kvp in this)
     {
         i_Writer.WriteStartElement(k_ItemNodeName);
         i_Writer.WriteStartElement(k_KeyNodeName);
         KeySerializer.Serialize(i_Writer, kvp.Key);
         i_Writer.WriteEndElement();
         i_Writer.WriteStartElement(k_ValueNodeName);
         ValueSerializer.Serialize(i_Writer, kvp.Value);
         i_Writer.WriteEndElement();
         i_Writer.WriteEndElement();
     }
 }
    /// <summary>
    /// Persists new key in storage.
    /// </summary>
    /// <param name="key"></param>
    /// <returns></returns>
    public Task StoreKeyAsync(SerializedKey key)
    {
        if (!_directory.Exists)
        {
            _directory.Create();
        }

        var json = KeySerializer.Serialize(key);

        var path = Path.Combine(_directory.FullName, KeyFilePrefix + key.Id + KeyFileExtension);

        File.WriteAllText(path, json, Encoding.UTF8);

        return(Task.CompletedTask);
    }
 void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer)
 {
     //writer.WriteStartElement(DictionaryNodeName);
     foreach (KeyValuePair <TKey, TVal> kvp in this)
     {
         writer.WriteStartElement(ItemNodeName);
         writer.WriteStartElement(KeyNodeName);
         KeySerializer.Serialize(writer, kvp.Key);
         writer.WriteEndElement();
         writer.WriteStartElement(ValueNodeName);
         ValueSerializer.Serialize(writer, kvp.Value);
         writer.WriteEndElement();
         writer.WriteEndElement();
     }
     //writer.WriteEndElement();
 }
Beispiel #32
0
        public void Execute()
        {
            var file = filesView.SelectedFile;

            if (!CheckFile(file))
            {
                throw new InvalidOperationException("Selected file is null or is not rsa.");
            }
            using (var form = formFactory.CreateDecipherForm()) {
                form.InputFileName = file.FullName;
                var serializer = new KeySerializer(new BigNumberHexSerializer());
                new DecipherFormPresenter(form, rsaFactory, serializer, commandsContainer, file, environmentHelper, messageHelper,
                                          fileUnifier);
                form.ShowDialog();
            }
        }
Beispiel #33
0
        /// <summary>
        /// Creates a new instance of <see cref="EntityToSerialize"/>.
        /// </summary>
        /// <param name="entity">The entity itself.</param>
        /// <param name="resourceType">The type of the entity.</param>
        /// <param name="resourceSetName">Name of the resource set the entity belongs to.</param>
        /// <param name="includeTypeSegment">if set to <c>true</c> then the type segment should be included in the edit link.</param>
        /// <param name="getPropertyValue">The callback to get each property value.</param>
        /// <param name="keySerializer">The key serializer to use.</param>
        /// <param name="absoluteServiceUri">The absolute service URI.</param>
        /// <returns>The new instance of <see cref="EntityToSerialize"/>.</returns>
        internal static EntityToSerialize Create(object entity, ResourceType resourceType, string resourceSetName,  bool includeTypeSegment, Func<ResourceProperty, object> getPropertyValue, KeySerializer keySerializer, Uri absoluteServiceUri)
        {
            Debug.Assert(!string.IsNullOrEmpty(resourceSetName), "container name must be specified");
            Debug.Assert(absoluteServiceUri != null && absoluteServiceUri.IsAbsoluteUri, "absoluteServiceUri != null && absoluteServiceUri.IsAbsoluteUri");

            string editLinkSuffix = null;
            if (includeTypeSegment)
            {
                editLinkSuffix = resourceType.FullName;
            }

            SerializedEntityKey serializedKey = LazySerializedEntityKey.Create(keySerializer, absoluteServiceUri, resourceSetName, resourceType.KeyProperties, getPropertyValue, editLinkSuffix);

            return CreateFromExplicitValues(entity, resourceType, serializedKey);
        }
 /// <summary>
 /// Creates an instance of <see cref="SerializedEntityKey"/> for the given properties and values.
 /// </summary>
 /// <param name="keySerializer">The key serializer to use.</param>
 /// <param name="absoluteServiceUri">The absolute service URI.</param>
 /// <param name="entitySetName">Name of the entity set.</param>
 /// <param name="keyProperties">The key properties.</param>
 /// <param name="getPropertyValue">The callback to get each property's value.</param>
 /// <param name="editLinkSuffix">The suffix to append to the edit-link, or null.</param>
 /// <returns>A serialized-key instance.</returns>
 internal static SerializedEntityKey Create(
     KeySerializer keySerializer, 
     Uri absoluteServiceUri,
     string entitySetName, 
     ICollection<ResourceProperty> keyProperties,
     Func<ResourceProperty, object> getPropertyValue, 
     string editLinkSuffix)
 {
     SimpleLazy<string> lazyRelativeIdentity = new SimpleLazy<string>(() =>
     {
         var builder = new StringBuilder();
         builder.Append(entitySetName);
         keySerializer.AppendKeyExpression(builder, keyProperties, p => p.Name, getPropertyValue);
         return builder.ToString();
     });
         
     return new LazySerializedEntityKey(lazyRelativeIdentity, absoluteServiceUri, editLinkSuffix);
 }