Beispiel #1
0
        /// <summary>
        /// Resets the format behavior of the current writer behavior to the default format behavior.
        /// </summary>
        internal void UseDefaultFormatBehavior()
        {
            this.formatBehaviorKind = ODataBehaviorKind.Default;

            // Also reset all format knobs
            this.allowNullValuesForNonNullablePrimitiveTypes = false;
            this.allowDuplicatePropertyNames = false;
        }
        /// <summary>
        /// Resets the format behavior of the current reader behavior to the default format behavior.
        /// </summary>
        internal void ResetFormatBehavior()
        {
            this.formatBehaviorKind = ODataBehaviorKind.Default;

            // Also reset all format knobs
            this.allowDuplicatePropertyNames = false;
            this.operationsBoundToEntityTypeMustBeContainerQualified = null;
        }
Beispiel #3
0
 internal void ResetFormatBehavior()
 {
     this.formatBehaviorKind          = ODataBehaviorKind.Default;
     this.allowDuplicatePropertyNames = false;
     this.usesV1Provider = false;
     this.odataNamespace = "http://schemas.microsoft.com/ado/2007/08/dataservices";
     this.typeScheme     = "http://schemas.microsoft.com/ado/2007/08/dataservices/scheme";
 }
Beispiel #4
0
 internal void ResetFormatBehavior()
 {
     this.formatBehaviorKind = ODataBehaviorKind.Default;
     this.allowDuplicatePropertyNames = false;
     this.usesV1Provider = false;
     this.odataNamespace = "http://schemas.microsoft.com/ado/2007/08/dataservices";
     this.typeScheme = "http://schemas.microsoft.com/ado/2007/08/dataservices/scheme";
 }
        /// <summary>
        /// Resets the format behavior of the current reader behavior to the default format behavior.
        /// </summary>
        internal void ResetFormatBehavior()
        {
            DebugUtils.CheckNoExternalCallers();
            this.formatBehaviorKind = ODataBehaviorKind.Default;

            // Also reset all format knobs
            this.allowDuplicatePropertyNames = false;
            this.usesV1Provider = false;
            this.odataNamespace = Atom.AtomConstants.ODataNamespace;
            this.typeScheme     = Atom.AtomConstants.ODataSchemeNamespace;
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="formatBehaviorKind">The format behavior kind of this behavior.</param>
 /// <param name="apiBehaviorKind">The API behavior kind of this behavior.</param>
 /// <param name="allowNullValuesForNonNullablePrimitiveTypes">
 /// true to allow null values for non-nullable primitive types; otherwise false.
 /// </param>
 /// <param name="allowDuplicatePropertyNames">
 /// If set to true, allows the writers to write duplicate properties of entries 
 /// and complex values (i.e., properties that have the same name).
 /// </param>
 private ODataWriterBehavior(
     ODataBehaviorKind formatBehaviorKind,
     ODataBehaviorKind apiBehaviorKind,
     bool allowNullValuesForNonNullablePrimitiveTypes,
     bool allowDuplicatePropertyNames)
 {
     this.formatBehaviorKind = formatBehaviorKind;
     this.apiBehaviorKind = apiBehaviorKind;
     this.allowNullValuesForNonNullablePrimitiveTypes = allowNullValuesForNonNullablePrimitiveTypes;
     this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="formatBehaviorKind">The format behavior kind of this behavior.</param>
 /// <param name="apiBehaviorKind">The API behavior kind of this behavior.</param>
 /// <param name="allowDuplicatePropertyNames">
 /// If set to true, allows the writers to write duplicate properties of entries and
 /// complex values (i.e., properties that have the same name). Defaults to 'false'.
 /// </param>
 /// <param name="typeResolver">Custom type resolver which takes both expected type and type name.
 /// This function is used instead of the IEdmModel.FindType is it's specified.
 /// The first parameter to the function is the expected type (the type infered from the parent property or specified by the external caller).
 /// The second parameter is the type name from the payload.
 /// The function should return the resolved type, or null if no such type was found.</param>
 private ODataReaderBehavior(
     ODataBehaviorKind formatBehaviorKind,
     ODataBehaviorKind apiBehaviorKind,
     bool allowDuplicatePropertyNames,
     Func <IEdmType, string, IEdmType> typeResolver)
 {
     this.formatBehaviorKind          = formatBehaviorKind;
     this.apiBehaviorKind             = apiBehaviorKind;
     this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
     this.typeResolver = typeResolver;
 }
Beispiel #8
0
 private ODataReaderBehavior(ODataBehaviorKind formatBehaviorKind, ODataBehaviorKind apiBehaviorKind, bool allowDuplicatePropertyNames, bool usesV1Provider, Func <IEdmType, string, IEdmType> typeResolver, string odataNamespace, string typeScheme, Func <ODataEntry, XmlReader, Uri, XmlReader> entryXmlCustomizationCallback)
 {
     this.formatBehaviorKind          = formatBehaviorKind;
     this.apiBehaviorKind             = apiBehaviorKind;
     this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
     this.usesV1Provider = usesV1Provider;
     this.typeResolver   = typeResolver;
     this.entryXmlCustomizationCallback = entryXmlCustomizationCallback;
     this.odataNamespace = odataNamespace;
     this.typeScheme     = typeScheme;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="formatBehaviorKind">The format behavior kind of this behavior.</param>
 /// <param name="apiBehaviorKind">The API behavior kind of this behavior.</param>
 /// <param name="allowDuplicatePropertyNames">
 /// If set to true, allows the writers to write duplicate properties of entries and 
 /// complex values (i.e., properties that have the same name). Defaults to 'false'.
 /// </param>
 /// <param name="typeResolver">Custom type resolver which takes both expected type and type name.
 /// This function is used instead of the IEdmModel.FindType is it's specified.
 /// The first parameter to the function is the expected type (the type infered from the parent property or specified by the external caller).
 /// The second parameter is the type name from the payload.
 /// The function should return the resolved type, or null if no such type was found.</param>
 private ODataReaderBehavior(
     ODataBehaviorKind formatBehaviorKind,
     ODataBehaviorKind apiBehaviorKind,
     bool allowDuplicatePropertyNames,
     Func<IEdmType, string, IEdmType> typeResolver)
 {
     this.formatBehaviorKind = formatBehaviorKind;
     this.apiBehaviorKind = apiBehaviorKind;
     this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
     this.typeResolver = typeResolver;
 }
Beispiel #10
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="formatBehaviorKind">The format behavior kind of this behavior.</param>
 /// <param name="apiBehaviorKind">The API behavior kind of this behavior.</param>
 /// <param name="allowNullValuesForNonNullablePrimitiveTypes">
 /// true to allow null values for non-nullable primitive types; otherwise false.
 /// </param>
 /// <param name="allowDuplicatePropertyNames">
 /// If set to true, allows the writers to write duplicate properties of entries
 /// and complex values (i.e., properties that have the same name).
 /// </param>
 private ODataWriterBehavior(
     ODataBehaviorKind formatBehaviorKind,
     ODataBehaviorKind apiBehaviorKind,
     bool allowNullValuesForNonNullablePrimitiveTypes,
     bool allowDuplicatePropertyNames)
 {
     this.formatBehaviorKind = formatBehaviorKind;
     this.apiBehaviorKind    = apiBehaviorKind;
     this.allowNullValuesForNonNullablePrimitiveTypes = allowNullValuesForNonNullablePrimitiveTypes;
     this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
 }
Beispiel #11
0
 private ODataReaderBehavior(ODataBehaviorKind formatBehaviorKind, ODataBehaviorKind apiBehaviorKind, bool allowDuplicatePropertyNames, bool usesV1Provider, Func<IEdmType, string, IEdmType> typeResolver, string odataNamespace, string typeScheme, Func<ODataEntry, XmlReader, Uri, XmlReader> entryXmlCustomizationCallback)
 {
     this.formatBehaviorKind = formatBehaviorKind;
     this.apiBehaviorKind = apiBehaviorKind;
     this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
     this.usesV1Provider = usesV1Provider;
     this.typeResolver = typeResolver;
     this.entryXmlCustomizationCallback = entryXmlCustomizationCallback;
     this.odataNamespace = odataNamespace;
     this.typeScheme = typeScheme;
 }
 private ODataWriterBehavior(ODataBehaviorKind formatBehaviorKind, ODataBehaviorKind apiBehaviorKind, bool usesV1Provider, bool allowNullValuesForNonNullablePrimitiveTypes, bool allowDuplicatePropertyNames, Func <ODataEntry, XmlWriter, XmlWriter> startEntryXmlCustomizationCallback, Action <ODataEntry, XmlWriter, XmlWriter> endEntryXmlCustomizationCallback, string odataNamespace, string typeScheme)
 {
     this.formatBehaviorKind = formatBehaviorKind;
     this.apiBehaviorKind    = apiBehaviorKind;
     this.usesV1Provider     = usesV1Provider;
     this.allowNullValuesForNonNullablePrimitiveTypes = allowNullValuesForNonNullablePrimitiveTypes;
     this.allowDuplicatePropertyNames        = allowDuplicatePropertyNames;
     this.startEntryXmlCustomizationCallback = startEntryXmlCustomizationCallback;
     this.endEntryXmlCustomizationCallback   = endEntryXmlCustomizationCallback;
     this.odataNamespace = odataNamespace;
     this.typeScheme     = typeScheme;
 }
Beispiel #13
0
 private ODataWriterBehavior(ODataBehaviorKind formatBehaviorKind, ODataBehaviorKind apiBehaviorKind, bool usesV1Provider, bool allowNullValuesForNonNullablePrimitiveTypes, bool allowDuplicatePropertyNames, Func<ODataEntry, XmlWriter, XmlWriter> startEntryXmlCustomizationCallback, Action<ODataEntry, XmlWriter, XmlWriter> endEntryXmlCustomizationCallback, string odataNamespace, string typeScheme)
 {
     this.formatBehaviorKind = formatBehaviorKind;
     this.apiBehaviorKind = apiBehaviorKind;
     this.usesV1Provider = usesV1Provider;
     this.allowNullValuesForNonNullablePrimitiveTypes = allowNullValuesForNonNullablePrimitiveTypes;
     this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
     this.startEntryXmlCustomizationCallback = startEntryXmlCustomizationCallback;
     this.endEntryXmlCustomizationCallback = endEntryXmlCustomizationCallback;
     this.odataNamespace = odataNamespace;
     this.typeScheme = typeScheme;
 }
Beispiel #14
0
        /// <summary>
        /// Creates a new media type resolver for readers with the mappings for the specified version and behavior kind.
        /// </summary>
        /// <param name="version">The version used to read the payload.</param>
        /// <param name="formatBehaviorKind">The format behavior kind used.</param>
        private MediaTypeResolver(ODataVersion version, ODataBehaviorKind formatBehaviorKind)
            : this(version)
        {
            DebugUtils.CheckNoExternalCallers();

            if (this.version < ODataVersion.V3)
            {
                if (formatBehaviorKind == ODataBehaviorKind.WcfDataServicesClient)
                {
                    this.AddV2ClientMediaTypes();
                }
            }
        }
Beispiel #15
0
        private void CompareReaderBehavior(
            ODataMessageReaderSettings settings,
            ODataBehaviorKind formatBehaviorKind,
            ODataBehaviorKind apiBehaviorKind,
            bool allowDuplicatePropertyNames,
            Func <IEdmType, string, IEdmType> typeResolver)
        {
            ODataReaderBehavior readerBehavior = settings.ReaderBehavior;

            Assert.AreEqual(formatBehaviorKind, readerBehavior.FormatBehaviorKind, "Reader format behavior kinds don't match.");
            Assert.AreEqual(apiBehaviorKind, readerBehavior.ApiBehaviorKind, "Reader API behavior kinds don't match.");
            Assert.AreEqual(allowDuplicatePropertyNames, readerBehavior.AllowDuplicatePropertyNames, "AllowDuplicatePropertyNames values don't match.");
            Assert.AreSame(typeResolver, readerBehavior.TypeResolver, "TypeResolver values don't match.");
        }
        private void AssertWriterBehavior(
            ODataBehaviorKind formatBehaviorKind,
            ODataBehaviorKind apiBehaviorKind,
            bool useV1ProviderBehavior,
            bool allowNullValuesForNonNullablePrimitiveTypes,
            bool allowDuplicatePropertyNames)
        {
            var writerBehavior = this.settings.WriterBehavior;

            formatBehaviorKind.Should().Be(writerBehavior.FormatBehaviorKind);
            apiBehaviorKind.Should().Be(writerBehavior.ApiBehaviorKind);
            allowNullValuesForNonNullablePrimitiveTypes.Should().Be(writerBehavior.AllowNullValuesForNonNullablePrimitiveTypes);
            allowDuplicatePropertyNames.Should().Be(writerBehavior.AllowDuplicatePropertyNames);
        }
Beispiel #17
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="formatBehaviorKind">The format behavior kind of this behavior.</param>
        /// <param name="apiBehaviorKind">The API behavior kind of this behavior.</param>
        /// <param name="usesV1Provider">true if the server uses a V1 provider; otherwise false.</param>
        /// <param name="allowNullValuesForNonNullablePrimitiveTypes">
        /// true to allow null values for non-nullable primitive types; otherwise false.
        /// </param>
        /// <param name="allowDuplicatePropertyNames">
        /// If set to true, allows the writers to write duplicate properties of entries
        /// and complex values (i.e., properties that have the same name).
        /// </param>
        /// <param name="odataNamespace">Custom data namespace.</param>
        /// <param name="typeScheme">Custom type scheme to use when resolving types.</param>
        private ODataWriterBehavior(
            ODataBehaviorKind formatBehaviorKind,
            ODataBehaviorKind apiBehaviorKind,
            bool usesV1Provider,
            bool allowNullValuesForNonNullablePrimitiveTypes,
            bool allowDuplicatePropertyNames,
            string odataNamespace,
            string typeScheme)
        {
            DebugUtils.CheckNoExternalCallers();

            this.formatBehaviorKind = formatBehaviorKind;
            this.apiBehaviorKind    = apiBehaviorKind;
            this.usesV1Provider     = usesV1Provider;
            this.allowNullValuesForNonNullablePrimitiveTypes = allowNullValuesForNonNullablePrimitiveTypes;
            this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
            this.odataNamespace = odataNamespace;
            this.typeScheme     = typeScheme;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="formatBehaviorKind">The format behavior kind of this behavior.</param>
        /// <param name="apiBehaviorKind">The API behavior kind of this behavior.</param>
        /// <param name="usesV1Provider">true if the server uses a V1 provider; otherwise false.</param>
        /// <param name="allowNullValuesForNonNullablePrimitiveTypes">
        /// true to allow null values for non-nullable primitive types; otherwise false.
        /// </param>
        /// <param name="allowDuplicatePropertyNames">
        /// If set to true, allows the writers to write duplicate properties of entries 
        /// and complex values (i.e., properties that have the same name).
        /// </param>
        /// <param name="odataNamespace">Custom data namespace.</param>
        /// <param name="typeScheme">Custom type scheme to use when resolving types.</param>
        private ODataWriterBehavior(
            ODataBehaviorKind formatBehaviorKind,
            ODataBehaviorKind apiBehaviorKind,
            bool usesV1Provider,
            bool allowNullValuesForNonNullablePrimitiveTypes,
            bool allowDuplicatePropertyNames,
            string odataNamespace,
            string typeScheme)
        {
            DebugUtils.CheckNoExternalCallers();

            this.formatBehaviorKind = formatBehaviorKind;
            this.apiBehaviorKind = apiBehaviorKind;
            this.usesV1Provider = usesV1Provider;
            this.allowNullValuesForNonNullablePrimitiveTypes = allowNullValuesForNonNullablePrimitiveTypes;
            this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
            this.odataNamespace = odataNamespace;
            this.typeScheme = typeScheme;
        }
Beispiel #19
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="formatBehaviorKind">The format behavior kind of this behavior.</param>
        /// <param name="apiBehaviorKind">The API behavior kind of this behavior.</param>
        /// <param name="allowDuplicatePropertyNames">
        /// If set to true, allows the writers to write duplicate properties of entries and
        /// complex values (i.e., properties that have the same name). Defaults to 'false'.
        /// </param>
        /// <param name="usesV1Provider">true if the server uses a V1 provider; otherwise false.</param>
        /// <param name="typeResolver">Custom type resolver which takes both expected type and type name.
        /// This function is used instead of the IEdmModel.FindType is it's specified.
        /// The first parameter to the function is the expected type (the type infered from the parent property or specified by the external caller).
        /// The second parameter is the type name from the payload.
        /// The function should return the resolved type, or null if no such type was found.</param>
        /// <param name="odataNamespace">Custom data namespace.</param>
        /// <param name="typeScheme">Custom type scheme to use when resolving types.</param>
        private ODataReaderBehavior(
            ODataBehaviorKind formatBehaviorKind,
            ODataBehaviorKind apiBehaviorKind,
            bool allowDuplicatePropertyNames,
            bool usesV1Provider,
            Func <IEdmType, string, IEdmType> typeResolver,
            string odataNamespace,
            string typeScheme)
        {
            DebugUtils.CheckNoExternalCallers();

            this.formatBehaviorKind          = formatBehaviorKind;
            this.apiBehaviorKind             = apiBehaviorKind;
            this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
            this.usesV1Provider = usesV1Provider;
            this.typeResolver   = typeResolver;

            // set the default values for data namespace and type scheme
            this.odataNamespace = odataNamespace;
            this.typeScheme     = typeScheme;
        }
Beispiel #20
0
 /// <summary>
 /// Creates a new media type resolver for readers with the mappings for the specified version and behavior kind.
 /// </summary>
 /// <param name="version">The version used to read the payload.</param>
 /// <param name="formatBehaviorKind">The format behavior kind used.</param>
 /// <returns>A new media type resolver for readers with the mappings for the specified version and behavior kind.</returns>
 internal static MediaTypeResolver CreateReaderMediaTypeResolver(ODataVersion version, ODataBehaviorKind formatBehaviorKind)
 {
     DebugUtils.CheckNoExternalCallers();
     return(new MediaTypeResolver(version, formatBehaviorKind));
 }
        /// <summary>
        /// Resets the format behavior of the current writer behavior to the default format behavior.
        /// </summary>
        internal void UseDefaultFormatBehavior()
        {
            this.formatBehaviorKind = ODataBehaviorKind.Default;

            // Also reset all format knobs
            this.allowNullValuesForNonNullablePrimitiveTypes = false;
            this.allowDuplicatePropertyNames = false;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="formatBehaviorKind">The format behavior kind of this behavior.</param>
        /// <param name="apiBehaviorKind">The API behavior kind of this behavior.</param>
        /// <param name="allowDuplicatePropertyNames">
        /// If set to true, allows the writers to write duplicate properties of entries and 
        /// complex values (i.e., properties that have the same name). Defaults to 'false'.
        /// </param>
        /// <param name="usesV1Provider">true if the server uses a V1 provider; otherwise false.</param>
        /// <param name="typeResolver">Custom type resolver which takes both expected type and type name.
        /// This function is used instead of the IEdmModel.FindType is it's specified.
        /// The first parameter to the function is the expected type (the type infered from the parent property or specified by the external caller).
        /// The second parameter is the type name from the payload.
        /// The function should return the resolved type, or null if no such type was found.</param>
        /// <param name="odataNamespace">Custom data namespace.</param>
        /// <param name="typeScheme">Custom type scheme to use when resolving types.</param>
        private ODataReaderBehavior(
            ODataBehaviorKind formatBehaviorKind,
            ODataBehaviorKind apiBehaviorKind,
            bool allowDuplicatePropertyNames,
            bool usesV1Provider,
            Func<IEdmType, string, IEdmType> typeResolver,
            string odataNamespace,
            string typeScheme)
        {
            DebugUtils.CheckNoExternalCallers();

            this.formatBehaviorKind = formatBehaviorKind;
            this.apiBehaviorKind = apiBehaviorKind;
            this.allowDuplicatePropertyNames = allowDuplicatePropertyNames;
            this.usesV1Provider = usesV1Provider;
            this.typeResolver = typeResolver;

            // set the default values for data namespace and type scheme
            this.odataNamespace = odataNamespace;
            this.typeScheme = typeScheme;
        }
        private void AssertWriterBehavior(
            ODataBehaviorKind formatBehaviorKind,
            ODataBehaviorKind apiBehaviorKind,
            bool useV1ProviderBehavior,
            bool allowNullValuesForNonNullablePrimitiveTypes,
            bool allowDuplicatePropertyNames)
        {
            var writerBehavior = this.settings.WriterBehavior;

            formatBehaviorKind.Should().Be(writerBehavior.FormatBehaviorKind);
            apiBehaviorKind.Should().Be(writerBehavior.ApiBehaviorKind);
            allowNullValuesForNonNullablePrimitiveTypes.Should().Be(writerBehavior.AllowNullValuesForNonNullablePrimitiveTypes);
            allowDuplicatePropertyNames.Should().Be(writerBehavior.AllowDuplicatePropertyNames);
        }
        /// <summary>
        /// Resets the format behavior of the current writer behavior to the default format behavior.
        /// </summary>
        internal void UseDefaultFormatBehavior()
        {
            DebugUtils.CheckNoExternalCallers();
            this.formatBehaviorKind = ODataBehaviorKind.Default;

            // Also reset all format knobs
            this.usesV1Provider = false;
            this.allowNullValuesForNonNullablePrimitiveTypes = false;
            this.allowDuplicatePropertyNames = false;
            this.odataNamespace = Atom.AtomConstants.ODataNamespace;
            this.typeScheme = Atom.AtomConstants.ODataSchemeNamespace;
        }
        /// <summary>
        /// Resets the format behavior of the current reader behavior to the default format behavior.
        /// </summary>
        internal void ResetFormatBehavior()
        {
            this.formatBehaviorKind = ODataBehaviorKind.Default;

            // Also reset all format knobs
            this.allowDuplicatePropertyNames = false;
            this.operationsBoundToEntityTypeMustBeContainerQualified = null;
        }
        private void CompareReaderBehavior(
            ODataMessageReaderSettings settings,
            ODataBehaviorKind formatBehaviorKind,
            ODataBehaviorKind apiBehaviorKind,
            bool allowDuplicatePropertyNames,
            Func<IEdmType, string, IEdmType> typeResolver)
        {
            ODataReaderBehavior readerBehavior = settings.ReaderBehavior;

            Assert.AreEqual(formatBehaviorKind, readerBehavior.FormatBehaviorKind, "Reader format behavior kinds don't match.");
            Assert.AreEqual(apiBehaviorKind, readerBehavior.ApiBehaviorKind, "Reader API behavior kinds don't match.");
            Assert.AreEqual(allowDuplicatePropertyNames, readerBehavior.AllowDuplicatePropertyNames, "AllowDuplicatePropertyNames values don't match.");
            Assert.AreSame(typeResolver, readerBehavior.TypeResolver, "TypeResolver values don't match.");
        }