Exemple #1
0
        private void Write(ConcreteNavigationCollectionAccessorProperty property)
        {
            WriteDeclaration(property);

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

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

                _("set");

                using (_builder.IndentBraced)
                {
                    WriteInitializationEnforcer();

                    _("{0}.Clear();", property.Name);
                    _("if (value != null)");
                    using (_builder.IndentBraced)
                    {
                        _("foreach (var i in value)");
                        using (_builder.IndentBraced)
                        {
                            _("{0}.Add(i);", property.Name);
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void Write(ConcreteNavigationCollectionAccessorProperty property)
        {
            WriteDeclaration(property);

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

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

                _("set");

                using (_builder.IndentBraced)
                {
                    WriteInitializationEnforcer();

                    _("{0}.Clear();", property.Name);
                    _("if (value != null)");
                    using (_builder.IndentBraced)
                    {
                        _("foreach (var i in value)");
                        using (_builder.IndentBraced)
                        {
                            _("{0}.Add(i);", property.Name);
                        }
                    }
                }
            }
        }
Exemple #3
0
 public static ConcreteNavigationAccessorProperty AsNavigationAccessorProperty(OdcmProperty odcmProperty)
 {
     return(odcmProperty.IsCollection
         ? ConcreteNavigationCollectionAccessorProperty.ForConcrete(odcmProperty)
         : ConcreteNavigationAccessorProperty.ForConcrete(odcmProperty));
 }