コード例 #1
0
        private static object GetPropertyValue(VersionedSchemaObjectBase obj, SchemaPropertyDefine pd)
        {
            try
            {
                object defaultValue = TypeCreator.GetTypeDefaultValue(pd.DataType.ToRealType());

                object result = defaultValue;

                if (pd.DataType == PropertyDataType.Enum)
                {
                    result = obj.Properties.GetValue(pd.Name, (object)null);
                }
                else
                {
                    result = obj.Properties.GetValue(pd.Name, defaultValue);
                }

                return(result);
            }
            catch (System.Exception ex)
            {
                throw new SystemSupportException(string.Format("生成Snapshot或全文检索时,{0}属性值获取错误: {1}", pd.Name, ex.Message),
                                                 ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// 使用指定的容器对象和成员对象 初始化<see cref="SCMemberRelation"/>的新实例
        /// </summary>
        /// <param name="container">容器对象</param>
        /// <param name="member">成员对象</param>
        /// <param name="schemaType"></param>
        public VersionedSchemaRelationBase(VersionedSchemaObjectBase container, VersionedSchemaObjectBase member, string schemaType) :
            base(schemaType)
        {
            container.NullCheck("container");
            member.NullCheck("member");

            this.ContainerID = container.ID;
            this.ID          = member.ID;

            this.ContainerSchemaType = container.SchemaType;
            this.MemberSchemaType    = member.SchemaType;
        }
コード例 #3
0
        public static void SchemaToSqlClauseBuilder <TBuilder>(this VersionedSchemaObjectBase obj, SnapshotModeDefinition constSmd, TBuilder builder) where TBuilder : SqlClauseBuilderIUW <TBuilder>
        {
            if (obj != null && builder != null)
            {
                obj.Schema.Properties.ForEach(pd =>
                                              pd.SnapshotMode.IfSwitchedOn(constSmd, () =>
                                                                           builder.AppendItem(GetFieldName(ORMapping.GetMappingInfo(obj.GetType()), pd), GetPropertyValue(obj, pd))));

                builder.AppendItem("SearchContent", obj.ToFullTextString());
                builder.AppendItem("SchemaType", obj.SchemaType);
                builder.AppendItem("Status", (int)obj.Status);
            }
        }
コード例 #4
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            string schemaType = DictionaryHelper.GetValue(dictionary, "schemaType", string.Empty);

            VersionedSchemaObjectBase schemaObjectBase = CreateInstance(schemaType, dictionary, type, serializer);

            schemaObjectBase.ID               = DictionaryHelper.GetValue(dictionary, "id", string.Empty);;
            schemaObjectBase.Status           = DictionaryHelper.GetValue(dictionary, "status", SchemaObjectStatus.Normal);
            schemaObjectBase.VersionStartTime = DictionaryHelper.GetValue(dictionary, "versionStartTime", DateTime.MinValue);
            schemaObjectBase.VersionEndTime   = DictionaryHelper.GetValue(dictionary, "versionEndTime", DateTime.MinValue);

            if (dictionary.ContainsKey("Properties") == true)
            {
                SchemaPropertyValueCollection propCollection = JSONSerializerExecute.Deserialize <SchemaPropertyValueCollection>(dictionary["Properties"]);
                schemaObjectBase.Properties.Clear();
                schemaObjectBase.Properties.CopyFrom(propCollection);
            }

            return(schemaObjectBase);
        }