[NUI] Fix VD Svace issue (#657)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Wed, 16 Jan 2019 07:40:10 +0000 (16:40 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 16 Jan 2019 07:40:10 +0000 (16:40 +0900)
Change-Id: I032ed4e562603441be4d26be68e29e0081e8c917
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/internal/Application.cs
src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs
src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StyleSheetExtension.cs
src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs
src/Tizen.NUI/src/internal/Xaml/XamlParser.cs
src/Tizen.NUI/src/internal/XamlBinding/Application.cs
src/Tizen.NUI/src/internal/XamlBinding/ResourcesExtensions.cs
src/Tizen.NUI/src/public/Window.cs
src/Tizen.NUI/src/public/XamlBinding/ResourceDictionary.cs

index 378758b..e81ab53 100755 (executable)
@@ -677,7 +677,7 @@ namespace Tizen.NUI
             await SaveSemaphore.WaitAsync();
             try
             {
-                await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
+                await DependencyService.Get<IDeserializer>()?.SerializePropertiesAsync(Properties);
             }
             finally
             {
index e8d90eb..1d5ce18 100755 (executable)
@@ -175,7 +175,7 @@ namespace Tizen.NUI.Xaml
             {
                 // Modify the namespace
                 var propname =
-                    parameter.CustomAttributes.First(ca => ca.AttributeType.FullName == "Tizen.NUI.Binding.ParameterAttribute")
+                    parameter.CustomAttributes.First(ca => ca.AttributeType.FullName == "Tizen.NUI.Binding.ParameterAttribute")?
                         .ConstructorArguments.First()
                         .Value as string;
                 if (!node.Properties.ContainsKey(new XmlName("", propname)))
index f46a1b2..b97485e 100755 (executable)
@@ -33,7 +33,7 @@ namespace Tizen.NUI.Xaml
                     return null;
                 var rootTargetPath = XamlResourceIdAttribute.GetPathForType(rootObjectType);
                 var resourcePath = ResourceDictionary.RDSourceTypeConverter.GetResourcePath(Source, rootTargetPath);
-                var resString = DependencyService.Get<IResourcesLoader>().GetResource(resourcePath, rootObjectType.GetTypeInfo().Assembly, lineInfo);
+                var resString = DependencyService.Get<IResourcesLoader>()?.GetResource(resourcePath, rootObjectType.GetTypeInfo().Assembly, lineInfo);
                 return StyleSheet.FromString(resString);
             }
 
index e90b735..f881a2e 100755 (executable)
@@ -21,7 +21,7 @@ namespace Tizen.NUI.Xaml
                     continue;
                 if (!propertyName.Equals(XamlParser.McUri, "Ignorable"))
                     continue;
-                (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>())).AddRange(propertyValue.Split(','));
+                (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>()))?.AddRange(propertyValue.Split(','));
             }
 
             foreach (var propertyKvp in node.Properties.ToList())
index c728d04..63f30da 100755 (executable)
@@ -168,7 +168,7 @@ namespace Tizen.NUI.Xaml
                         node = new ElementNode(new XmlType(elementNsUri, elementName, typeArguments), elementNsUri,
                             reader as IXmlNamespaceResolver, elementXmlInfo.LineNumber, elementXmlInfo.LinePosition);
                         ((IElementNode)node).Properties.AddRange(attributes);
-                        (node.IgnorablePrefixes ?? (node.IgnorablePrefixes = new List<string>())).AddRange(prefixes);
+                        (node.IgnorablePrefixes ?? (node.IgnorablePrefixes = new List<string>()))?.AddRange(prefixes);
 
                         ParseXamlElementFor((IElementNode)node, reader);
                         nodes.Add(node);
index 83520a2..cbfefcc 100755 (executable)
@@ -30,7 +30,7 @@ namespace Tizen.NUI.Binding
             NavigationProxy = new NavigationImpl(this);
             SetCurrentApplication(this);
 
-            SystemResources = DependencyService.Get<ISystemResourcesProvider>().GetSystemResources();
+            SystemResources = DependencyService.Get<ISystemResourcesProvider>()?.GetSystemResources();
             SystemResources.ValuesChanged += OnParentResourcesChanged;
             _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Application>>(() => new PlatformConfigurationRegistry<Application>(this));
         }
