.DeclaredConstructors.Any(
ci =>
ci.IsPublic && ci.GetParameters().Length != 0 &&
- ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute)))) &&
+ ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof(ParameterAttribute)))) &&
ValidateCtorArguments(type, node, out ctorargname))
value = CreateFromParameterizedConstructor(type, node);
else if (!type.GetTypeInfo().DeclaredConstructors.Any(ci => ci.IsPublic && ci.GetParameters().Length == 0) &&
//this is a trick as the DataTemplate parameterless ctor is internal, and we can't CreateInstance(..., false) on WP7
try
{
- if (type == typeof (DataTemplate))
+ if (type == typeof(DataTemplate))
value = new DataTemplate();
- if (type == typeof (ControlTemplate))
+ if (type == typeof(ControlTemplate))
value = new ControlTemplate();
if (value == null && node.CollectionItems.Any() && node.CollectionItems.First() is ValueNode)
{
.DeclaredConstructors.FirstOrDefault(
ci =>
ci.GetParameters().Length != 0 && ci.IsPublic &&
- ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute))));
+ ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof(ParameterAttribute))));
if (ctorInfo == null)
return true;
foreach (var parameter in ctorInfo.GetParameters())
.DeclaredConstructors.FirstOrDefault(
ci =>
ci.GetParameters().Length != 0 && ci.IsPublic &&
- ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute))));
+ ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof(ParameterAttribute))));
object[] arguments = CreateArgumentsArray(node, ctorInfo);
if (arguments != null)
var factoryMethod = ((string)((ValueNode)node.Properties[XmlName.xFactoryMethod]).Value);
Type[] types = arguments == null ? new Type[0] : arguments.Select(a => a.GetType()).ToArray();
- Func<MethodInfo, bool> isMatch = m => {
+ Func<MethodInfo, bool> isMatch = m =>
+ {
if (m.Name != factoryMethod)
return false;
var p = m.GetParameters();
return false;
if (!m.IsStatic)
return false;
- for (var i = 0; i < p.Length; i++) {
- if ((p [i].ParameterType.IsAssignableFrom(types [i])))
+ for (var i = 0; i < p.Length; i++)
+ {
+ if ((p[i].ParameterType.IsAssignableFrom(types[i])))
continue;
- var op_impl = p[i].ParameterType.GetImplicitConversionOperator(fromType: types[i], toType: p[i].ParameterType)
+ var op_impl = p[i].ParameterType.GetImplicitConversionOperator(fromType: types[i], toType: p[i].ParameterType)
?? types[i].GetImplicitConversionOperator(fromType: types[i], toType: p[i].ParameterType);
if (op_impl == null)
return false;
- arguments [i] = op_impl.Invoke(null, new [] { arguments [i]});
+ arguments[i] = op_impl.Invoke(null, new[] { arguments[i] });
}
return true;
};
public object[] CreateArgumentsArray(IElementNode enode, ConstructorInfo ctorInfo)
{
- if( ctorInfo != null )
+ if (ctorInfo != null)
{
var n = ctorInfo.GetParameters().Length;
var array = new object[n];
{
var parameter = ctorInfo.GetParameters()[i];
var propname =
- parameter?.CustomAttributes?.First(attr => attr.AttributeType == typeof (ParameterAttribute))?
+ parameter?.CustomAttributes?.First(attr => attr.AttributeType == typeof(ParameterAttribute))?
.ConstructorArguments.First()
.Value as string;
var name = new XmlName("", propname);
{
var valuestring = ((ValueNode)node.CollectionItems[0]).Value as string;
- if (nodeType == typeof(SByte)) {
+ if (nodeType == typeof(SByte))
+ {
sbyte retval;
if (sbyte.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(Int16)) {
+ if (nodeType == typeof(Int16))
+ {
short retval;
if (short.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(Int32)) {
+ if (nodeType == typeof(Int32))
+ {
int retval;
if (int.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(Int64)) {
+ if (nodeType == typeof(Int64))
+ {
long retval;
if (long.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(Byte)) {
+ if (nodeType == typeof(Byte))
+ {
byte retval;
if (byte.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(UInt16)) {
+ if (nodeType == typeof(UInt16))
+ {
ushort retval;
if (ushort.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(UInt32)) {
+ if (nodeType == typeof(UInt32))
+ {
uint retval;
if (uint.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(UInt64)) {
+ if (nodeType == typeof(UInt64))
+ {
ulong retval;
if (ulong.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(Single)) {
+ if (nodeType == typeof(Single))
+ {
float retval;
if (float.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof(Double)) {
+ if (nodeType == typeof(Double))
+ {
double retval;
if (double.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof (Boolean))
+ if (nodeType == typeof(Boolean))
{
bool outbool;
if (bool.TryParse(valuestring, out outbool))
return outbool;
}
- if (nodeType == typeof(TimeSpan)) {
+ if (nodeType == typeof(TimeSpan))
+ {
TimeSpan retval;
if (TimeSpan.TryParse(valuestring, CultureInfo.InvariantCulture, out retval))
return retval;
}
- if (nodeType == typeof (char))
+ if (nodeType == typeof(char))
{
char retval;
if (char.TryParse(valuestring, out retval))
return retval;
}
- if (nodeType == typeof (string))
+ if (nodeType == typeof(string))
return valuestring;
- if (nodeType == typeof (decimal))
+ if (nodeType == typeof(decimal))
{
decimal retval;
if (decimal.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
return retval;
}
- else if (nodeType == typeof (Uri))
+ else if (nodeType == typeof(Uri))
{
Uri retval;
if (Uri.TryCreate(valuestring, UriKind.RelativeOrAbsolute, out retval))