public IFormatReader Get(IFormatReader parameter)
                {
                    var typeInfo = _classification.Get(parameter);
                    var fullName = typeInfo.FullName;
                    var version  = parameter.IsSatisfiedBy(_property) ? _property.Get(parameter) : 0;

                    var length = _migrations.Length;

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

                    if (_migrations == null)
                    {
                        throw new XmlException($"Migrations for type {fullName} is null.");
                    }

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

                    for (var i = version; i < length; 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 result = _factory.Get(element.CreateReader());

                    return(result);
                }
            public object Get(IFormatReader parameter)
            {
                var reader = parameter.Get()
                             .To <System.Xml.XmlReader>();

                var items = new ArrayList();

                while (!IdentityComparer.Default.Equals(parameter, _identity))
                {
                    var value = _serializer.Get(parameter);
                    items.Add(value);
                    reader.Read();
                    reader.MoveToContent();
                }

                if (reader.HasValue)
                {
                    items.Add(_item.Get(parameter));
                }

                reader.Read();

                var result = _lists.Get(items);

                return(result);
            }
Exemple #3
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);
Exemple #4
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);
            }
        }
Exemple #5
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);
                }
Exemple #6
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);
                }
Exemple #7
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);
                }
Exemple #8
0
            public DatabaseObject Get(IFormatReader parameter)
            {
                var owner = _history.Get(parameter)
                            .Peek()
                            .Current;
                var access = _members.Get(owner.GetType())
                             .Get(parameter.Name)
                             .Access;

                _proxies.Get(parameter.Get())
                .Add(((Proxy)_serializer.Get(parameter), owner, access));
                return(null);
            }
		public IInnerContent Get(IFormatReader parameter)
		{
			var xml = (System.Xml.XmlReader) parameter.Get();
			var attributes = xml.HasAttributes ? new XmlAttributes(xml) : (XmlAttributes?) null;

			var depth = XmlDepth.Default.Get(xml);
			var content = depth.HasValue ? new XmlElements(xml, depth.Value) : (XmlElements?) null;

			var result = parameter.IsAssigned()
				             ? _contents.Create(parameter, _activator.Get(parameter), new XmlContent(attributes, content))
				             : null;
			return result;
		}
Exemple #10
0
            public MessageStringFormat Get(IFormatReader parameter)
            {
                var reader = parameter.Get().AsValid <XmlReader>();


                var content = reader.ReadInnerXml();


                return(new MessageStringFormat
                {
                    Body = content
                });
            }
        public IInnerContent Get(IFormatReader parameter)
        {
            var xml        = (System.Xml.XmlReader)parameter.Get();
            var attributes = xml.HasAttributes ? new XmlAttributes(xml) : (XmlAttributes?)null;

            var depth   = XmlDepth.Default.Get(xml);
            var content = depth.HasValue ? new XmlElements(xml, depth.Value) : (XmlElements?)null;

            var result = IdentityComparer.Default.Equals(parameter, NullElementIdentity.Default) ||
                         parameter.IsSatisfiedBy(NullValueIdentity.Default)
                                             ? null
                                             : _contents.Create(parameter, _activator.Get(parameter), new XmlContent(attributes, content));

            return(result);
        }
            public object Get(IFormatReader parameter)
            {
                var element = parameter.Get().To <XmlReader>().NodeType != XmlNodeType.Attribute || MemberProperty.Default.Get(parameter);

                var declared = element ? Identity(parameter) : null;
                var result   = _activator.Get(parameter);

                var identity = declared ?? (element && result != null ? Entity(parameter, result) : null);

                if (identity != null)
                {
                    _maps.Get(parameter)
                    .Assign(identity.Value, result);
                }

                return(result);
            }
Exemple #13
0
                public object Get(IFormatReader parameter)
                {
                    var reader = parameter.Get()
                                 .To <System.Xml.XmlReader>();

                    var items = new ArrayList();

                    reader.MoveToContent();

                    while (parameter.Name == _name)
                    {
                        var value = _item.Get(parameter);
                        items.Add(value);
                        reader.Read();
                    }

                    var result = _lists.Get(items);

                    return(result);
                }
