1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace FunctionalTests.Model
{
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
public class CountryRegion
{
public virtual string CountryRegionCode { get; set; }
public virtual string Name { get; set; }
public virtual DateTime ModifiedDate { get; set; }
public virtual ICollection<CountryRegionCurrency> CountryRegionCurrencies
{
get
{
if (_countryRegionCurrencies == null)
{
var newCollection = new FixupCollection<CountryRegionCurrency>();
newCollection.CollectionChanged += FixupCountryRegionCurrencies;
_countryRegionCurrencies = newCollection;
}
return _countryRegionCurrencies;
}
set
{
if (!ReferenceEquals(_countryRegionCurrencies, value))
{
var previousValue = _countryRegionCurrencies as FixupCollection<CountryRegionCurrency>;
if (previousValue != null)
{
previousValue.CollectionChanged -= FixupCountryRegionCurrencies;
}
_countryRegionCurrencies = value;
var newValue = value as FixupCollection<CountryRegionCurrency>;
if (newValue != null)
{
newValue.CollectionChanged += FixupCountryRegionCurrencies;
}
}
}
}
private ICollection<CountryRegionCurrency> _countryRegionCurrencies;
public virtual ICollection<StateProvince> StateProvinces
{
get
{
if (_stateProvinces == null)
{
var newCollection = new FixupCollection<StateProvince>();
newCollection.CollectionChanged += FixupStateProvinces;
_stateProvinces = newCollection;
}
return _stateProvinces;
}
set
{
if (!ReferenceEquals(_stateProvinces, value))
{
var previousValue = _stateProvinces as FixupCollection<StateProvince>;
if (previousValue != null)
{
previousValue.CollectionChanged -= FixupStateProvinces;
}
_stateProvinces = value;
var newValue = value as FixupCollection<StateProvince>;
if (newValue != null)
{
newValue.CollectionChanged += FixupStateProvinces;
}
}
}
}
private ICollection<StateProvince> _stateProvinces;
private void FixupCountryRegionCurrencies(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (CountryRegionCurrency item in e.NewItems)
{
item.CountryRegion = this;
}
}
if (e.OldItems != null)
{
foreach (CountryRegionCurrency item in e.OldItems)
{
if (ReferenceEquals(item.CountryRegion, this))
{
item.CountryRegion = null;
}
}
}
}
private void FixupStateProvinces(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (StateProvince item in e.NewItems)
{
item.CountryRegion = this;
}
}
if (e.OldItems != null)
{
foreach (StateProvince item in e.OldItems)
{
if (ReferenceEquals(item.CountryRegion, this))
{
item.CountryRegion = null;
}
}
}
}
}
}
|