@@ -350,7 +350,7 @@ namespace Tizen.NUI.Binding
             await SaveSemaphore.WaitAsync();
             try
             {
-                await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
+                await DependencyService.Get<IDeserializer>()?.SerializePropertiesAsync(Properties);
             }
             finally
             {
index 84eeaf3..c6f4074 100755 (executable)
@@ -14,15 +14,18 @@ namespace Tizen.NUI.Binding
                 if (ve != null && ve.IsResourcesCreated)
                 {
                     resources = resources ?? new Dictionary<string, object>();
-                    foreach (KeyValuePair<string, object> res in ve.XamlResources.MergedResources)
-                        if (!resources.ContainsKey(res.Key))
-                            resources.Add(res.Key, res.Value);
-                        else if (res.Key.StartsWith(Style.StyleClassPrefix, StringComparison.Ordinal))
-                        {
-                            var mergedClassStyles = new List<Style>(resources[res.Key] as List<Style>);
-                            mergedClassStyles.AddRange(res.Value as List<Style>);
-                            resources[res.Key] = mergedClassStyles;
-                        }
+                    if (ve.XamlResources != null)
+                    {
+                        foreach (KeyValuePair<string, object> res in ve.XamlResources.MergedResources)
+                            if (!resources.ContainsKey(res.Key))
+                                resources.Add(res.Key, res.Value);
+                            else if (res.Key.StartsWith(Style.StyleClassPrefix, StringComparison.Ordinal))
+                            {
+                                var mergedClassStyles = new List<Style>(resources[res.Key] as List<Style>);
+                                mergedClassStyles.AddRange(res.Value as List<Style>);
+                                resources[res.Key] = mergedClassStyles;
+                            }
+                    }
                 }
                 var app = element as Application;
                 if (app != null && app.SystemResources != null)
@@ -48,7 +51,7 @@ namespace Tizen.NUI.Binding
             while (element != null)
             {
                 var ve = element as IResourcesProvider;
-                if (ve != null && ve.IsResourcesCreated && ve.XamlResources.TryGetValue(key, out value))
+                if (ve != null && ve.IsResourcesCreated && ve.XamlResources != null && ve.XamlResources.TryGetValue(key, out value))
                     return true;
                 var app = element as Application;
                 if (app != null && app.SystemResources != null && app.SystemResources.TryGetValue(key, out value))
index 09e3d8c..976471a 100755 (executable)
@@ -613,7 +613,7 @@ namespace Tizen.NUI
             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
-            LayersChildren.Add(layer);
+            LayersChildren?.Add(layer);
         }
 
         internal void Remove(Layer layer)
@@ -621,7 +621,7 @@ namespace Tizen.NUI
             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
-            LayersChildren.Remove(layer);
+            LayersChildren?.Remove(layer);
         }
 
         /// <summary>
@@ -684,7 +684,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public Layer GetLayer(uint depth)
         {
-            if (depth < LayersChildren.Count)
+            if (depth < LayersChildren?.Count)
             {
                 Layer ret = LayersChildren[Convert.ToInt32(depth)];
                 return ret;
@@ -703,7 +703,7 @@ namespace Tizen.NUI
             {
                 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-                LayersChildren.Add(_rootLayer);
+                LayersChildren?.Add(_rootLayer);
             }
             return _rootLayer;
         }
@@ -1600,7 +1600,7 @@ namespace Tizen.NUI
             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
-            LayersChildren.Add(layer);
+            LayersChildren?.Add(layer);
         }
 
         /// <summary>
@@ -1613,7 +1613,7 @@ namespace Tizen.NUI
             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
-            LayersChildren.Remove(layer);
+            LayersChildren?.Remove(layer);
         }
 
         /// <summary>
index 0e2303e..16c6f13 100755 (executable)
@@ -81,7 +81,7 @@ namespace Tizen.NUI.Binding
             if (type != null)
                 _mergedInstance = s_instances.GetValue(type, (key) => (ResourceDictionary)Activator.CreateInstance(key));
             else
-                _mergedInstance = DependencyService.Get<IResourcesLoader>().CreateFromResource<ResourceDictionary>(resourcePath, assembly, lineInfo);
+                _mergedInstance = DependencyService.Get<IResourcesLoader>()?.CreateFromResource<ResourceDictionary>(resourcePath, assembly, lineInfo);
             OnValuesChanged(_mergedInstance.ToArray());
         }