+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
//
// XamlLoader.cs
//
if (string.IsNullOrEmpty(xaml))
throw new XamlParseException(string.Format("Can't get xaml from type {0}", callingType), new XmlLineInfo());
Load(view, xaml);
+ NUIApplication.CurrentLoadedXaml = callingType.FullName;
}
catch (XamlParseException e)
{
var rootnode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), ret, (IXmlNamespaceResolver)reader);
XamlParser.ParseXaml(rootnode, reader);
+ var doNotThrow = ResourceLoader.ExceptionHandler != null || Internals.XamlLoader.DoNotThrowOnExceptions;
+ void ehandler(Exception e) => ResourceLoader.ExceptionHandler?.Invoke((e, path));
Visit(rootnode, new HydrationContext
{
RootElement = ret,
#pragma warning disable 0618
- ExceptionHandler = ResourceLoader.ExceptionHandler ?? (Internals.XamlLoader.DoNotThrowOnExceptions ? e => { } : (Action<Exception>)null)
+ ExceptionHandler = doNotThrow ? ehandler : (Action<Exception>)null
#pragma warning restore 0618
});
break;
var rootnode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), view, (IXmlNamespaceResolver)reader);
XamlParser.ParseXaml(rootnode, reader);
+ var doNotThrow = ResourceLoader.ExceptionHandler != null || Internals.XamlLoader.DoNotThrowOnExceptions;
+ void ehandler(Exception e) => ResourceLoader.ExceptionHandler?.Invoke((e, XamlFilePathAttribute.GetFilePathForObject(view)));
Visit(rootnode, new HydrationContext
{
RootElement = view,
#pragma warning disable 0618
- ExceptionHandler = ResourceLoader.ExceptionHandler ?? (Internals.XamlLoader.DoNotThrowOnExceptions ? e => { } : (Action<Exception>)null)
+ ExceptionHandler = doNotThrow ? ehandler : (Action<Exception>)null
#pragma warning restore 0618
});
break;
}
}
- [Obsolete("Use the XamlFileProvider to provide xaml files. We will remove this when Cycle 8 hits Stable.")]
- public static object Create(string xaml, bool doNotThrow = false)
- {
- object inflatedView = null;
- using (var textreader = new StringReader(xaml))
- using (var reader = XmlReader.Create(textreader))
- {
- inflatedView = Create(reader, doNotThrow);
- }
- return inflatedView;
- }
-
public static object Create(XmlReader reader, bool doNotThrow = false)
{
object inflatedView = null;