Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        static private void WritePropertyString(BsonSerializer file, DesignerPropertyInfo property, object o) {
            string str = property.GetExportValue(o);

            file.WriteAttributeString(property.Property.Name, str);
        }