Exemple #14
0
        ReferenceIdentity?GetReference(IFormatReader parameter)
        {
            if (parameter.Get().To <XmlReader>().NodeType != XmlNodeType.Attribute ||
                MemberProperty.Default.Get(parameter))
            {
                var identity = ReferenceIdentity.Get(parameter);
                if (identity.HasValue)
                {
                    return(new ReferenceIdentity(identity.Value));
                }

                var type   = _classification.GetClassification(parameter, _definition);
                var entity = _entities.Get(type)?.Reference(parameter);
                if (entity != null)
                {
                    return(new ReferenceIdentity(type, entity));
                }
            }

            return(null);
        }
                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 reader  = parameter.Get().AsValid <System.Xml.XmlReader>();
                    var element = XElement.Load(reader.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();

                    XmlParserContexts.Default.Assign(xmlReader.NameTable,
                                                     XmlParserContexts.Default.Get(reader.NameTable));
                    var result = _factory.Get(xmlReader);

                    AssociatedReaders.Default.Assign(result, parameter);
                    return(result);
                }
 public IIdentity Get(string name, string identifier) => _reader.Get(name, identifier);
Exemple #17
0
 public bool IsSatisfiedBy(IFormatReader parameter) => parameter.Get()
 .AsValid <System.Xml.XmlReader>()
 .HasAttributes;
 public object Get(IFormatReader parameter) => _converter.Parse(parameter.Get()
                                                                .To <System.Xml.XmlReader>()
                                                                .Value);
Exemple #19
0
 public RootClass Get(IFormatReader parameter)
 {
     System.Xml.XmlReader native = parameter.Get().AsValid <System.Xml.XmlReader>();                // if you need it.
     return(_serializer.Get(parameter));
 }
Exemple #20
0
 public string Get(IFormatReader parameter) => ((System.Xml.XmlReader)parameter.Get()).Name;
 public IInnerContent Get(IFormatReader parameter)
 => parameter.IsAssigned()
                            ? _contents.Create(parameter, _activator.Get(parameter),
                                               Content(parameter.Get()
                                                       .To <System.Xml.XmlReader>()))
                            : null;
Exemple #22
0
 public MemberInfo Get(IFormatReader parameter) => parameter.Get(parameter.Content());
                // ReSharper disable once CognitiveComplexity
                // ReSharper disable once ExcessiveIndentation
                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 version number {version} for type {typeInfo}.");
                    }

                    parameter.Set();

                    var reader  = parameter.Get().AsValid <System.Xml.XmlReader>();
                    var element = XElement.Load(reader.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](element);
                    }

                    var attributes = element.Descendants()
                                     .Attributes()
                                     .Where(a => a.IsNamespaceDeclaration)
                                     .Distinct()
                                     .ToArray();

                    foreach (var attribute in attributes)
                    {
                        if (element.Attribute(attribute.Name) == null)
                        {
                            element.Add(attribute);
                        }
                    }

                    var native  = element.CreateReader(ReaderOptions.OmitDuplicateNamespaces);
                    var context = XmlParserContexts.Default.Get(reader.NameTable);

                    if (reader.NameTable != null)
                    {
                        var manager = context.NamespaceManager;

                        foreach (var attribute in attributes)
                        {
                            var prefix = attribute.Name.LocalName;
                            if (manager.LookupNamespace(prefix) == null)
                            {
                                var @namespace = element.GetNamespaceOfPrefix(prefix);
                                if (@namespace != null)
                                {
                                    manager.AddNamespace(prefix, @namespace.NamespaceName);
                                }
                            }
                        }
                    }

                    XmlParserContexts.Default.Assign(native.NameTable, context);
                    var result = _factory.Get(native);

                    AssociatedReaders.Default.Assign(result, parameter);
                    return(result);
                }