internal void WriteOperation(ODataOperation operation)
 {
     string str;
     WriterValidationUtils.ValidateOperation(operation, base.WritingResponse);
     if (operation is ODataAction)
     {
         str = "action";
     }
     else
     {
         str = "function";
     }
     base.XmlWriter.WriteStartElement("m", str, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
     string str2 = base.UriToUrlAttributeValue(operation.Metadata, false);
     base.XmlWriter.WriteAttributeString("metadata", str2);
     if (operation.Title != null)
     {
         base.XmlWriter.WriteAttributeString("title", operation.Title);
     }
     string str3 = base.UriToUrlAttributeValue(operation.Target);
     base.XmlWriter.WriteAttributeString("target", str3);
     base.XmlWriter.WriteEndElement();
 }
Beispiel #2
0
 internal static void ValidateOperationNotNull(ODataOperation operation, bool isAction)
 {
     if (operation == null)
     {
         string str = isAction ? "ODataEntry.Actions" : "ODataEntry.Functions";
         throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_EnumerableContainsANullItem(str));
     }
 }
        /// <summary>
        /// Validates an <see cref="ODataOperation"/> to ensure all required information is specified and valid.
        /// </summary>
        /// <param name="operation">The operation (an action or a function) to validate.</param>
        /// <param name="writingResponse">true if writing a response; otherwise false.</param>
        internal static void ValidateOperation(ODataOperation operation, bool writingResponse)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(operation != null, "operation != null");

            // Operations are only valid in responses; we fail on them in requests
            if (!writingResponse)
            {
                throw new ODataException(Strings.WriterValidationUtils_OperationInRequest(operation.Metadata));
            }

            ValidationUtils.ValidateOperation(operation);
        }
Beispiel #4
0
 internal static void ValidateOperation(ODataOperation operation)
 {
     if (operation.Metadata == null)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_ActionsAndFunctionsMustSpecifyMetadata(operation.GetType().Name));
     }
     if (operation.Target == null)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_ActionsAndFunctionsMustSpecifyTarget(operation.GetType().Name));
     }
 }
Beispiel #5
0
 internal static void ValidateOperation(ODataOperation operation, bool writingResponse)
 {
     if (!writingResponse)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.WriterValidationUtils_OperationInRequest(operation.Metadata));
     }
     ValidationUtils.ValidateOperation(operation);
 }
        /// <summary>
        /// Validates an <see cref="ODataOperation"/> to ensure all required information is specified and valid.
        /// </summary>
        /// <param name="operation">The operation to validate.</param>
        internal static void ValidateOperation(ODataOperation operation)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(operation != null, "operation != null");

            // ODataOperation must have a Metadata property.
            if (operation.Metadata == null)
            {
                throw new ODataException(Strings.ValidationUtils_ActionsAndFunctionsMustSpecifyMetadata(operation.GetType().Name));
            }

            // ODataOperation must have a Target property.
            if (operation.Target == null)
            {
                throw new ODataException(Strings.ValidationUtils_ActionsAndFunctionsMustSpecifyTarget(operation.GetType().Name));
            }
        }
        /// <summary>
        /// Validates an <see cref="ODataOperation"/> to ensure it's not null.
        /// </summary>
        /// <param name="operation">The operation to ensure it's not null.</param>
        /// <param name="isAction">Whether <paramref name="operation"/> is an <see cref="ODataAction"/>.</param>
        internal static void ValidateOperationNotNull(ODataOperation operation, bool isAction)
        {
            DebugUtils.CheckNoExternalCallers();

            // null action/function can not appear in the enumeration
            if (operation == null)
            {
                string enumerableName = isAction ? "ODataEntry.Actions" : "ODataEntry.Functions";
                throw new ODataException(Strings.ValidationUtils_EnumerableContainsANullItem(enumerableName));
            }
        }
 private void WriteOperation(ODataOperation operation)
 {
     base.JsonWriter.StartObjectScope();
     if (operation.Title != null)
     {
         base.JsonWriter.WriteName("title");
         base.JsonWriter.WriteValue(operation.Title);
     }
     string str = base.UriToAbsoluteUriString(operation.Target);
     base.JsonWriter.WriteName("target");
     base.JsonWriter.WriteValue(str);
     base.JsonWriter.EndObjectScope();
 }