示例#1
0
 public ClassDescriber(Type type, IDescribersFinder finder)
 {
     _Default = null;
     _Type    = type;
     _TypeSet = finder;
     _Fields  = (from field in _Type.GetFields()
                 where field.IsStatic == false && field.IsPublic orderby field.Name
                 select field).ToArray();
 }
示例#2
0
 public TypeIdentifier(Type type, IDescribersFinder finder)
 {
     if (_IsPoint(type))
     {
         Describers = new ITypeDescriber[0];
     }
     else if (_IsDelegate(type))
     {
         Describers = new ITypeDescriber[0];
     }
     else if (_IsEnum(type))
     {
         Describers = new[] { new EnumDescriber(type) };
     }
     else if (_IsNumber(type))
     {
         Describers = new[] { new NumberDescriber(type) };
     }
     else if (_IsByteArray(type))
     {
         NumberDescriber byteDescriber = new NumberDescriber(typeof(int));
         Describers = new ITypeDescriber[] { new ByteArrayDescriber(byteDescriber), byteDescriber };
     }
     else if (_IsBuffer(type))
     {
         Describers = new ITypeDescriber[] { new BufferDescriber(type) };
     }
     else if (_IsBittable(type))
     {
         Describers = new ITypeDescriber[] { new BlittableDescriber(type) };
     }
     else if (_IsString(type))
     {
         BufferDescriber chars = new BufferDescriber(typeof(char[]));
         Describers = new ITypeDescriber[] { new StringDescriber(chars), chars };
     }
     else if (_IsArray(type))
     {
         Describers = new ITypeDescriber[] { new ArrayDescriber(type, finder) };
     }
     else if (_IsClass(type))
     {
         Describers = new ITypeDescriber[] { new ClassDescriber(type, finder) };
     }
     else
     {
         throw new Exception("Unrecognized type " + type.FullName);
     }
 }
示例#3
0
        public ArrayDescriber(Type type, IDescribersFinder finder)
        {
            _TypeSet = finder;
            _Default = null;
            _Type    = type;
            var elementType = type.GetElementType();

            try
            {
                if (!elementType.IsClass)
                {
                    _DefaultElement = Activator.CreateInstance(elementType);
                }
                else
                {
                    _DefaultElement = null;
                }
            }
            catch (Exception ex)
            {
                throw new DescriberException(typeof(ArrayDescriber), _Type, "_DefaultElement", ex);
            }
        }
示例#4
0
 public DescriberProvider(IKeyDescriber key_describer, IDescribersFinder type_finder)
 {
     KeyDescriber         = key_describer;
     TypeDescriberFinders = type_finder;
 }
示例#5
0
 public DescriberProvider(IDescribersFinder finder) : this(finder.Get(), finder)
 {
 }
示例#6
0
 public StringKeyDescriber(ITypeFinder type_finder, IDescribersFinder describers_finder)
 {
     _TypeFinder    = type_finder;
     _TypeDescriber = describers_finder.Get(typeof(string));
 }