Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
38015799
Commit
38015799
authored
10 years ago
by
tebjan
Browse files
Options
Download
Email Patches
Plain Diff
try unboxed checks for attribute changed events
parent
f03ac5bd
master
netstandard2
nuget2.4.2
nuget2.4.1
nuget2.4
nuget2.3
nuget2.2.2
nuget2.2.1
nuget1.7
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Source/SvgAttributeCollection.cs
+40
-3
Source/SvgAttributeCollection.cs
with
40 additions
and
3 deletions
+40
-3
Source/SvgAttributeCollection.cs
+
40
-
3
View file @
38015799
...
...
@@ -92,8 +92,11 @@ namespace Svg
if
(
base
.
ContainsKey
(
attributeName
))
{
var
oldVal
=
base
[
attributeName
];
if
(
TryUnboxAndCheck
(
oldVal
,
value
))
{
base
[
attributeName
]
=
value
;
if
(
oldVal
!=
value
)
OnAttributeChanged
(
attributeName
,
value
);
OnAttributeChanged
(
attributeName
,
value
);
}
}
else
{
...
...
@@ -103,6 +106,40 @@ namespace Svg
}
}
private
bool
TryUnboxAndCheck
(
object
a
,
object
b
)
{
System
.
Diagnostics
.
Debug
.
WriteLine
(
"object type: "
+
a
.
GetType
().
ToString
());
if
(
IsValueType
(
a
))
{
System
.
Diagnostics
.
Debug
.
WriteLine
(
"is value type"
);
if
(
a
is
SvgUnit
)
return
UnboxAndCheck
<
SvgUnit
>(
a
,
b
);
else
if
(
a
is
bool
)
return
UnboxAndCheck
<
bool
>(
a
,
b
);
else
if
(
a
is
int
)
return
UnboxAndCheck
<
int
>(
a
,
b
);
else
if
(
a
is
float
)
return
UnboxAndCheck
<
float
>(
a
,
b
);
else
return
true
;
}
else
{
return
a
!=
b
;
}
}
private
bool
UnboxAndCheck
<
T
>(
object
a
,
object
b
)
{
return
!((
T
)
a
).
Equals
((
T
)
b
);
}
private
bool
IsValueType
(
object
obj
)
{
return
obj
!=
null
&&
obj
.
GetType
().
IsValueType
;
}
/// <summary>
/// Fired when an Atrribute has changed
/// </summary>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help