Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntityToSerialize"/> class.
        /// </summary>
        /// <param name="entity">The entity itself.</param>
        /// <param name="resourceType">The type of the entity.</param>
        /// <param name="serializedKey">The serialized entity key for the instance.</param>
        private EntityToSerialize(object entity, ResourceType resourceType, SerializedEntityKey serializedKey)
        {
            Debug.Assert(entity != null, "resource != null");
            Debug.Assert(resourceType != null && resourceType.ResourceTypeKind == ResourceTypeKind.EntityType, "resourceType != null && resourceType.ResourceTypeKind == ResourceTypeKind.EntityType");
            Debug.Assert(serializedKey != null, "serializedKey != null");

            this.entity = entity;
            this.resourceType = resourceType;
            this.serializedEntityKey = serializedKey;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntityToSerialize"/> class.
        /// </summary>
        /// <param name="entity">The entity itself.</param>
        /// <param name="resourceType">The type of the entity.</param>
        /// <param name="serializedKey">The serialized entity key for the instance.</param>
        private EntityToSerialize(object entity, ResourceType resourceType, SerializedEntityKey serializedKey)
        {
            Debug.Assert(entity != null, "resource != null");
            Debug.Assert(resourceType != null && resourceType.ResourceTypeKind == ResourceTypeKind.EntityType, "resourceType != null && resourceType.ResourceTypeKind == ResourceTypeKind.EntityType");
            Debug.Assert(serializedKey != null, "serializedKey != null");

            this.entity              = entity;
            this.resourceType        = resourceType;
            this.serializedEntityKey = serializedKey;
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of <see cref="EntityToSerialize"/>. Should only be used from other Create methods or from unit tests.
 /// </summary>
 /// <param name="entity">The entity itself.</param>
 /// <param name="resourceType">The type of the entity.</param>
 /// <param name="serializedKey">The serialized key of the entity.</param>
 /// <returns>The new instance of <see cref="EntityToSerialize"/>.</returns>
 internal static EntityToSerialize CreateFromExplicitValues(object entity, ResourceType resourceType, SerializedEntityKey serializedKey)
 {
     return new EntityToSerialize(entity, resourceType, serializedKey);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of <see cref="EntityToSerialize"/>. Should only be used from other Create methods or from unit tests.
 /// </summary>
 /// <param name="entity">The entity itself.</param>
 /// <param name="resourceType">The type of the entity.</param>
 /// <param name="serializedKey">The serialized key of the entity.</param>
 /// <returns>The new instance of <see cref="EntityToSerialize"/>.</returns>
 internal static EntityToSerialize CreateFromExplicitValues(object entity, ResourceType resourceType, SerializedEntityKey serializedKey)
 {
     return(new EntityToSerialize(entity, resourceType, serializedKey));
 }