예제 #1
0
 internal static string GetEntityTypeNameForUriAndValidateMaxProtocolVersion(Type type, DataServiceContext context, ref Version uriVersion)
 {
     if (context.MaxProtocolVersionAsVersion < Util.DataServiceVersion3)
     {
         throw new NotSupportedException(Strings.ALinq_TypeAsNotSupportedForMaxDataServiceVersionLessThan3);
     }
     if (!ClientTypeUtil.TypeOrElementTypeIsEntity(type))
     {
         throw new NotSupportedException(Strings.ALinq_TypeAsArgumentNotEntityType(type.FullName));
     }
     WebUtil.RaiseVersion(ref uriVersion, Util.DataServiceVersion3);
     return(context.ResolveNameFromType(type) ?? type.FullName);
 }
예제 #2
0
파일: UriHelper.cs 프로젝트: tapika/swupd
        /// <summary>Gets the type name to be used in the URI for the given <paramref name="type"/>.</summary>
        /// <param name="type">Type to get name for.</param>
        /// <param name="context">Data context used to generate type names for types.</param>
        /// <param name="uriVersion">Data service version for the uri</param>
        /// <returns>The name for the <paramref name="type"/>, suitable for including in a URI.</returns>
        internal static string GetEntityTypeNameForUriAndValidateMaxProtocolVersion(Type type, DataServiceContext context, ref Version uriVersion)
        {
            Debug.Assert(type != null, "type != null");
            Debug.Assert(context != null, "context != null");

            if (context.MaxProtocolVersionAsVersion < Util.DataServiceVersion3)
            {
                throw new NotSupportedException(Strings.ALinq_TypeAsNotSupportedForMaxDataServiceVersionLessThan3);
            }

            if (!ClientTypeUtil.TypeOrElementTypeIsEntity(type))
            {
                throw new NotSupportedException(Strings.ALinq_TypeAsArgumentNotEntityType(type.FullName));
            }

            // Raise the uriVersion each time we write the type segment on the uri.
            WebUtil.RaiseVersion(ref uriVersion, Util.DataServiceVersion3);
            return(context.ResolveNameFromType(type) ?? type.FullName);
        }