コード例 #1
0
ファイル: JsonReflectionApi.cs プロジェクト: E01D/Base
        public NamingStrategy GetContainerNamingStrategy(JsonContainerAttribute containerAttribute)
        {
            if (containerAttribute.Internal().NamingStrategyInstance == null)
            {
                if (containerAttribute.Internal().NamingStrategyType == null)
                {
                    return(null);
                }

                containerAttribute.Internal().NamingStrategyInstance = CreateNamingStrategyInstance(containerAttribute.Internal().NamingStrategyType, containerAttribute.Internal().NamingStrategyParameters);
            }

            return(containerAttribute.Internal().NamingStrategyInstance);
        }
コード例 #2
0
 /// <summary>
 /// Gets or sets a value that indicates whether to preserve object references.
 /// </summary>
 /// <value>
 ///     <c>true</c> to keep object reference; otherwise, <c>false</c>. The default is <c>false</c>.
 /// </value>
 public void IsReference(JsonContainerAttribute attribute, bool value)
 {
     attribute.Internal().IsReference = value;
 }
コード例 #3
0
 /// <summary>
 /// Gets or sets a value that indicates whether to preserve object references.
 /// </summary>
 /// <value>
 ///     <c>true</c> to keep object reference; otherwise, <c>false</c>. The default is <c>false</c>.
 /// </value>
 public bool IsReference(JsonContainerAttribute attribute)
 {
     return(attribute.Internal().IsReference ?? default(bool));
 }
コード例 #4
0
 /// <summary>
 /// The parameter list to use when constructing the <see cref="NamingStrategy"/> described by <see cref="NamingStrategyType"/>.
 /// If <c>null</c>, the default constructor is used.
 /// When non-<c>null</c>, there must be a constructor defined in the <see cref="NamingStrategy"/> that exactly matches the number,
 /// order, and type of these parameters.
 /// </summary>
 /// <example>
 /// <code>
 /// [JsonContainer(NamingStrategyType = typeof(MyNamingStrategy), NamingStrategyParameters = new object[] { 123, "Four" })]
 /// </code>
 /// </example>
 public void NamingStrategyParameters(JsonContainerAttribute attribute, object[] value)
 {
     attribute.Internal().NamingStrategyParameters = value;
     attribute.Internal().NamingStrategyInstance   = null;
 }
コード例 #5
0
 /// <summary>
 /// The parameter list to use when constructing the <see cref="NamingStrategy"/> described by <see cref="NamingStrategyType"/>.
 /// If <c>null</c>, the default constructor is used.
 /// When non-<c>null</c>, there must be a constructor defined in the <see cref="NamingStrategy"/> that exactly matches the number,
 /// order, and type of these parameters.
 /// </summary>
 /// <example>
 /// <code>
 /// [JsonContainer(NamingStrategyType = typeof(MyNamingStrategy), NamingStrategyParameters = new object[] { 123, "Four" })]
 /// </code>
 /// </example>
 public object[] NamingStrategyParameters(JsonContainerAttribute attribute)
 {
     return(attribute.Internal().NamingStrategyParameters);
 }
コード例 #6
0
 /// <summary>
 /// Gets or sets the <see cref="Type"/> of the <see cref="NamingStrategy"/>.
 /// </summary>
 /// <value>The <see cref="Type"/> of the <see cref="NamingStrategy"/>.</value>
 public void NamingStrategyType(JsonContainerAttribute attribute, Type value)
 {
     attribute.Internal().NamingStrategyType     = value;
     attribute.Internal().NamingStrategyInstance = null;
 }
コード例 #7
0
 /// <summary>
 /// Gets or sets the <see cref="Type"/> of the <see cref="NamingStrategy"/>.
 /// </summary>
 /// <value>The <see cref="Type"/> of the <see cref="NamingStrategy"/>.</value>
 public Type NamingStrategyType(JsonContainerAttribute attribute)
 {
     return(attribute.Internal().NamingStrategyType);
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonContainerAttribute"/> class with the specified container Id.
 /// </summary>
 /// <param name="id">The container Id.</param>
 public void New(JsonContainerAttribute attribute, string id)
 {
     attribute.Internal().Id = id;
 }
コード例 #9
0
 /// <summary>
 /// Gets or sets the type name handling used when serializing the collection's items.
 /// </summary>
 /// <value>The type name handling.</value>
 public void ItemTypeNameHandling(JsonContainerAttribute attribute, TypeNameHandling value)
 {
     attribute.Internal().ItemTypeNameHandling = value;
 }
コード例 #10
0
 /// <summary>
 /// Gets or sets the type name handling used when serializing the collection's items.
 /// </summary>
 /// <value>The type name handling.</value>
 public TypeNameHandling ItemTypeNameHandling(JsonContainerAttribute attribute)
 {
     return(attribute.Internal().ItemTypeNameHandling ?? default(TypeNameHandling));
 }
コード例 #11
0
 /// <summary>
 /// Gets or sets the reference loop handling used when serializing the collection's items.
 /// </summary>
 /// <value>The reference loop handling.</value>
 public void ItemReferenceLoopHandling(JsonContainerAttribute attribute, ReferenceLoopHandling value)
 {
     attribute.Internal().ItemReferenceLoopHandling = value;
 }
コード例 #12
0
 /// <summary>
 /// Gets or sets the reference loop handling used when serializing the collection's items.
 /// </summary>
 /// <value>The reference loop handling.</value>
 public ReferenceLoopHandling ItemReferenceLoopHandling(JsonContainerAttribute attribute)
 {
     return(attribute.Internal().ItemReferenceLoopHandling ?? default(ReferenceLoopHandling));
 }