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
|
// 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 Document
{
public virtual int DocumentID { get; set; }
public virtual string Title { get; set; }
public virtual string FileName { get; set; }
public virtual string FileExtension { get; set; }
public virtual string Revision { get; set; }
public virtual int ChangeNumber { get; set; }
public virtual byte Status { get; set; }
public virtual string DocumentSummary { get; set; }
public virtual byte[] Document1 { get; set; }
public virtual DateTime ModifiedDate { get; set; }
public virtual ICollection<ProductDocument> ProductDocuments
{
get
{
if (_productDocuments == null)
{
var newCollection = new FixupCollection<ProductDocument>();
newCollection.CollectionChanged += FixupProductDocuments;
_productDocuments = newCollection;
}
return _productDocuments;
}
set
{
if (!ReferenceEquals(_productDocuments, value))
{
var previousValue = _productDocuments as FixupCollection<ProductDocument>;
if (previousValue != null)
{
previousValue.CollectionChanged -= FixupProductDocuments;
}
_productDocuments = value;
var newValue = value as FixupCollection<ProductDocument>;
if (newValue != null)
{
newValue.CollectionChanged += FixupProductDocuments;
}
}
}
}
private ICollection<ProductDocument> _productDocuments;
private void FixupProductDocuments(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (ProductDocument item in e.NewItems)
{
item.Document = this;
}
}
if (e.OldItems != null)
{
foreach (ProductDocument item in e.OldItems)
{
if (ReferenceEquals(item.Document, this))
{
item.Document = null;
}
}
}
}
}
}
|