Esempio n. 1
0
        private void Write(StructuralCollectionProperty property)
        {
            WriteDeclaration(property);

            using (_builder.IndentBraced)
            {
                _("get");

                using (_builder.IndentBraced)
                {
                    _("if (this.{0} == default({1}))", property.FieldName, property.Type);

                    using (_builder.IndentBraced)
                    {
                        _("this.{0} = new {1}<{2}>();", property.FieldName,
                          NamesService.GetExtensionTypeName("NonEntityTypeCollectionImpl"), property.InstanceType);
                        _("this.{0}.SetContainer(() => GetContainingEntity(\"{1}\"));", property.FieldName, property.ModelName);
                    }

                    _("return this.{0};", property.FieldName);
                }
                _("set");
                using (_builder.IndentBraced)
                {
                    _("{0}.Clear();", property.Name);
                    _("if (value != null)");

                    using (_builder.IndentBraced)
                    {
                        _("foreach (var i in value)");

                        using (_builder.IndentBraced)
                        {
                            _("{0}.Add(i);", property.Name);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public static StructuralProperty AsConcreteStructuralProperty(OdcmProperty odcmProperty)
 {
     return(odcmProperty.IsCollection
         ? StructuralCollectionProperty.ForConcrete(odcmProperty)
         : StructuralProperty.ForConcrete(odcmProperty));
 }