[NUI] Fix CA2000 issues for Visual (#2491)
authorzhouleonlei <56956725+zhouleonlei@users.noreply.github.com>
Tue, 5 Jan 2021 09:03:46 +0000 (17:03 +0800)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Mon, 11 Jan 2021 05:49:43 +0000 (14:49 +0900)
Co-authored-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/public/Visuals/AnimatedImageVisual.cs
src/Tizen.NUI/src/public/Visuals/GradientVisual.cs
src/Tizen.NUI/src/public/Visuals/MeshVisual.cs
src/Tizen.NUI/src/public/Visuals/PrimitiveVisual.cs

index beb8907..f4d2957 100755 (executable)
@@ -165,10 +165,14 @@ namespace Tizen.NUI
             if (_urls != null)
             {
                 _outputVisualMap = new PropertyMap();
-                _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.AnimatedImage));
+                PropertyValue temp = new PropertyValue((int)Visual.Type.AnimatedImage);
+                _outputVisualMap.Add(Visual.Property.Type, temp);
+                temp.Dispose();
                 if (_urls.Count == 1)
                 {
-                    _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_urls[0]));
+                    temp = new PropertyValue(_urls[0]);
+                    _outputVisualMap.Add(ImageVisualProperty.URL, temp);
+                    temp.Dispose();
                 }
                 else
                 {
@@ -177,12 +181,35 @@ namespace Tizen.NUI
                     {
                         urlArray.Add(new PropertyValue(url));
                     }
-                    _outputVisualMap.Add(ImageVisualProperty.URL, (new PropertyValue(urlArray)));
+                    temp = new PropertyValue(urlArray);
+                    _outputVisualMap.Add(ImageVisualProperty.URL, temp);
+                    temp.Dispose();
+                    urlArray.Dispose();
+                }
+                if (_batchSize != null)
+                {
+                    temp = new PropertyValue((int)_batchSize);
+                    _outputVisualMap.Add(ImageVisualProperty.BatchSize, temp);
+                    temp.Dispose();
+                }
+                if (_cacheSize != null)
+                {
+                    temp = new PropertyValue((int)_cacheSize);
+                    _outputVisualMap.Add(ImageVisualProperty.CacheSize, temp);
+                    temp.Dispose();
+                }
+                if (_frameDelay != null)
+                {
+                    temp = new PropertyValue((float)_frameDelay);
+                    _outputVisualMap.Add(ImageVisualProperty.FrameDelay, temp);
+                    temp.Dispose();
+                }
+                if (_loopCount != null)
+                {
+                    temp = new PropertyValue((int)_loopCount);
+                    _outputVisualMap.Add(ImageVisualProperty.LoopCount, temp);
+                    temp.Dispose();
                 }
-                if (_batchSize != null) { _outputVisualMap.Add(ImageVisualProperty.BatchSize, new PropertyValue((int)_batchSize)); }
-                if (_cacheSize != null) { _outputVisualMap.Add(ImageVisualProperty.CacheSize, new PropertyValue((int)_cacheSize)); }
-                if (_frameDelay != null) { _outputVisualMap.Add(ImageVisualProperty.FrameDelay, new PropertyValue((float)_frameDelay)); }
-                if (_loopCount != null) { _outputVisualMap.Add(ImageVisualProperty.LoopCount, new PropertyValue((int)_loopCount)); }
                 base.ComposingPropertyMap();
             }
         }
