public virtual ConcreteOf2Abstracts ToConcreteOf2Abstracts(
			ImmutableObjectGraph.Optional<System.Int32> abstract2Field1 = default(ImmutableObjectGraph.Optional<System.Int32>),
			ImmutableObjectGraph.Optional<System.Int32> abstract2Field2 = default(ImmutableObjectGraph.Optional<System.Int32>),
			ImmutableObjectGraph.Optional<System.Int32> concreteField1 = default(ImmutableObjectGraph.Optional<System.Int32>),
			ImmutableObjectGraph.Optional<System.Int32> concreteField2 = default(ImmutableObjectGraph.Optional<System.Int32>))
        {
            ConcreteOf2Abstracts that = this as ConcreteOf2Abstracts;
            if (that != null && this.GetType().IsEquivalentTo(typeof(ConcreteOf2Abstracts))) {
                if ((!abstract2Field1.IsDefined || abstract2Field1.Value == that.Abstract2Field1) &&
                    (!abstract2Field2.IsDefined || abstract2Field2.Value == that.Abstract2Field2) &&
                    (!concreteField1.IsDefined || concreteField1.Value == that.ConcreteField1) &&
                    (!concreteField2.IsDefined || concreteField2.Value == that.ConcreteField2)) {
                    return that;
                }
            }

            return ConcreteOf2Abstracts.CreateWithIdentity(
                abstract1Field1: Optional.For(this.Abstract1Field1),
                abstract1Field2: Optional.For(this.Abstract1Field2),
                identity: this.Identity,
                abstract2Field1: abstract2Field1,
                abstract2Field2: abstract2Field2,
                concreteField1: concreteField1,
                concreteField2: concreteField2);
        }
        public static A Create(
			ImmutableObjectGraph.Optional<System.Int32> field1 = default(ImmutableObjectGraph.Optional<System.Int32>))
        {
            var identity = Optional.For(NewIdentity());
            return DefaultInstance.WithFactory(
                field1: Optional.For(field1.GetValueOrDefault(DefaultInstance.Field1)),
                identity: Optional.For(identity.GetValueOrDefault(DefaultInstance.Identity)));
        }
        public static ReqAndHierL1 Create(
			System.String l1Field2,
			ImmutableObjectGraph.Optional<System.String> l1Field1 = default(ImmutableObjectGraph.Optional<System.String>))
        {
            var identity = Optional.For(NewIdentity());
            return DefaultInstance.WithFactory(
                l1Field1: Optional.For(l1Field1.GetValueOrDefault(DefaultInstance.L1Field1)),
                l1Field2: Optional.For(l1Field2),
                identity: Optional.For(identity.GetValueOrDefault(DefaultInstance.Identity)));
        }
        public static Contact Create(
			ImmutableObjectGraph.Optional<System.String> name = default(ImmutableObjectGraph.Optional<System.String>),
			ImmutableObjectGraph.Optional<System.String> email = default(ImmutableObjectGraph.Optional<System.String>))
        {
            var identity = Optional.For(NewIdentity());
            return DefaultInstance.WithFactory(
                name: Optional.For(name.GetValueOrDefault(DefaultInstance.Name)),
                email: Optional.For(email.GetValueOrDefault(DefaultInstance.Email)),
                identity: Optional.For(identity.GetValueOrDefault(DefaultInstance.Identity)));
        }
        /// <summary>Initializes a new instance of the Abstract1 class.</summary>
        protected Abstract1(
			System.UInt32 identity,
			System.Int32 abstract1Field1,
			System.Int32 abstract1Field2,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.abstract1Field1 = abstract1Field1;
            this.abstract1Field2 = abstract1Field2;
        }
        public static Fruit Create(
			ImmutableObjectGraph.Optional<System.String> color = default(ImmutableObjectGraph.Optional<System.String>),
			ImmutableObjectGraph.Optional<System.Int32> skinThickness = default(ImmutableObjectGraph.Optional<System.Int32>))
        {
            var identity = Optional.For(NewIdentity());
            return DefaultInstance.WithFactory(
                color: Optional.For(color.GetValueOrDefault(DefaultInstance.Color)),
                skinThickness: Optional.For(skinThickness.GetValueOrDefault(DefaultInstance.SkinThickness)),
                identity: Optional.For(identity.GetValueOrDefault(DefaultInstance.Identity)));
        }
        /// <summary>Initializes a new instance of the A class.</summary>
        protected A(
			System.UInt32 identity,
			System.Int32 field1,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.field1 = field1;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        /// <summary>Initializes a new instance of the Contact class.</summary>
        protected Contact(
			System.UInt32 identity,
			System.String name,
			System.String email,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.name = name;
            this.email = email;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        /// <summary>Initializes a new instance of the Fruit class.</summary>
        protected Fruit(
			System.UInt32 identity,
			System.String color,
			System.Int32 skinThickness,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.color = color;
            this.skinThickness = skinThickness;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        /// <summary>Initializes a new instance of the ReqAndHierL1 class.</summary>
        protected ReqAndHierL1(
			System.UInt32 identity,
			System.String l1Field1,
			System.String l1Field2,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.l1Field1 = l1Field1;
            this.l1Field2 = l1Field2;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        public virtual B ToB(
			ImmutableObjectGraph.Optional<System.Int32> field2 = default(ImmutableObjectGraph.Optional<System.Int32>))
        {
            B that = this as B;
            if (that != null && this.GetType().IsEquivalentTo(typeof(B))) {
                if ((!field2.IsDefined || field2.Value == that.Field2)) {
                    return that;
                }
            }

            return B.CreateWithIdentity(
                field1: Optional.For(this.Field1),
                identity: this.Identity,
                field2: field2);
        }
        /// <summary>Initializes a new instance of the EmptyDerivedFromNonEmptyBase class.</summary>
        protected EmptyDerivedFromNonEmptyBase(
			System.UInt32 identity,
			System.Boolean oneField,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
            : base(identity: identity,
				oneField: oneField)
        {
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        /// <summary>Returns a new instance of this object with any number of properties changed.</summary>
        public EmptyDerivedFromAbstract With(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>))
        {
            return (EmptyDerivedFromAbstract)this.WithCore(
                oneField: oneField);
        }
        internal static EmptyDerived CreateWithIdentity(
				ImmutableObjectGraph.Optional<System.UInt32> identity = default(ImmutableObjectGraph.Optional<System.UInt32>))
        {
            if (!identity.IsDefined) {
                identity = NewIdentity();
            }

            return DefaultInstance;
        }
        /// <summary>Initializes a new instance of the EmptyDerived class.</summary>
        protected EmptyDerived(
			System.UInt32 identity,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
            : base(identity: identity)
        {
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        /// <summary>Returns a new instance of this object with any number of properties changed.</summary>
        private NonEmptyBase WithFactory(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>),
			ImmutableObjectGraph.Optional<System.UInt32> identity = default(ImmutableObjectGraph.Optional<System.UInt32>))
        {
            if (
                (identity.IsDefined && identity.Value != this.Identity) ||
                (oneField.IsDefined && oneField.Value != this.OneField)) {
                return new NonEmptyBase(
                    identity: identity.GetValueOrDefault(this.Identity),
                    oneField: oneField.GetValueOrDefault(this.OneField));
            } else {
                return this;
            }
        }
        internal static NonEmptyBase CreateWithIdentity(
				ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>),
				ImmutableObjectGraph.Optional<System.UInt32> identity = default(ImmutableObjectGraph.Optional<System.UInt32>))
        {
            if (!identity.IsDefined) {
                identity = NewIdentity();
            }

            return DefaultInstance.WithFactory(
                    oneField: Optional.For(oneField.GetValueOrDefault(DefaultInstance.OneField)),
                    identity: Optional.For(identity.GetValueOrDefault(DefaultInstance.Identity)));
        }
        /// <summary>Returns a new instance of this object with any number of properties changed.</summary>
        public NonEmptyBase With(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>))
        {
            return (NonEmptyBase)this.WithCore(
                oneField: oneField);
        }
        /// <summary>Initializes a new instance of the NonEmptyBase class.</summary>
        protected NonEmptyBase(
			System.UInt32 identity,
			System.Boolean oneField,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.oneField = oneField;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        internal static EmptyDerivedFromNonEmptyBase CreateWithIdentity(
				ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>),
				ImmutableObjectGraph.Optional<System.UInt32> identity = default(ImmutableObjectGraph.Optional<System.UInt32>))
        {
            if (!identity.IsDefined) {
                identity = NewIdentity();
            }

            return DefaultInstance;
        }
        /// <summary>Returns a new instance of this object with any number of properties changed.</summary>
        protected override NonEmptyBase WithCore(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>))
        {
            return this.WithFactory(
                oneField: oneField);
        }
        /// <summary>Returns a new instance of this object with any number of properties changed.</summary>
        public NotSoEmptyDerived With(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>))
        {
            return (NotSoEmptyDerived)this.WithCore(
                oneField: oneField);
        }
        public static NonEmptyBase Create(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>))
        {
            var identity = Optional.For(NewIdentity());
            return DefaultInstance.WithFactory(
                oneField: Optional.For(oneField.GetValueOrDefault(DefaultInstance.OneField)),
                identity: Optional.For(identity.GetValueOrDefault(DefaultInstance.Identity)));
        }
        /// <summary>Returns a new instance of this object with any number of properties changed.</summary>
        public AbstractNonEmpty With(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>))
        {
            return (AbstractNonEmpty)this.WithCore(
                oneField: oneField);
        }
        /// <summary>Initializes a new instance of the AbstractNonEmpty class.</summary>
        protected AbstractNonEmpty(
			System.UInt32 identity,
			System.Boolean oneField,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.oneField = oneField;
        }
        /// <summary>Returns a new instance of this object with any number of properties changed.</summary>
        protected abstract AbstractNonEmpty WithCore(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>));
        /// <summary>Returns a new instance of this object with any number of properties changed.</summary>
        protected virtual NonEmptyBase WithCore(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>))
        {
            var identity = default(ImmutableObjectGraph.Optional<System.UInt32>);
            return this.WithFactory(
                oneField: Optional.For(oneField.GetValueOrDefault(this.OneField)),
                identity: Optional.For(identity.GetValueOrDefault(this.Identity)));
        }
        /// <summary>Initializes a new instance of the Empty class.</summary>
        protected Empty(
			System.UInt32 identity,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        /// <summary>Initializes a new instance of the NotSoEmptyDerived class.</summary>
        protected NotSoEmptyDerived(
			System.UInt32 identity,
			System.Boolean oneField,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
            : base(identity: identity)
        {
            this.oneField = oneField;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        public virtual NotSoEmptyDerived ToNotSoEmptyDerived(
			ImmutableObjectGraph.Optional<System.Boolean> oneField = default(ImmutableObjectGraph.Optional<System.Boolean>))
        {
            NotSoEmptyDerived that = this as NotSoEmptyDerived;
            if (that != null && this.GetType().IsEquivalentTo(typeof(NotSoEmptyDerived))) {
                if ((!oneField.IsDefined || oneField.Value == that.OneField)) {
                    return that;
                }
            }

            return NotSoEmptyDerived.CreateWithIdentity(
                identity: this.Identity,
                oneField: oneField);
        }