コード例 #1
0
        public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement)
        {
            Dictionary <string, object> changes = new Dictionary <string, object>();

            PropertyKey refInCache = null;

            if (Id != string.Empty)
            {
                refInCache = CacheHelper.GetPropertyKeyFromCache(memoryCache, Id);

                if (refInCache != null)
                {
                    if (!Name.Equals(refInCache.Name))
                    {
                        changes.Add("Name", Name);
                    }
                    if (!PrimitiveDataType.Equals(refInCache.PrimitiveDataType))
                    {
                        changes.Add("PrimitiveDataType", this.PrimitiveDataType.ToString());
                    }
                    if (!Category.Equals(refInCache.Category))
                    {
                        changes.Add("Category", Category);
                    }
                    if (!Description.Equals(refInCache.Description))
                    {
                        changes.Add("Description", Description);
                    }
                    if (!SpaceId.Equals(refInCache.SpaceId))
                    {
                        changes.Add("SpaceId", SpaceId);
                    }
                    if (!Scope.Equals(refInCache.Scope))
                    {
                        changes.Add("Scope", Scope.ToString());
                    }
                    if (!ValidationData.Equals(refInCache.ValidationData))
                    {
                        changes.Add("ValidationData", ValidationData);
                    }
                    if (!Min.Equals(refInCache.Min))
                    {
                        changes.Add("Min", Min);
                    }
                    if (!Max.Equals(refInCache.Max))
                    {
                        changes.Add("Max", Max);
                    }
                }
                else
                {
                    refInCache = this;

                    if (Name != null)
                    {
                        changes.Add("Name", Name);
                    }
                    changes.Add("PrimitiveDataType", this.PrimitiveDataType.ToString());
                    if (Category != null)
                    {
                        changes.Add("Category", Category);
                    }
                    if (Description != null)
                    {
                        changes.Add("Description", Description);
                    }
                    if (SpaceId != null)
                    {
                        changes.Add("SpaceId", SpaceId);
                    }
                    changes.Add("Scope", Scope.ToString());
                    if (ValidationData != null)
                    {
                        changes.Add("ValidationData", ValidationData);
                    }
                    if (Min != null)
                    {
                        changes.Add("Min", Min);
                    }
                    if (Max != null)
                    {
                        changes.Add("Max", Max);
                    }
                }
            }
            updatedElement = refInCache;
            return(changes);
        }