Esempio n. 1
0
        /// <summary>
        /// 确保扩展属性被加载
        /// </summary>
        /// <param name="element">当不为<see langword="null"/> 时 ,顺便从其中提取属性值</param>
        private void EnsureExtendedPropertyLoaded(System.Xml.Linq.XElement element)
        {
            if (string.IsNullOrEmpty(this.AUSchemaID) == false)
            {
                var key       = new SchemaPropertyExtensionKey(this.AUSchemaID, this.SchemaType);
                var extension = (SchemaPropertyExtension)MCS.Library.Caching.ObjectContextCache.Instance.GetOrAddNewValue(key, (cache, vk) =>
                {
                    SchemaPropertyExtensionKey k = (SchemaPropertyExtensionKey)vk;
                    return(SchemaPropertyExtensionAdapter.Instance.Load(k.TargetSchemaType, k.SourceID));
                });

                if (extension != null)
                {
                    foreach (var item in extension.Properties)
                    {
                        if (this.Properties.ContainsKey(item.Name) == false)
                        {
                            this.Properties.Add(new SchemaPropertyValue(item));
                        }
                    }

                    if (element != null)
                    {
                        foreach (var item in extension.Properties)
                        {
                            this.Properties[item.Name].FromXElement(element);
                        }
                    }
                }
            }
        }
        public override bool Equals(object obj)
        {
            bool eq = obj is SchemaPropertyExtensionKey;

            if (eq)
            {
                SchemaPropertyExtensionKey key = (SchemaPropertyExtensionKey)obj;
                eq = key.sourceID == this.sourceID && key.targetSchemaType == this.targetSchemaType;
            }

            return(eq);
        }