index f4537c4..0970529 100755 (executable)
@@ -199,15 +199,62 @@ namespace Tizen.NUI
             if (((_startPosition != null && _endPosition != null) || (_center != null && _radius != null)) && _stopColor != null)
             {
                 _outputVisualMap = new PropertyMap();
-                _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Gradient));
-                _outputVisualMap.Add(GradientVisualProperty.StopColor, new PropertyValue(_stopColor));
-                if (_startPosition != null) { _outputVisualMap.Add(GradientVisualProperty.StartPosition, new PropertyValue(_startPosition)); }
-                if (_endPosition != null) { _outputVisualMap.Add(GradientVisualProperty.EndPosition, new PropertyValue(_endPosition)); }
-                if (_center != null) { _outputVisualMap.Add(GradientVisualProperty.Center, new PropertyValue(_center)); }
-                if (_radius != null) { _outputVisualMap.Add(GradientVisualProperty.Radius, new PropertyValue((float)_radius)); }
-                if (_stopOffset != null) { _outputVisualMap.Add(GradientVisualProperty.StopOffset, new PropertyValue(_stopOffset)); }
-                if (_units != null) { _outputVisualMap.Add(GradientVisualProperty.Units, new PropertyValue((int)_units)); }
-                if (_spreadMethod != null) { _outputVisualMap.Add(GradientVisualProperty.SpreadMethod, new PropertyValue((int)_spreadMethod)); }
+                PropertyValue temp = new PropertyValue((int)Visual.Type.Gradient);
+                _outputVisualMap.Add(Visual.Property.Type, temp);
+                temp.Dispose();
+
+                temp = new PropertyValue(_stopColor);
+                _outputVisualMap.Add(GradientVisualProperty.StopColor, temp);
+                temp.Dispose();
+
+                if (_startPosition != null)
+                {
+                    temp = new PropertyValue(_startPosition);
+                    _outputVisualMap.Add(GradientVisualProperty.StartPosition, temp);
+                    temp.Dispose();
+                }
+
+                if (_endPosition != null)
+                {
+                    temp = new PropertyValue(_endPosition);
+                    _outputVisualMap.Add(GradientVisualProperty.EndPosition, temp);
+                    temp.Dispose();
+                }
+
+                if (_center != null)
+                {
+                    temp = new PropertyValue(_center);
+                    _outputVisualMap.Add(GradientVisualProperty.Center, temp);
+                    temp.Dispose();
+                }
+
+                if (_radius != null)
+                {
+                    temp = new PropertyValue((float)_radius);
+                    _outputVisualMap.Add(GradientVisualProperty.Radius, temp);
+                    temp.Dispose();
+                }
+
+                if (_stopOffset != null)
+                {
+                    temp = new PropertyValue(_stopOffset);
+                    _outputVisualMap.Add(GradientVisualProperty.StopOffset, temp);
+                    temp.Dispose();
+                }
+
+                if (_units != null)
+                {
+                    temp = new PropertyValue((int)_units);
+                    _outputVisualMap.Add(GradientVisualProperty.Units, temp);
+                    temp.Dispose();
+                }
+
+                if (_spreadMethod != null)
+                {
+                    temp = new PropertyValue((int)_spreadMethod);
+                    _outputVisualMap.Add(GradientVisualProperty.SpreadMethod, temp);
+                    temp.Dispose();
+                }
                 base.ComposingPropertyMap();
             }
         }
index 51729fd..f19ead1 100755 (executable)
@@ -182,13 +182,44 @@ namespace Tizen.NUI
             if (_objectURL != null)
             {
                 _outputVisualMap = new PropertyMap();
-                _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Mesh));
-                _outputVisualMap.Add(MeshVisualProperty.ObjectURL, new PropertyValue(_objectURL));
-                if (_materialtURL != null) { _outputVisualMap.Add(MeshVisualProperty.MaterialtURL, new PropertyValue(_materialtURL)); }
-                if (_texturesPath != null) { _outputVisualMap.Add(MeshVisualProperty.TexturesPath, new PropertyValue(_texturesPath)); }
-                if (_shadingMode != null) { _outputVisualMap.Add(MeshVisualProperty.ShadingMode, new PropertyValue((int)_shadingMode)); }
-                if (_useMipmapping != null) { _outputVisualMap.Add(MeshVisualProperty.UseMipmapping, new PropertyValue((bool)_useMipmapping)); }
-                if (_useSoftNormals != null) { _outputVisualMap.Add(MeshVisualProperty.UseSoftNormals, new PropertyValue((bool)_useSoftNormals)); }
+                PropertyValue temp = new PropertyValue((int)Visual.Type.Mesh);
+                _outputVisualMap.Add(Visual.Property.Type, temp);
+                temp.Dispose();
+
+                temp = new PropertyValue(_objectURL);
+                _outputVisualMap.Add(MeshVisualProperty.ObjectURL, temp);
+                temp.Dispose();
+
+                if (_materialtURL != null)
+                {
+                    temp = new PropertyValue(_materialtURL);
+                    _outputVisualMap.Add(MeshVisualProperty.MaterialtURL, temp);
+                    temp.Dispose();
+                }
+                if (_texturesPath != null)
+                {
+                    temp = new PropertyValue(_texturesPath);
+                    _outputVisualMap.Add(MeshVisualProperty.TexturesPath, temp);
+                    temp.Dispose();
+                }
+                if (_shadingMode != null)
+                {
+                    temp = new PropertyValue((int)_shadingMode);
+                    _outputVisualMap.Add(MeshVisualProperty.ShadingMode, temp);
+                    temp.Dispose();
+                }
+                if (_useMipmapping != null)
+                {
+                    temp = new PropertyValue((bool)_useMipmapping);
+                    _outputVisualMap.Add(MeshVisualProperty.UseMipmapping, temp);
+                    temp.Dispose();
+                }
+                if (_useSoftNormals != null)
+                {
+                    temp = new PropertyValue((bool)_useSoftNormals);
+                    _outputVisualMap.Add(MeshVisualProperty.UseSoftNormals, temp);
+                    temp.Dispose();
+                }
                 base.ComposingPropertyMap();
             }
         }
