Пример #1
0
 /// <summary>
 /// Reads properties for the specified container.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="container">The container.</param>
 public virtual void Read(IFormatReader reader, object container)
 {
     foreach (ILayoutElement element in this._elements)
     {
         element.Read(reader, container);
     }
 }
Пример #2
0
 public string Get(IFormatReader parameter)
 =>
 parameter.Name.Contains(_separator)
                                 ? IdentityFormatter.Default.Get(parameter.Identifier == string.Empty
                                                                         ? parameter.Get(parameter.Name, string.Empty)
                                                                         : parameter)
                                 : _formatter.Get(parameter);
                public IFormatReader Get(IFormatReader parameter)
                {
                    var typeInfo = _classification.Get(parameter) ?? _type;
                    var fullName = typeInfo.FullName;
                    var version  = parameter.IsSatisfiedBy(_property) ? _property.Get(parameter) : 0;

                    if (version > _version)
                    {
                        throw new XmlException($"Unknown varsion number {version} for type {typeInfo}.");
                    }

                    var element = XElement.Load(parameter.Get()
                                                .AsValid <System.Xml.XmlReader>()
                                                .ReadSubtree());

                    for (var i = version; i < _version; i++)
                    {
                        var index     = (int)i;
                        var migration = _migrations.ElementAtOrDefault(index);
                        if (migration == null)
                        {
                            throw new XmlException(
                                      $"Migrations for type {fullName} contains invalid migration at index {i}.");
                        }
                        _migrations[index]
                        .Invoke(element);
                    }

                    var xmlReader = element.CreateReader();
                    var result    = _factory.Get(xmlReader);

                    AssociatedReaders.Default.Assign(result, parameter);
                    return(result);
                }
Пример #4
0
        /// <summary>
        /// Reads partial data for the container from the specified format.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="container">The container.</param>
        public override void Read(IFormatReader reader, object container)
        {
            using (reader.Section(this.Tag))
            {
                int length = reader.ReadInteger("Length");

                ICollection <TElement> collection = this.ReadCollection(reader, length);
                var array = collection as TElement[];

                for (int i = 0; i < length; i++)
                {
                    using (reader.Section(this.ElementTag))
                    {
                        TElement element = this.ReadElement(reader);
                        if (array != null)
                        {
                            array[i] = element;
                        }
                        else
                        {
                            collection.Add(element);
                        }
                    }
                }

                this.SetAction(container, collection);
            }
        }
Пример #5
0
            static ReferenceIdentity?Identity(IFormatReader reader)
            {
                var identity = IdentityProperty.Default.Get(reader);
                var result   = identity.HasValue ? new ReferenceIdentity(identity.Value) : (ReferenceIdentity?)null;

                return(result);
            }
Пример #6
0
        public override object Get(IFormatReader parameter)
        {
            var reference = GetReference(parameter);

            if (reference != null)
            {
                var result = _maps.Get(parameter).Get(reference.Value);
                return(result);
            }

            {
                var element = parameter.Get().To <XmlReader>().NodeType != XmlNodeType.Attribute ||
                              MemberProperty.Default.Get(parameter);
                var declared = element ? Identity(parameter) : null;
                var result   = base.Get(parameter);
                var identity = declared ?? (element && result != null ? Entity(parameter, result) : null);
                if (identity != null)
                {
                    var map = _maps.Get(parameter);
                    if (map.Get(identity.Value) != result)
                    {
                        map.Assign(identity.Value, result);
                    }
                }

                return(result);
            }
        }
Пример #7
0
        TypeInfo Generic(IFormatReader parameter)
        {
            var arguments = ArgumentsTypeProperty.Default.Get(parameter);
            var result    = !arguments.IsDefault ? Generic(parameter, arguments) : null;

            return(result);
        }
                public object Get(IFormatReader parameter)
                {
                    var reader = _migrator.Get(parameter);
                    var result = _serializer.Get(reader);

                    return(result);
                }
            public TypeInfo Get(IFormatReader parameter)
            {
                var isSatisfiedBy = parameter.IsSatisfiedBy(SchemaType.Instance);

                return(isSatisfiedBy
                                               ? _reader.Get(parameter)
                                               : _classification.Get(parameter));
            }
Пример #10
0
        /// <summary>
        /// Reads a value out of the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public override T Read(IFormatReader reader)
        {
            T instance = this.CreateInstance(reader);

            this.Layout.Read(reader, instance);

            return(instance);
        }
 public async Task WriteAllAsync(IFormatReader reader)
 {
     while (!reader.EndOfFile)
     {
         SNP genotype = await reader.ReadNext();
         await WriteNext(genotype);
     }
 }
Пример #12
0
        /// <summary>
        /// Reads a value out of the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public override object Read(IFormatReader reader)
        {
            object instance = Activator.CreateInstance(this.Type, true);

            cache.Get(this.Type).Read(reader, instance);

            return(instance);
        }
Пример #13
0
            public object Get(IFormatReader parameter)
            {
                var dimensions = _map.Get(parameter);
                var source     = _reader.Get(parameter).AsValid <Array>();
                var result     = Array.CreateInstance(_root, dimensions.ToArray());

                Buffer.BlockCopy(source, 0, result, 0, source.Length * sizeof(int));
                return(result);
            }
Пример #14
0
                public RandomType Get(IFormatReader parameter)
                {
                    var xml         = parameter.Get().To <System.Xml.XmlReader>();
                    var description = xml.GetAttribute("DescriptionOverride");
                    var result      = (RandomType)_serializer.Get(parameter);

                    result.Description = description;
                    return(result);
                }
