public static KeyValuePair <bool, object> GetDefaultValue(PlatformTypes platformTypes, MemberInfo memberInfo, Type valueType) { object result; if (PlatformNeutralAttributeHelper.TryGetAttributeValue <object>((IEnumerable)platformTypes.GetCustomAttributes(memberInfo), PlatformTypes.DefaultValueAttribute, "Value", out result) && (!valueType.IsValueType && (result == null || valueType.IsAssignableFrom(result.GetType())) || valueType.IsValueType && result != null && valueType.IsAssignableFrom(result.GetType()))) { return(new KeyValuePair <bool, object>(true, result)); } return(PlatformTypeHelper.GetDefaultValue(valueType)); }
public FieldImplementation(FieldReferenceStep referenceStep, System.Reflection.FieldInfo fieldInfo) { this.referenceStep = referenceStep; this.fieldInfo = fieldInfo; this.isResolved = PlatformTypeHelper.GetFieldType(this.fieldInfo) != null; this.serializationVisibility = new DelayedInstance <DesignerSerializationVisibility>(() => PlatformTypeHelper.GetSerializationVisibility(this.PlatformTypes, this.fieldInfo)); this.defaultValue = new DelayedInstance <KeyValuePair <bool, object> >(() => { Type fieldType = PlatformTypeHelper.GetFieldType(this.fieldInfo); if (fieldType == null) { return(new KeyValuePair <bool, object>(false, null)); } return(PlatformTypeHelper.GetDefaultValue(this.PlatformTypes, this.fieldInfo, fieldType)); }); }