/// <summary>
        /// Generates the record type schema.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="schemas">The schemas.</param>
        /// <param name="currentDepth">The current depth.</param>
        /// <returns>
        /// Instance of schema.
        /// </returns>
        private TypeSchema BuildRecordTypeSchema(Type type, Dictionary<string, NamedSchema> schemas, uint currentDepth)
        {
            if (type == typeof(DateTimeOffset))
            {
                return this.settings.UsePosixTime
                    ? (TypeSchema)new LongSchema(type)
                    : new StringSchema(type);
            }

            NamedSchema schema;
            if (schemas.TryGetValue(type.ToString(), out schema))
            {
                return schema;
            }

            if (type == typeof(Guid))
            {
                var recordName = new SchemaName(type.GetStrippedFullName());
                var attributes = new NamedEntityAttributes(recordName, new List<string>(), string.Empty);
                var result = new FixedSchema(attributes, 16, type);
                schemas.Add(type.ToString(), result);
                return result;
            }

            var attr = this.GetNamedEntityAttributesFrom(type);
            AvroContractResolver resolver = this.settings.Resolver;
            var record = new RecordSchema(
                attr,
                type);
            schemas.Add(type.ToString(), record);

            var members = resolver.ResolveMembers(type);
            this.AddRecordFields(members, schemas, currentDepth, record);
            return record;
        }
        /// <summary>
        ///     Creates a schema definition.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>
        ///     New instance of schema definition.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="type"/> parameter is null.</exception>
        public TypeSchema BuildSchema(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            AvroContractResolver resolver = this.settings.Resolver;
            this.knownTypes.UnionWith(resolver.GetKnownTypes(type) ?? new List<Type>());
            return this.CreateSchema(false, type, new Dictionary<string, NamedSchema>(), 0);
        }
 private NamedEntityAttributes GetNamedEntityAttributesFrom(Type type)
 {
     AvroContractResolver resolver = this.settings.Resolver;
     TypeSerializationInfo typeInfo = resolver.ResolveType(type);
     var name = new SchemaName(typeInfo.Name, typeInfo.Namespace);
     var aliases = typeInfo
         .Aliases
         .Select(alias => string.IsNullOrEmpty(name.Namespace) || alias.Contains(".") ? alias : name.Namespace + "." + alias)
         .ToList();
     return new NamedEntityAttributes(name, aliases, typeInfo.Doc);
 }