Пример #15
0
                public object Get(IFormatReader parameter)
                {
                    var key = parameter.Get()
                              .AsValid <XmlReader>();

                    var result = _instances.IsSatisfiedBy(key) ? _instances.Get(key) : _reader.Get(parameter);

                    return(result);
                }
Пример #16
0
            public IInterface Get(IFormatReader parameter)
            {
                var name   = parameter.Content();
                var type   = Type.GetType(name) ?? throw new InvalidOperationException($"Could not parse '{name}'");
                var result = (Implementation)Activator.CreateInstance(type);

                result.Created = true;
                return(result);
            }
Пример #17
0
            public TypeInfo Get(IFormatReader parameter)
            {
                var element = _reader.Get(parameter);
                var result  = element != null
                                        ? TypeInfo(parameter, element)
                              .GetTypeInfo()
                                        : null;

                return(result);
            }
Пример #18
0
            public object Get(IFormatReader parameter)
            {
                var classification = _classification.Get(parameter);
                var result         = _specification.IsSatisfiedBy(classification)
                                                     ? _activators.Get(classification)
                                     .Get()
                                                     : _activator.Get(parameter);

                return(result);
            }
Пример #19
0
        ReferenceIdentity?Entity(IFormatReader reader, object instance)
        {
            var typeInfo = instance.GetType();
            var entity   = _entities.Get(typeInfo)?.Get(reader);
            var result   = entity != null
                                             ? (ReferenceIdentity?)new ReferenceIdentity(typeInfo.GetTypeInfo(), entity)
                                             : null;

            return(result);
        }
Пример #20
0
        public object Get(IFormatReader parameter)
        {
            var elementType = _classification.GetClassification(parameter, _declaredType)
                              .GetElementType();
            var result = _reader.Get(parameter)
                         .ToArray(elementType ??
                                  throw new InvalidOperationException("Element type not found."));

            return(result);
        }
Пример #21
0
        /// <summary>
        /// Reads the property for the specified container.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="container">The container.</param>
        public override void Read(IFormatReader reader, object container)
        {
            using (reader.Section(this.Tag))
            {
                Type   type          = Type.GetType(reader.ReadString("Type"));
                object propertyValue = Cementery.Serializer.Load(type, reader);

                this.SetAction(container, propertyValue);
            }
        }
Пример #22
0
                public object Get(IFormatReader parameter)
                {
                    var reader = parameter.Get()
                                 .AsValid <System.Xml.XmlReader>();
                    var subtree = reader.ReadSubtree();
                    var element = XElement.Load(subtree);
                    var result  = _custom.Deserialize(element);

                    return(result);
                }
Пример #23
0
 public object Get(IFormatReader parameter)
 {
     try
     {
         return(_previous.Get(parameter));
     }
     catch (FormatException)
     {
         return(null);
     }
 }
Пример #24
0
 public TagCloud(
     IFormatReader reader,
     IWordFilter contentConfigurator,
     IPainter pictureConfigurator,
     ITagCloudBuilder builder)
 {
     this.reader = reader;
     this.contentConfigurator = contentConfigurator;
     this.pictureConfigurator = pictureConfigurator;
     this.builder             = builder;
 }
Пример #25
0
        // Constructor
        public DataReader(IFormatReader reader)
        {
            // Guard clause to ensure that only a valid DataReader can be created
            if (reader == null)
            {
                throw new ArgumentException($"ERROR :: '{nameof(reader)}' is NULL!");
            }

            // Assign private variables
            this._reader = reader;
        }
Пример #26
0
 CandidateResult Candidate(IFormatReader parameter)
 {
     try
     {
         return(new CandidateResult(_serializer.Get(parameter)));
     }
     catch (Exception e)
     {
         return(new CandidateResult(_parser.Parse(parameter.Content()), e));
     }
 }
Пример #27
0
        public object Get(IFormatReader parameter)
        {
            var candidate = Candidate(parameter);
            var parts     = candidate.Instance as MarkupExtensionParts;
            var result    = parts != null
                                             ? _container.Get(parameter)
                            .Get(parts)
                                             : candidate.Get();

            return(result);
        }
Пример #28
0
        public object Get(IFormatReader parameter)
        {
            var contains = parameter.IsSatisfiedBy(_member.Profile);

            if (contains)
            {
                var result = _member.Get(parameter);
                parameter.Set();
                return(result);
            }
            return(null);
        }
        /// <summary>
        /// Creates the collection.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="length">The length.</param>
        protected override ICollection <TElement> ReadCollection(IFormatReader reader, int length)
        {
            string typeName = reader.ReadString("Type");
            Type   type     = Type.GetType(typeName);

            if (type.IsArray)
            {
                return(new TElement[length]);
            }

            return((ICollection <TElement>)Activator.CreateInstance(type, true));
        }
Пример #30
0
        public object Get(IFormatReader parameter)
        {
            var adapter = _activator.Get(parameter);

            while (adapter?.MoveNext() ?? false)
            {
                _content.Execute(adapter);
            }
            var result = adapter != null?_result.Get(adapter) : null;

            return(result);
        }
Пример #31
0
        public SerializableStructure Deserialize(string input, IFormatReader formatter)
        {
            Dump dump = formatter.Read(input);

            return dump == null ? null : CreateFromDump(dump);
        }