Exemple #1
0
                    public static DefaultPropertyValueVerbalizer GetVerbalizer()
                    {
                        DefaultPropertyValueVerbalizer retVal = myCache;

                        if (retVal != null)
                        {
                            retVal = System.Threading.Interlocked.CompareExchange <DefaultPropertyValueVerbalizer>(ref myCache, null as DefaultPropertyValueVerbalizer, retVal);
                        }
                        if (retVal == null)
                        {
                            retVal = new DefaultPropertyValueVerbalizer();
                        }
                        return(retVal);
                    }
Exemple #2
0
                IEnumerable <CustomChildVerbalizer> IVerbalizeExtensionChildren.GetExtensionChildVerbalizations(object parentElement, IVerbalizeFilterChildren filter, VerbalizationSign sign)
                {
                    // Get the instance data local and release the cached iterator
                    IORMExtendableElement propertyOwner = parentElement as IORMExtendableElement;

                    if (propertyOwner != null)
                    {
                        PropertyDefinitionFilter propertyFilter           = myPropertyFilter;
                        LinkedElementCollection <ModelElement> extensions = null;
                        foreach (CustomPropertyDefinition customPropertyDefinition in propertyOwner.Store.ElementDirectory.FindElements <CustomPropertyDefinition>())
                        {
                            object defaultValue;
                            string defaultValueString;
                            if (!customPropertyDefinition.VerbalizeDefaultValue ||
                                null == (defaultValue = customPropertyDefinition.DefaultValue) ||
                                (null != (defaultValueString = defaultValue as string) && defaultValueString.Length == 0) ||
                                (propertyFilter != null && !propertyFilter(propertyOwner, customPropertyDefinition)))
                            {
                                continue;
                            }
                            bool haveMatchingProperty = false;
                            foreach (ModelElement extensionElement in extensions ?? (extensions = propertyOwner.ExtensionCollection))
                            {
                                CustomProperty customProperty = extensionElement as CustomProperty;
                                if (customProperty != null && customProperty.CustomPropertyDefinition == customPropertyDefinition)
                                {
                                    haveMatchingProperty = true;
                                    break;
                                }
                            }
                            if (!haveMatchingProperty)
                            {
                                DefaultPropertyValueVerbalizer verbalizer = DefaultPropertyValueVerbalizer.GetVerbalizer();
                                verbalizer.Attach(customPropertyDefinition);
                                yield return(CustomChildVerbalizer.VerbalizeInstance(verbalizer, true));
                            }
                        }
                    }
                }
					public static DefaultPropertyValueVerbalizer GetVerbalizer()
					{
						DefaultPropertyValueVerbalizer retVal = myCache;
						if (retVal != null)
						{
							retVal = System.Threading.Interlocked.CompareExchange<DefaultPropertyValueVerbalizer>(ref myCache, null as DefaultPropertyValueVerbalizer, retVal);
						}
						if (retVal == null)
						{
							retVal = new DefaultPropertyValueVerbalizer();
						}
						return retVal;
					}