public ObjectAssembler(IRuntimeTypeSource typeSource, ITopDownValueContext topDownValueContext, Settings settings = null)
        {
            TypeSource = typeSource;
            var mapping = new DeferredLoaderMapping();
            mapping.Map<DataTemplate>(template => template.AlternateTemplateContent, new DeferredLoader());

            objectAssembler = new TemplateHostingObjectAssembler(
                new OmniXaml.ObjectAssembler.ObjectAssembler(typeSource, topDownValueContext, settings),
                mapping);
        }
        public IParser Create(Settings settings)
        {
            var xamlInstructionParser = new OrderAwareInstructionParser(new InstructionParser(runtimeTypeSource));

            IObjectAssembler objectAssembler = new PerspexObjectAssembler(runtimeTypeSource, settings);
            var phaseParserKit = new PhaseParserKit(
                new ProtoInstructionParser(runtimeTypeSource),
                xamlInstructionParser,
                objectAssembler);

            return new XmlParser(phaseParserKit);
        }
        public ObjectAssembler(IRuntimeTypeSource typeSource, IValueContext valueContext, Settings settings = null)
            : this(new StackingLinkedList<Level>(), typeSource, GetLifecycleListener(settings), valueContext)
        {
            this.valueContext = valueContext;
            Guard.ThrowIfNull(typeSource, nameof(typeSource));

            TypeSource = typeSource;
            StateCommuter.RaiseLevel();

            rootInstance = settings?.RootInstance;
            var rootInstanceType = rootInstance?.GetType();
            rootInstanceXamlType = rootInstanceType != null ? TypeSource.GetByType(rootInstanceType) : null;
        }
Beispiel #4
0
        private static IReadOnlyDictionary<string, object> GetDictionary(Settings settings)
        {
            IReadOnlyDictionary<string, object> dict;
            if (settings != null)
            {
                dict = settings.ParsingContext;
            }
            else
            {
                dict = new ReadOnlyDictionary<string, object>(new Dictionary<string, object>());
            }

            return dict;
        }
        public IParser Create(Settings settings)
        {
            var xamlInstructionParser = new OrderAwareInstructionParser(new InstructionParser(runtimeTypeSource));

            IObjectAssembler objectAssembler = new AvaloniaObjectAssembler(
                runtimeTypeSource,
                new TopDownValueContext(),
                settings);
            var phaseParserKit = new PhaseParserKit(
                new ProtoInstructionParser(runtimeTypeSource),
                xamlInstructionParser,
                objectAssembler);

            return new XmlParser(phaseParserKit);
        }
        public PerspexObjectAssembler(
            IRuntimeTypeSource typeSource, 
            ITopDownValueContext topDownValueContext, 
            Settings settings = null)
        {
            var mapping = new DeferredLoaderMapping();
            mapping.Map<ControlTemplate>(x => x.Content, new TemplateLoader());
            mapping.Map<DataTemplate>(x => x.Content, new TemplateLoader());
            mapping.Map<FocusAdornerTemplate>(x => x.Content, new TemplateLoader());
            mapping.Map<TreeDataTemplate>(x => x.Content, new TemplateLoader());
            mapping.Map<ItemsPanelTemplate>(x => x.Content, new TemplateLoader());

            var valueContext = new ValueContext(typeSource, topDownValueContext);
            assembler = new ObjectAssembler(typeSource, valueContext, settings);
            objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping);
        }
        public IParser Create(Settings settings)
        {
            var objectAssemblerForUndefinedRoot = new ObjectAssembler(runtimeTypeSource, new TopDownValueContext(), settings);

            return CreateParser(objectAssemblerForUndefinedRoot);
        }
        private static IInstanceLifeCycleListener GetLifecycleListener(Settings settings)
        {
            if (settings?.InstanceLifeCycleListener != null)
            {
                return settings.InstanceLifeCycleListener;
            }

            return new NullLifecycleListener();
        }
Beispiel #9
0
 public object Load(Stream stream, Settings settings)
 {
     return innerLoader.Load(stream, settings);
 }