Skip to content
GitLab
Menu
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
Mar 28, 2014
by
tebjan
Browse files
try unboxed checks for attribute changed events
parent
f03ac5bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Source/SvgAttributeCollection.cs
View file @
38015799
...
...
@@ -91,9 +91,12 @@ namespace Svg
{
if
(
base
.
ContainsKey
(
attributeName
))
{
var
oldVal
=
base
[
attributeName
];
base
[
attributeName
]
=
value
;
if
(
oldVal
!=
value
)
OnAttributeChanged
(
attributeName
,
value
);
var
oldVal
=
base
[
attributeName
];
if
(
TryUnboxAndCheck
(
oldVal
,
value
))
{
base
[
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>
...
...
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