Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KeySegmentTemplate" /> class.
        /// </summary>
        /// <param name="segment">The key segment, it should be a template key segment.</param>
        public KeySegmentTemplate(KeySegment segment)
        {
            if (segment == null)
            {
                throw Error.ArgumentNull(nameof(segment));
            }

            NavigationSource = segment.NavigationSource;
            EntityType       = segment.EdmType as IEdmEntityType;

            KeyMappings = BuildKeyMappings(segment.Keys, EntityType);

            string routeKey = KeyMappings.BuildRouteKey();

            Literal = $"{{{routeKey}}}";
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KeySegmentTemplate" /> class.
        /// </summary>
        /// <param name="keys">The input key mappings, the key string is case-sensitive, the value string should wrapper with { and }.</param>
        /// <param name="entityType">The declaring type containes the key.</param>
        /// <param name="navigationSource">The navigation source. It could be null.</param>
        public KeySegmentTemplate(IDictionary <string, string> keys, IEdmEntityType entityType, IEdmNavigationSource navigationSource)
        {
            if (keys == null)
            {
                throw Error.ArgumentNull(nameof(keys));
            }

            EntityType       = entityType ?? throw Error.ArgumentNull(nameof(entityType));
            NavigationSource = navigationSource;

            KeyMappings = BuildKeyMappings(keys.Select(kvp => new KeyValuePair <string, object>(kvp.Key, kvp.Value)), entityType);

            string routeKey = KeyMappings.BuildRouteKey();

            Literal = $"{{{routeKey}}}";
        }