зеркало из https://github.com/stride3d/SharpYaml.git
Added Descriptor Category in ITypeDescriptor.
This commit is contained in:
Родитель
8b082839bb
Коммит
4ea5071ea4
|
@ -0,0 +1,87 @@
|
||||||
|
// Copyright (c) 2015 SharpYaml - Alexandre Mutel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// -------------------------------------------------------------------------------
|
||||||
|
// SharpYaml is a fork of YamlDotNet https://github.com/aaubry/YamlDotNet
|
||||||
|
// published with the following license:
|
||||||
|
// -------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2008, 2009, 2010, 2011, 2012 Antoine Aubry
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
// this software and associated documentation files (the "Software"), to deal in
|
||||||
|
// the Software without restriction, including without limitation the rights to
|
||||||
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
// so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
namespace SharpYaml.Serialization
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A category used by <see cref="ITypeDescriptor"/>.
|
||||||
|
/// </summary>
|
||||||
|
public enum DescriptorCategory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A primitive.
|
||||||
|
/// </summary>
|
||||||
|
Primitive,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A collection.
|
||||||
|
/// </summary>
|
||||||
|
Collection,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An array
|
||||||
|
/// </summary>
|
||||||
|
Array,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary
|
||||||
|
/// </summary>
|
||||||
|
Dictionary,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An object
|
||||||
|
/// </summary>
|
||||||
|
Object,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A nullable value
|
||||||
|
/// </summary>
|
||||||
|
Nullable,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A custom descriptor.
|
||||||
|
/// </summary>
|
||||||
|
Custom
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,6 +80,11 @@ namespace SharpYaml.Serialization.Descriptors
|
||||||
toArrayMethod = listType.GetMethod("ToArray");
|
toArrayMethod = listType.GetMethod("ToArray");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override DescriptorCategory Category
|
||||||
|
{
|
||||||
|
get { return DescriptorCategory.Array; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the type of the array element.
|
/// Gets the type of the array element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -108,6 +108,11 @@ namespace SharpYaml.Serialization.Descriptors
|
||||||
IsPureCollection = Count == 0;
|
IsPureCollection = Count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override DescriptorCategory Category
|
||||||
|
{
|
||||||
|
get { return DescriptorCategory.Collection; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the type of the element.
|
/// Gets or sets the type of the element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -102,6 +102,11 @@ namespace SharpYaml.Serialization.Descriptors
|
||||||
IsPureDictionary = Count == 0;
|
IsPureDictionary = Count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override DescriptorCategory Category
|
||||||
|
{
|
||||||
|
get { return DescriptorCategory.Dictionary; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this instance is generic dictionary.
|
/// Gets a value indicating whether this instance is generic dictionary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -70,6 +70,11 @@ namespace SharpYaml.Serialization.Descriptors
|
||||||
UnderlyingType = Nullable.GetUnderlyingType(type);
|
UnderlyingType = Nullable.GetUnderlyingType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override DescriptorCategory Category
|
||||||
|
{
|
||||||
|
get { return DescriptorCategory.Nullable; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the type underlying type T of the nullable <see cref="Nullable{T}"/>
|
/// Gets the type underlying type T of the nullable <see cref="Nullable{T}"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -185,6 +185,11 @@ namespace SharpYaml.Serialization.Descriptors
|
||||||
get { return members == null ? 0 : members.Count; }
|
get { return members == null ? 0 : members.Count; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual DescriptorCategory Category
|
||||||
|
{
|
||||||
|
get { return DescriptorCategory.Object; }
|
||||||
|
}
|
||||||
|
|
||||||
public bool HasMembers
|
public bool HasMembers
|
||||||
{
|
{
|
||||||
get { return members.Count > 0; }
|
get { return members.Count > 0; }
|
||||||
|
|
|
@ -92,6 +92,11 @@ namespace SharpYaml.Serialization.Descriptors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override DescriptorCategory Category
|
||||||
|
{
|
||||||
|
get { return DescriptorCategory.Primitive; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether the specified type is a primitive.
|
/// Determines whether the specified type is a primitive.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -70,6 +70,12 @@ namespace SharpYaml.Serialization
|
||||||
/// <value>The member count.</value>
|
/// <value>The member count.</value>
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the category of this descriptor.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The category.</value>
|
||||||
|
DescriptorCategory Category { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this instance has members.
|
/// Gets a value indicating whether this instance has members.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
<Compile Include="MemoryParser.cs" />
|
<Compile Include="MemoryParser.cs" />
|
||||||
<Compile Include="Serialization\AnchorEventEmitter.cs" />
|
<Compile Include="Serialization\AnchorEventEmitter.cs" />
|
||||||
<Compile Include="Serialization\DefaultNamingConvention.cs" />
|
<Compile Include="Serialization\DefaultNamingConvention.cs" />
|
||||||
|
<Compile Include="Serialization\DescriptorCategory.cs" />
|
||||||
<Compile Include="Serialization\Descriptors\DefaultKeyComparer.cs" />
|
<Compile Include="Serialization\Descriptors\DefaultKeyComparer.cs" />
|
||||||
<Compile Include="Serialization\FlatNamingConvention.cs" />
|
<Compile Include="Serialization\FlatNamingConvention.cs" />
|
||||||
<Compile Include="Serialization\IMemberNamingConvention.cs" />
|
<Compile Include="Serialization\IMemberNamingConvention.cs" />
|
||||||
|
|
Загрузка…
Ссылка в новой задаче