index 959545d..48c08a5 100755 (executable)
@@ -311,20 +311,94 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         protected override void ComposingPropertyMap()
         {
-            _outputVisualMap = new PropertyMap(); ;
-            _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Primitive));
-            if (_shape != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Shape, new PropertyValue((int)_shape)); }
-            if (_mixColorForPrimitiveVisual != null) { _outputVisualMap.Add(PrimitiveVisualProperty.MixColor, new PropertyValue(_mixColorForPrimitiveVisual)); }
-            if (_slices != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Slices, new PropertyValue((int)_slices)); }
-            if (_stacks != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Stacks, new PropertyValue((int)_stacks)); }
-            if (_scaleTopRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleTopRadius, new PropertyValue((float)_scaleTopRadius)); }
-            if (_scaleBottomRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleBottomRadius, new PropertyValue((float)_scaleBottomRadius)); }
-            if (_scaleHeight != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleHeight, new PropertyValue((float)_scaleHeight)); }
-            if (_scaleRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleRadius, new PropertyValue((float)_scaleRadius)); }
-            if (_scaleDimensions != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(_scaleDimensions)); }
-            if (_bevelPercentage != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelPercentage, new PropertyValue((float)_bevelPercentage)); }
-            if (_bevelSmoothness != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelSmoothness, new PropertyValue((float)_bevelSmoothness)); }
-            if (_lightPosition != null) { _outputVisualMap.Add(PrimitiveVisualProperty.LightPosition, new PropertyValue(_lightPosition)); }
+            _outputVisualMap = new PropertyMap();
+            PropertyValue temp = new PropertyValue((int)Visual.Type.Primitive);
+            _outputVisualMap.Add(Visual.Property.Type, temp);
+            temp.Dispose();
+
+            if (_shape != null)
+            {
+                temp = new PropertyValue((int)_shape);
+                _outputVisualMap.Add(PrimitiveVisualProperty.Shape, temp);
+                temp.Dispose();
+            }
+
+            if (_mixColorForPrimitiveVisual != null)
+            {
+                temp = new PropertyValue(_mixColorForPrimitiveVisual);
+                _outputVisualMap.Add(PrimitiveVisualProperty.MixColor, temp);
+                temp.Dispose();
+            }
+
+            if (_slices != null)
+            {
+                temp = new PropertyValue((int)_slices);
+                _outputVisualMap.Add(PrimitiveVisualProperty.Slices, temp);
+                temp.Dispose();
+            }
+
+            if (_stacks != null)
+            {
+                temp = new PropertyValue((int)_stacks);
+                _outputVisualMap.Add(PrimitiveVisualProperty.Stacks, temp);
+                temp.Dispose();
+            }
+
+            if (_scaleTopRadius != null)
+            {
+                temp = new PropertyValue((float)_scaleTopRadius);
+                _outputVisualMap.Add(PrimitiveVisualProperty.ScaleTopRadius, temp);
+                temp.Dispose();
+            }
+
+            if (_scaleBottomRadius != null)
+            {
+                temp = new PropertyValue((float)_scaleBottomRadius);
+                _outputVisualMap.Add(PrimitiveVisualProperty.ScaleBottomRadius, temp);
+                temp.Dispose();
+            }
+
+            if (_scaleHeight != null)
+            {
+                temp = new PropertyValue((float)_scaleHeight);
+                _outputVisualMap.Add(PrimitiveVisualProperty.ScaleHeight, temp);
+                temp.Dispose();
+            }
+
+            if (_scaleRadius != null)
+            {
+                temp = new PropertyValue((float)_scaleRadius);
+                _outputVisualMap.Add(PrimitiveVisualProperty.ScaleRadius, temp);
+                temp.Dispose();
+            }
+
+            if (_scaleDimensions != null)
+            {
+                temp = new PropertyValue(_scaleDimensions);
+                _outputVisualMap.Add(PrimitiveVisualProperty.ScaleDimensions, temp);
+                temp.Dispose();
+            }
+
+            if (_bevelPercentage != null)
+            {
+                temp = new PropertyValue((float)_bevelPercentage);
+                _outputVisualMap.Add(PrimitiveVisualProperty.BevelPercentage, temp);
+                temp.Dispose();
+            }
+
+            if (_bevelSmoothness != null)
+            {
+                temp = new PropertyValue((float)_bevelSmoothness);
+                _outputVisualMap.Add(PrimitiveVisualProperty.BevelSmoothness, temp);
+                temp.Dispose();
+            }
+
+            if (_lightPosition != null)
+            {
+                temp = new PropertyValue(_lightPosition);
+                _outputVisualMap.Add(PrimitiveVisualProperty.LightPosition, temp);
+                temp.Dispose();
+            }
             base.ComposingPropertyMap();
         }
     }