25 [Append(Ignore =
true)]
41 internal void CopyProperties<T>(T source, T reference) where T :
AbstractStyle
43 if (source ==
null || GetType() != source.GetType() && GetType() != reference.GetType())
45 throw new StyleException(
"The objects of the source, target and reference for style appending are not of the same type");
47 PropertyInfo[] infos = GetType().GetProperties();
48 PropertyInfo sourceInfo;
49 PropertyInfo referenceInfo;
50 IEnumerable<AppendAttribute> attributes;
51 foreach (PropertyInfo info
in infos)
54 if (attributes.Any() && !HandleProperties(attributes))
58 sourceInfo = source.GetType().GetProperty(info.Name);
59 referenceInfo = reference.GetType().GetProperty(info.Name);
60 if (!sourceInfo.GetValue(source).Equals(referenceInfo.GetValue(reference)))
62 info.SetValue(
this, sourceInfo.GetValue(source));
72 private static bool HandleProperties(IEnumerable<AppendAttribute> attributes)
74 foreach (AppendAttribute attribute
in attributes)
76 if (attribute.Ignore || attribute.NestedProperty)
95 else if (other ==
null || !other.
InternalID.HasValue)
116 return this.GetHashCode() == other.GetHashCode();
126 internal static void AddPropertyAsJson(StringBuilder sb,
string name,
object value,
bool terminate =
false)
128 sb.Append(
'"').Append(name).Append(
"\": ");
131 sb.Append(
"__null__");
135 sb.Append(
'"').Append(value.ToString().Replace(
"\"",
"\\\"")).Append(
'"');