/// <summary> /// WriteProperty /// </summary> /// <param name="file"></param> /// <param name="p"></param> /// <param name="o"></param> static private void WriteProperty(JArray file, DesignerPropertyInfo p, object o) { //WritePropertyValue(file, property, o); string name = p.Property.Name; string str = p.GetExportValue(o); file.Add(new JObject { { name, str } }); }
static private void WritePropertyValue(BsonSerializer file, DesignerPropertyInfo property, object o) { string str = property.GetExportValue(o); string[] tokens = str.Split(' '); string valueString = null; if (tokens.Length == 3 && tokens[0] == "const") { valueString = tokens[2]; } else if (tokens.Length == 1) { valueString = str; } bool bW = false; if (valueString != null) { object obj = property.Property.GetValue(o, null); object v = null; Type valueType = null; VariableDef varType = obj as VariableDef; if (varType != null) { valueType = varType.GetValueType(); } else { RightValueDef rvarType = obj as RightValueDef; if (rvarType != null) { if (rvarType.Method == null) { valueType = rvarType.ValueType; } } else { MethodDef mType = obj as MethodDef; if (mType != null) { Debug.Check(true); } else { valueType = obj.GetType(); } } } if (valueType != null && Plugin.InvokeTypeParser(null, valueType, valueString, (object value) => v = value, null)) { file.WriteAttribute(property.Property.Name, v); bW = true; } } if (!bW) { file.WriteAttributeString(property.Property.Name, str); } }
static private void WritePropertyString(BsonSerializer file, DesignerPropertyInfo property, object o) { string str = property.GetExportValue(o); file.WriteAttributeString(property.Property.Name, str); }
/// <summary> /// WritePropertyValue /// </summary> /// <param name="file"></param> /// <param name="p"></param> /// <param name="o"></param> static private void WritePropertyValue(JArray file, DesignerPropertyInfo p, object o) { string str = p.GetExportValue(o); string[] tokens = str.Split(' '); string valueString = null; if (tokens.Length == 3 && tokens[0] == "const") { valueString = tokens[2]; } else if (tokens.Length == 1) { valueString = str; } bool bW = false; if (valueString != null) { object obj = p.Property.GetValue(o, null); object v = null; Type valueType = null; Behaviac.Design.VariableDef varType = obj as Behaviac.Design.VariableDef; if (varType != null) { valueType = varType.ValueType; } else { Behaviac.Design.RightValueDef rvarType = obj as Behaviac.Design.RightValueDef; if (rvarType != null) { if (rvarType.Method == null) { valueType = rvarType.ValueType; } } else { Behaviac.Design.MethodDef mType = obj as Behaviac.Design.MethodDef; if (mType != null) { Behaviac.Design.Debug.Check(true); } else { valueType = obj.GetType(); } } } if (valueType != null && Plugin.InvokeTypeParser(null, valueType, valueString, (object value) => v = value, null)) { file.Add(new JObject { { p.Property.Name, JsonConvert.SerializeObject(v) } }); bW = true; } } if (!bW) { file.Add(new JObject { { p.Property.Name, str } }); } }