/// <summary>
 /// Пытется найти подходящий resolver для указанного примитивного типа
 /// </summary>
 /// <returns><c>true</c>, if create primitive resolver was tryed, <c>false</c> otherwise.</returns>
 /// <param name="type">Type.</param>
 /// <param name="resolver">Resolver.</param>
 private bool TryCreatePrimitiveResolver(Type type, out IResolver resolver)
 {
     if (TypeOf <Boolean> .Equals(type))
     {
         resolver = new BooleanResolver(); return(true);
     }
     if (TypeOf <Byte> .Equals(type))
     {
         resolver = new ByteResolver(); return(true);
     }
     if (TypeOf <Char> .Equals(type))
     {
         resolver = new CharResolver(); return(true);
     }
     if (TypeOf <Double> .Equals(type))
     {
         resolver = new DoubleResolver(); return(true);
     }
     if (TypeOf <Int16> .Equals(type))
     {
         resolver = new Int16Resolver(); return(true);
     }
     if (TypeOf <Int32> .Equals(type))
     {
         resolver = new Int32Resolver(); return(true);
     }
     if (TypeOf <Int64> .Equals(type))
     {
         resolver = new Int64Resolver(); return(true);
     }
     if (TypeOf <SByte> .Equals(type))
     {
         resolver = new SByteResolver(); return(true);
     }
     if (TypeOf <Single> .Equals(type))
     {
         resolver = new SingleResolver(); return(true);
     }
     if (TypeOf <UInt16> .Equals(type))
     {
         resolver = new UInt16Resolver(); return(true);
     }
     if (TypeOf <UInt32> .Equals(type))
     {
         resolver = new UInt32Resolver(); return(true);
     }
     if (TypeOf <UInt64> .Equals(type))
     {
         resolver = new UInt64Resolver(); return(true);
     }
     resolver = null;
     return(false);
 }
Example #2
0
            internal static void FindSerialiableFieldsInternal(List <FieldInfo> fields, Type targetType, bool includeBaseFields)
            {
                if (TypeOf <Object> .Equals(targetType))
                {
                    return;
                }

                SublistSerializableFieldsInternal(fields, targetType);

                if (includeBaseFields)
                {
                    FindSerialiableFieldsInternal(fields, targetType.BaseType, true);
                }
            }
        /// <summary>
        /// Tries the create default resolver.
        /// </summary>
        /// <returns><c>true</c>, if create default resolver was tryed, <c>false</c> otherwise.</returns>
        /// <param name="type">Type.</param>
        /// <param name="resolver">Resolver.</param>
        private bool TryCreateDefaultResolver(Type type, out IResolver resolver)
        {
            if (type.IsValueType)                                                       //Проверяем является ли тип значимым
            {
                if (type.IsPrimitive && TryCreatePrimitiveResolver(type, out resolver)) //Проверяем является ли тип примитивным
                {
                    return(true);
                }

                if (TypeOf <Decimal> .Equals(type))
                {
                    resolver = new DecimalResolver();
                    return(true);
                }
            }
            else
            {
                if (type.IsArray)
                {
                    resolver = CreateArrayResolver(type);
                    return(true);
                }

                if (TypeOf <Object> .Equals(type))
                {
                    resolver = new ObjectResolver(); return(true);
                }
                if (TypeOf <String> .Equals(type))
                {
                    resolver = new StringResolver(); return(true);
                }
                if (RuntimeType.Equals(type))
                {
                    resolver = new TypeResolver(Serializator); return(true);
                }

                if (Delegate.IsAssignableFrom(type))
                {
                    if ((Serializator.Options & SerializatorOption.ThrowOutExceptions) != 0)
                    {
                        throw new NotSupportedException("Serialization delegates is not supported");
                    }
                    resolver = new EmptyResolver(Serializator);
                    return(true);
                }
            }

            resolver = null;
            return(false);
        }
        public bool Equals(ContentTypeDescription input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     CType == input.CType ||
                     (CType != null && CType.Equals(input.CType))
                     ) &&
                 (
                     Name == input.Name ||
                     (Name != null && Name.Equals(input.Name))
                 ) &&
                 (
                     ContentDescription == input.ContentDescription ||
                     (ContentDescription != null && ContentDescription.Equals(input.ContentDescription))
                 ) &&
                 (
                     PreviewImage == input.PreviewImage ||
                     (PreviewImage != null && PreviewImage.Equals(input.PreviewImage))
                 ) &&
                 (
                     Priority == input.Priority ||
                     (Priority.Equals(input.Priority))
                 ) &&
                 (
                     Reminder == input.Reminder ||
                     (Reminder != null && Reminder.Equals(input.Reminder))
                 ) &&
                 (
                     Properties == input.Properties ||
                     (Properties != null && Properties.SequenceEqual(input.Properties))
                 ) &&
                 (
                     TagMetadata == input.TagMetadata ||
                     (TagMetadata != null && TagMetadata.SequenceEqual(input.TagMetadata))
                 ) &&
                 (
                     TagMetadataItems == input.TagMetadataItems ||
                     (TagMetadataItems != null && TagMetadataItems.SequenceEqual(input.TagMetadataItems))
                 ) &&
                 (
                     UsageExamples == input.UsageExamples ||
                     (UsageExamples != null && UsageExamples.SequenceEqual(input.UsageExamples))
                 ) &&
                 (
                     ShowInContentEditor == input.ShowInContentEditor ||
                     (ShowInContentEditor != null && ShowInContentEditor.Equals(input.ShowInContentEditor))
                 ) &&
                 (
                     TypeOf == input.TypeOf ||
                     (TypeOf != null && TypeOf.Equals(input.TypeOf))
                 ) &&
                 (
                     BindIdentifierToProperty == input.BindIdentifierToProperty ||
                     (BindIdentifierToProperty != null && BindIdentifierToProperty.Equals(input.BindIdentifierToProperty))
                 ) &&
                 (
                     BoundRegex == input.BoundRegex ||
                     (BoundRegex != null && BoundRegex.Equals(input.BoundRegex))
                 ) &&
                 (
                     ForceIdentifierBinding == input.ForceIdentifierBinding ||
                     (ForceIdentifierBinding != null && ForceIdentifierBinding.Equals(input.ForceIdentifierBinding))
                 ) &&
                 (
                     AllowComments == input.AllowComments ||
                     (AllowComments != null && AllowComments.Equals(input.AllowComments))
                 ) &&
                 (
                     AutoEnglishPropertyFallback == input.AutoEnglishPropertyFallback ||
                     (AutoEnglishPropertyFallback != null && AutoEnglishPropertyFallback.Equals(input.AutoEnglishPropertyFallback))
                 ) &&
                 (
                     BulkUploadable == input.BulkUploadable ||
                     (BulkUploadable != null && BulkUploadable.Equals(input.BulkUploadable))
                 ) &&
                 (
                     Previews == input.Previews ||
                     (Previews != null && Previews.SequenceEqual(input.Previews))
                 ) &&
                 (
                     SuppressCmsPath == input.SuppressCmsPath ||
                     (SuppressCmsPath != null && SuppressCmsPath.Equals(input.SuppressCmsPath))
                 ) &&
                 (
                     PropertySections == input.PropertySections ||
                     (PropertySections != null && PropertySections.SequenceEqual(input.PropertySections))
                 ));
        }