示例#1
0
        protected dynamic CreateSerializedObjectViewModel(SerializedObject serializedObject)
        {
            ViewModelBuilder viewModelBuilder = new ViewModelBuilder();

            viewModelBuilder.BuildId(serializedObject.ObjectId);
            viewModelBuilder.BuildClassId(serializedObject.ClassId);

            foreach (SerializedProperty serializedProperty in JsonConvert.DeserializeObject <IEnumerable <SerializedProperty> >(serializedObject.SerializedProperties))
            {
                if (serializedProperty.Member.PropertyDataTypeStorageDataType == StorageDataType.Integer)
                {
                    viewModelBuilder.BuildProperty(serializedProperty.Member.Code, serializedProperty.IntegerValue);
                }

                else if (serializedProperty.Member.PropertyDataTypeStorageDataType == StorageDataType.Decimal)
                {
                    viewModelBuilder.BuildProperty(serializedProperty.Member.Code, serializedProperty.DecimalValue);
                }

                else if (serializedProperty.Member.PropertyDataTypeStorageDataType == StorageDataType.String)
                {
                    viewModelBuilder.BuildProperty(serializedProperty.Member.Code, serializedProperty.StringValue);
                }

                else if (serializedProperty.Member.PropertyDataTypeStorageDataType == StorageDataType.DateTime)
                {
                    viewModelBuilder.BuildProperty(serializedProperty.Member.Code, serializedProperty.DateTimeValue);
                }
            }

            return(viewModelBuilder.Build());
        }