Esempio n. 1
0
 /// <summary>
 /// Implements <see cref="IVerbalizeCustomChildren.GetCustomChildVerbalizations"/>.
 /// Explicitly verbalizes extension elements
 /// </summary>
 protected IEnumerable <CustomChildVerbalizer> GetCustomChildVerbalizations(IVerbalizeFilterChildren filter, IDictionary <string, object> verbalizationOptions, VerbalizationSign sign)
 {
     foreach (ModelElement extensionElement in ExtensionCollection)
     {
         IVerbalize verbalizeExtension = extensionElement as IVerbalize;
         if (verbalizeExtension != null)
         {
             yield return(CustomChildVerbalizer.VerbalizeInstance(verbalizeExtension));
         }
     }
 }
Esempio n. 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));
                            }
                        }
                    }
                }