├── .gitattributes
├── .gitignore
├── Common
├── CommonProperties.cs
└── Mallardsoft.snk
├── LICENSE
├── NuGet
├── App
│ ├── UpdateControls.App.nuspec
│ └── content
│ │ ├── Models
│ │ ├── Document.cs.pp
│ │ ├── Item.cs.pp
│ │ └── Selection.cs.pp
│ │ ├── Readme_UpdateControls.txt.pp
│ │ └── ViewModels
│ │ ├── ItemHeader.cs.pp
│ │ ├── ItemViewModel.cs.pp
│ │ ├── MainViewModel.cs.pp
│ │ └── ViewModelLocator.cs.pp
├── Core
│ └── updatecontrols.nuspec
├── Forms
│ └── UpdateControls.Forms.nuspec
└── Snippets
│ ├── content
│ └── Readme_UpdateControls_Snippets.txt
│ ├── tools
│ ├── dep.snippet
│ ├── depList.snippet
│ ├── ind.snippet
│ ├── indList.snippet
│ ├── install.ps1
│ └── uninstall.ps1
│ └── updatecontrols.snippets.nuspec
├── Portable
├── UpdateControls.UnitTest
│ ├── CollectionContentTest.cs
│ ├── CollectionData
│ │ ├── SourceCollection.cs
│ │ └── TargetCollection.cs
│ ├── CollectionTest.cs
│ ├── ContactListData
│ │ ├── Contact.cs
│ │ ├── ContactList.cs
│ │ ├── ContactListSortOrder.cs
│ │ ├── ContactListViewModel.cs
│ │ └── ContactViewModel.cs
│ ├── DependentListTest.cs
│ ├── DirectConcurrencyTest.cs
│ ├── DirectDependent.cs
│ ├── DirectDependentTest.cs
│ ├── DynamicSortOrderTest.cs
│ ├── IndirectConcurrencyTest.cs
│ ├── IndirectDependent.cs
│ ├── IndirectDependentTest.cs
│ ├── MemoryLeakTest.cs
│ ├── MultithreadedData
│ │ ├── SourceThread.cs
│ │ └── TargetThread.cs
│ ├── MultithreadedTest.cs
│ ├── NotificationTest.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SortedCollectionTest.cs
│ ├── SourceData.cs
│ └── UpdateControls.UnitTest.csproj
└── UpdateControls
│ ├── Collections
│ ├── DependentDictionary.cs
│ ├── DependentList.cs
│ ├── Impl
│ │ └── UpdateCollectionHelper.cs
│ ├── IndependentDictionary.cs
│ └── IndependentList.cs
│ ├── Dependent.cs
│ ├── DependentJob.cs
│ ├── Fields
│ ├── Dependent.cs
│ └── Independent.cs
│ ├── IUpdatable.cs
│ ├── Independent.cs
│ ├── InertialProperty.cs
│ ├── MemoizedTypeName.cs
│ ├── NamedPrecedents.cs
│ ├── Precedent.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── RecycleBin.cs
│ ├── ThreadLocal.cs
│ ├── UpdateControls.csproj
│ ├── UpdateControlsExtensions.cs
│ ├── UpdateScheduler.cs
│ └── XAML
│ └── MakeCommand.cs
├── README.md
├── Silverlight
└── UpdateControls.XAML
│ ├── ForView.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── UpdateControls.XAML.csproj
│ ├── ViewModelBase.cs
│ ├── ViewModelLocatorBase.cs
│ └── Wrapper
│ ├── ClassInstance.cs
│ ├── ClassProperty.cs
│ ├── CollectionItem.cs
│ ├── DelegatedPropertyInfo.cs
│ ├── DelegatedType.cs
│ ├── IObjectInstance.cs
│ ├── NotificationGate.cs
│ ├── ObjectInstance.cs
│ ├── ObjectProperty.cs
│ ├── ObjectPropertyAtom.cs
│ ├── ObjectPropertyAtomNative.cs
│ ├── ObjectPropertyAtomObject.cs
│ ├── ObjectPropertyCollection.cs
│ ├── ObjectPropertyCollectionNative.cs
│ └── ObjectPropertyCollectionObject.cs
├── Universal
├── UpdateControls.Test
│ ├── ContactList.cs
│ ├── ContactListNavigationModel.cs
│ ├── ContactListViewModel.cs
│ ├── DataGridPersonViewModel.cs
│ ├── GenderEnum.cs
│ ├── GenderOption.cs
│ ├── ISpouseViewModel.cs
│ ├── Person.cs
│ ├── PersonViewModel.cs
│ ├── PersonViewModelBase.cs
│ ├── PrefixID.cs
│ ├── PrefixViewModel.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SpouseViewModel.cs
│ └── UpdateControls.Test.csproj
├── UpdateControls.XAML
│ ├── ForView.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── UpdateControls.XAML.csproj
│ ├── ViewModelBase.cs
│ ├── ViewModelLocatorBase.cs
│ └── Wrapper
│ │ ├── CollectionItem.cs
│ │ ├── CustomMemberProvider.cs
│ │ ├── CustomMetadataProvider.cs
│ │ ├── CustomTypeProvider.cs
│ │ ├── ObjectInstance.cs
│ │ ├── ObjectProperty.cs
│ │ └── PrimitiveTypeProvider.cs
└── UpdateControls
│ ├── Collections
│ ├── DependentDictionary.cs
│ ├── DependentList.cs
│ ├── Impl
│ │ └── UpdateCollectionHelper.cs
│ ├── IndependentDictionary.cs
│ └── IndependentList.cs
│ ├── Dependent.cs
│ ├── Fields
│ ├── Dependent.cs
│ └── Independent.cs
│ ├── IUpdatable.cs
│ ├── Independent.cs
│ ├── InertialProperty.cs
│ ├── Precedent.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── RecycleBin.cs
│ ├── UpdateControls.csproj
│ ├── UpdateControlsExtensions.cs
│ ├── UpdateScheduler.cs
│ └── XAML
│ └── MakeCommand.cs
├── UpdateControls.sln
├── WPF
└── UpdateControls.XAML
│ ├── BindingInterceptor.cs
│ ├── ForView.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Timers
│ ├── DroppingTimeSpan.cs
│ ├── FloatingDateTime.cs
│ ├── FloatingTimeSpan.cs
│ ├── FloatingTimeZone.cs
│ ├── IndependentTimer.cs
│ ├── RisingTimeSpan.cs
│ └── UtcTimeZone.cs
│ ├── UpdateControls.XAML.csproj
│ ├── ViewModelBase.cs
│ ├── ViewModelLocatorBase.cs
│ └── Wrapper
│ ├── ClassEvent.cs
│ ├── ClassInstance.cs
│ ├── ClassInstanceProvider.cs
│ ├── ClassMember.cs
│ ├── ClassMemberCommand.cs
│ ├── ClassMemberField.cs
│ ├── ClassMemberIndependent.cs
│ ├── ClassMemberProperty.cs
│ ├── CollectionItem.cs
│ ├── IObjectInstance.cs
│ ├── ObjectInstance.cs
│ ├── ObjectProperty.cs
│ ├── ObjectPropertyAtom.cs
│ ├── ObjectPropertyAtomNative.cs
│ ├── ObjectPropertyAtomObject.cs
│ ├── ObjectPropertyCollection.cs
│ ├── ObjectPropertyCollectionNative.cs
│ ├── ObjectPropertyCollectionObject.cs
│ └── ObjectPropertyCommand.cs
├── WindowsForms
├── UpdateControls.Forms
│ ├── Delegates.cs
│ ├── GuiUpdateHelper.cs
│ ├── IEnabledControl.cs
│ ├── IErrorControl.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ToolboxImages
│ │ ├── UpdateButton.png
│ │ ├── UpdateCheckBox.png
│ │ ├── UpdateCheckedListBox.png
│ │ ├── UpdateComboBox.png
│ │ ├── UpdateComponent.png
│ │ ├── UpdateDateTimePicker.png
│ │ ├── UpdateErrorProvider.png
│ │ ├── UpdateFormMap.png
│ │ ├── UpdateGrid.png
│ │ ├── UpdateLabel.png
│ │ ├── UpdateListBox.png
│ │ ├── UpdateListView.png
│ │ ├── UpdateMonthCalendar.png
│ │ ├── UpdateRadioButton.png
│ │ ├── UpdateTextBox.png
│ │ └── UpdateTreeView.png
│ ├── UpdateButton.cs
│ ├── UpdateButton.resx
│ ├── UpdateCheckBox.cs
│ ├── UpdateCheckBox.resx
│ ├── UpdateCheckedListBox.cs
│ ├── UpdateCheckedListBox.resx
│ ├── UpdateComboBox.cs
│ ├── UpdateComboBox.resx
│ ├── UpdateComponent.cs
│ ├── UpdateComponent.resx
│ ├── UpdateControls.Forms.csproj
│ ├── UpdateDateTimePicker.cs
│ ├── UpdateDateTimePicker.resx
│ ├── UpdateErrorProvider.Designer.cs
│ ├── UpdateErrorProvider.cs
│ ├── UpdateErrorProvider.resx
│ ├── UpdateFormMap.cs
│ ├── UpdateFormMap.resx
│ ├── UpdateGrid.cs
│ ├── UpdateGrid.resx
│ ├── UpdateLabel.cs
│ ├── UpdateLabel.resx
│ ├── UpdateListBox.cs
│ ├── UpdateListBox.resx
│ ├── UpdateListView.cs
│ ├── UpdateListView.resx
│ ├── UpdateMonthCalendar.cs
│ ├── UpdateMonthCalendar.resx
│ ├── UpdateNumericUpDown.cs
│ ├── UpdateRadioButton.cs
│ ├── UpdateRadioButton.resx
│ ├── UpdateTextBox.cs
│ ├── UpdateTextBox.resx
│ ├── UpdateTreeView.cs
│ ├── UpdateTreeView.resx
│ └── Util
│ │ ├── CollectionHelper.cs
│ │ ├── ReadOnlyListDecorator.cs
│ │ └── UpdateController.cs
└── UpdateControls
│ ├── Collections
│ ├── DependentDictionary.cs
│ ├── DependentList.cs
│ ├── Impl
│ │ └── UpdateCollectionHelper.cs
│ ├── IndependentDictionary.cs
│ └── IndependentList.cs
│ ├── Dependent.CurrentUpdate.cs
│ ├── Dependent.cs
│ ├── Fields
│ ├── Dependent.cs
│ └── Independent.cs
│ ├── IUpdatable.cs
│ ├── Independent.cs
│ ├── InertialProperty.cs
│ ├── MemoizedTypeName.cs
│ ├── NamedPrecedents.cs
│ ├── Precedent.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── RecycleBin.cs
│ ├── ThreadLocal.cs
│ ├── UpdateControls.csproj
│ ├── UpdateControlsExtensions.cs
│ └── UpdateScheduler.cs
├── WindowsPhone
└── UpdateControls.XAML
│ ├── ForView.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── UpdateControls.XAML.csproj
│ ├── ViewModelBase.cs
│ ├── ViewModelLocatorBase.cs
│ └── Wrapper
│ ├── ClassInstance.cs
│ ├── ClassProperty.cs
│ ├── CollectionItem.cs
│ ├── IObjectInstance.cs
│ ├── NotificationGate.cs
│ ├── ObjectInstance.cs
│ ├── ObjectProperty.cs
│ ├── ObjectPropertyAtom.cs
│ ├── ObjectPropertyCollection.cs
│ ├── Tree.cs
│ └── UnitTestDispatcher.cs
└── WindowsStore
└── UpdateControls.Test.App
├── App.xaml
├── App.xaml.cs
├── Assets
├── Logo.png
├── SmallLogo.png
├── SplashScreen.png
└── StoreLogo.png
├── Common
└── StandardStyles.xaml
├── DebugConverter.cs
├── MainPage.xaml
├── MainPage.xaml.cs
├── Package.appxmanifest
├── Properties
└── AssemblyInfo.cs
├── UpdateControls.Test.App.csproj
├── UpdateControls.XAML.Test_TemporaryKey.pfx
├── ViewModelLocator.cs
└── app.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | packages/
2 | NuGet/Core/lib/
3 | NuGet/Forms/lib/
4 | .vs/
5 |
6 | #ignore thumbnails created by windows
7 | Thumbs.db
8 | #Ignore files build by Visual Studio
9 | *.obj
10 | *.pdb
11 | *.user
12 | *.aps
13 | *.pch
14 | *.vspscc
15 | *_i.c
16 | *_p.c
17 | *.ncb
18 | *.suo
19 | *.tlb
20 | *.tlh
21 | *.bak
22 | *.cache
23 | *.ilk
24 | *.log
25 | [Bb]in
26 | [Dd]ebug*/
27 | *.lib
28 | *.sbr
29 | obj/
30 | [Rr]elease*/
31 | _ReSharper*/
32 | [Tt]est[Rr]esult*
33 | .svn/
34 | *.[Mm][Dd][Ff]
35 | *.[Ll][Dd][Ff]
36 | *.dbmdl
37 | *.eto
38 | *.ncb
39 | *.user
40 | *.stuff
41 | ~*.*
42 | *.suo
43 | *.xap
44 | *.vs10x
45 | Index.dat
46 | Storage.dat
47 | Generated_Code*/
48 | *.Publish.xml
49 | *.docstates
50 | AppPackages/
51 | .cr/Settings.xml
52 |
--------------------------------------------------------------------------------
/Common/CommonProperties.cs:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Update Controls .NET
4 | * Copyright 2010 Michael L Perry
5 | * MIT License
6 | *
7 | * http://updatecontrols.net
8 | * http://www.codeplex.com/updatecontrols/
9 | *
10 | **********************************************************************/
11 |
12 | using System.Reflection;
13 | using System;
14 |
15 | [assembly: AssemblyDescription("")]
16 | [assembly: AssemblyConfiguration("")]
17 | [assembly: AssemblyCompany("Michael L Perry")]
18 | [assembly: AssemblyCopyright("Copyright 2014 Michael L Perry, MIT License")]
19 | [assembly: AssemblyTrademark("")]
20 | [assembly: AssemblyCulture("")]
21 | [assembly: AssemblyVersion("2.3.0.0")]
22 | [assembly: AssemblyFileVersion("2.3.2.0")]
23 |
--------------------------------------------------------------------------------
/Common/Mallardsoft.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaellperry/UpdateControls/8b300b8faca6cc4712f3fd748701b0c0449ca8e4/Common/Mallardsoft.snk
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Michael L Perry
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/NuGet/App/UpdateControls.App.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | UpdateControls.App
5 | 1.1.0
6 | Michael L Perry
7 | Michael L Perry
8 | http://updatecontrols.codeplex.com/license
9 | http://updatecontrols.net/
10 | http://updatecontrols.net/images/logosmall.png
11 | false
12 | Add a view model locator for use in an Update Controls application.
13 | Copyright 2012, Michael L Perry
14 | mvvm viewmodel databinding inotifypropertychanged inpc
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/NuGet/App/content/Models/Document.cs.pp:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using UpdateControls.Collections;
7 | using UpdateControls.Fields;
8 |
9 | namespace $rootnamespace$.Models
10 | {
11 | public class Document
12 | {
13 | private Independent _name = new Independent();
14 | private IndependentList- _items = new IndependentList
- ();
15 |
16 | public string Name
17 | {
18 | get { return _name; }
19 | set { _name.Value = value; }
20 | }
21 |
22 | public IEnumerable
- Items
23 | {
24 | get { return _items; }
25 | }
26 |
27 | public Item NewItem()
28 | {
29 | Item item = new Item();
30 | _items.Add(item);
31 | return item;
32 | }
33 |
34 | public void DeleteItem(Item item)
35 | {
36 | _items.Remove(item);
37 | }
38 |
39 | public bool CanMoveDown(Item item)
40 | {
41 | return _items.IndexOf(item) < _items.Count - 1;
42 | }
43 |
44 | public bool CanMoveUp(Item item)
45 | {
46 | return _items.IndexOf(item) > 0;
47 | }
48 |
49 | public void MoveDown(Item item)
50 | {
51 | int index = _items.IndexOf(item);
52 | _items.RemoveAt(index);
53 | _items.Insert(index + 1, item);
54 | }
55 |
56 | public void MoveUp(Item item)
57 | {
58 | int index = _items.IndexOf(item);
59 | _items.RemoveAt(index);
60 | _items.Insert(index - 1, item);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/NuGet/App/content/Models/Item.cs.pp:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using UpdateControls.Collections;
6 | using UpdateControls.Fields;
7 |
8 | namespace $rootnamespace$.Models
9 | {
10 | public class Item
11 | {
12 | private Independent _name = new Independent();
13 |
14 | public string Name
15 | {
16 | get { return _name; }
17 | set { _name.Value = value; }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/NuGet/App/content/Models/Selection.cs.pp:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using UpdateControls.Fields;
3 |
4 | namespace $rootnamespace$.Models
5 | {
6 | public class Selection
7 | {
8 | private Independent
- _selectedItem = new Independent
- ();
9 |
10 | public Item SelectedItem
11 | {
12 | get { return _selectedItem; }
13 | set { _selectedItem.Value = value; }
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/NuGet/App/content/Readme_UpdateControls.txt.pp:
--------------------------------------------------------------------------------
1 | Add the ViewModels namespace to App.xaml:
2 |
3 |
6 |
7 |
8 | Add the view model locator to the resource dictionary:
9 |
10 |
11 |
12 | ...
13 |
14 |
15 |
16 |
17 |
18 | Reference the view model locator in each view:
19 |
20 |
23 |
--------------------------------------------------------------------------------
/NuGet/App/content/ViewModels/ItemHeader.cs.pp:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using $rootnamespace$.Models;
4 |
5 | namespace $rootnamespace$.ViewModels
6 | {
7 | public class ItemHeader
8 | {
9 | private readonly Item _item;
10 |
11 | public ItemHeader(Item Item)
12 | {
13 | _item = Item;
14 | }
15 |
16 | public Item Item
17 | {
18 | get { return _item; }
19 | }
20 |
21 | public string Name
22 | {
23 | get { return _item.Name ?? ""; }
24 | }
25 |
26 | public override bool Equals(object obj)
27 | {
28 | if (obj == this)
29 | return true;
30 | ItemHeader that = obj as ItemHeader;
31 | if (that == null)
32 | return false;
33 | return Object.Equals(this._item, that._item);
34 | }
35 |
36 | public override int GetHashCode()
37 | {
38 | return _item.GetHashCode();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/NuGet/App/content/ViewModels/ItemViewModel.cs.pp:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using $rootnamespace$.Models;
5 |
6 | namespace $rootnamespace$.ViewModels
7 | {
8 | public class ItemViewModel
9 | {
10 | private readonly Item _item;
11 |
12 | public ItemViewModel(Item Item)
13 | {
14 | _item = Item;
15 | }
16 |
17 | public string Name
18 | {
19 | get { return _item.Name; }
20 | set { _item.Name = value; }
21 | }
22 |
23 | public override bool Equals(object obj)
24 | {
25 | if (obj == this)
26 | return true;
27 | ItemViewModel that = obj as ItemViewModel;
28 | if (that == null)
29 | return false;
30 | return Object.Equals(this._item, that._item);
31 | }
32 |
33 | public override int GetHashCode()
34 | {
35 | return _item.GetHashCode();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/NuGet/App/content/ViewModels/ViewModelLocator.cs.pp:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using UpdateControls.XAML;
7 | using $rootnamespace$.Models;
8 |
9 | namespace $rootnamespace$.ViewModels
10 | {
11 | public class ViewModelLocator : ViewModelLocatorBase
12 | {
13 | private Document _document;
14 | private Selection _selection;
15 |
16 | public ViewModelLocator()
17 | {
18 | _document = LoadDocument();
19 | _selection = new Selection();
20 | }
21 |
22 | public object Main
23 | {
24 | get { return ViewModel(() => new MainViewModel(_document, _selection)); }
25 | }
26 |
27 | public object Item
28 | {
29 | get
30 | {
31 | return ViewModel(() => _selection.SelectedItem == null
32 | ? null
33 | : new ItemViewModel(_selection.SelectedItem));
34 | }
35 | }
36 |
37 | private Document LoadDocument()
38 | {
39 | // TODO: Load your document here.
40 | Document document = new Document();
41 | var one = document.NewItem();
42 | one.Name = "One";
43 | var two = document.NewItem();
44 | two.Name = "Two";
45 | var three = document.NewItem();
46 | three.Name = "Three";
47 | return document;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/NuGet/Core/updatecontrols.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | UpdateControls
5 | 2.3.3
6 | Michael L Perry
7 | Michael L Perry
8 | Automatically discover view model dependencies and databind without INotifyPropertyChanged.
9 | http://updatecontrols.codeplex.com/license
10 | http://updatecontrols.net/
11 | http://updatecontrols.net/images/logosmall.png
12 | false
13 | en-US
14 | mvvm viewmodel databinding inotifypropertychanged inpc wpf silverlight wp7
15 |
16 |
--------------------------------------------------------------------------------
/NuGet/Forms/UpdateControls.Forms.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | UpdateControls.Forms
5 | 2.3.3
6 | Michael L Perry
7 | Michael L Perry
8 | Dependency tracking MVVM framework for Windows Forms.
9 | http://updatecontrols.codeplex.com/license
10 | http://updatecontrols.net/
11 | http://updatecontrols.net/images/logosmall.png
12 | false
13 | en-US
14 | mvvm viewmodel databinding winforms
15 |
16 |
--------------------------------------------------------------------------------
/NuGet/Snippets/content/Readme_UpdateControls_Snippets.txt:
--------------------------------------------------------------------------------
1 | Use the following snippets to create independent and dependent properties:
2 |
3 | ind - Independent property
4 | An independent property is one that can change on its own. These will be the
5 | values of your data model.
6 |
7 | indlist - Independent list
8 | The user can add and remove items in an independent collection. These will be
9 | child collections in your data model.
10 |
11 | dep - Dependent property
12 | A dependenty property calculates its value from code. The user cannot change
13 | its value directly. They can only change the independent properties that the
14 | dependent depends upon.
15 |
16 | All view model properties are dependent by default. Only use this template
17 | to cache the dependent value when it is expensive to calculate.
18 |
19 | deplist - Dependent list
20 | A dependent list calculates its contents from a linq query. The user cannot
21 | add or remove items in this list. They can only change the independent lists
22 | and properties that the linq query depends upon.
23 |
24 | All view model lists are dependent by default. Only use this template to
25 | cache lists that are expensive to calculate, or are used by other properties
26 | of the view model.
27 |
28 | If these snippets aren't working for you, please remove and reinstall the
29 | UpdateControls.Snippets package.
--------------------------------------------------------------------------------
/NuGet/Snippets/tools/dep.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | dep
6 | dep
7 | Code snippet to help you make properties based on 'Dependent<T>', an Update Controls class that represents a value computed based on one or more Independents. Note: in most cases you should just write a normal property instead of using Dependent<T>. Dependent<T> is useful to cache the result of a computation when the value of the property is expensive to compute.
8 | David Piepgrass
9 |
10 | Expansion
11 |
12 |
13 |
14 |
15 |
16 | type
17 | string
18 | Data type
19 |
20 |
21 | name
22 | CalculatedProperty
23 | A name for this computed property
24 |
25 |
26 | expr
27 | TODO
28 | Write an expression here to compute the value of the Dependent
29 |
30 |
31 |
_$name$;
32 | public $type$ $name$
33 | {
34 | get {
35 | if (_$name$ == null)
36 | _$name$ = new Dependent<$type$>("$name$",
37 | () => $expr$);
38 | return _$name$.Value;
39 | }
40 | }]]>
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/NuGet/Snippets/tools/depList.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | depList
6 | depList
7 | Code snippet for 'DependentList<T>', which is used to compute a list of values based on a set of other values that utilize Independent, Dependent or other classes in Update Controls.
8 | David Piepgrass
9 |
10 | Expansion
11 |
12 |
13 |
14 |
15 |
16 | type
17 | string
18 | Data type of each element
19 |
20 |
21 | name
22 | List
23 | Property Name
24 |
25 |
26 | expr
27 | return TODO;
28 | Write a LINQ query or other code to compute the list of items as IEnumerable<T%gt;.
29 |
30 |
31 | _$name$;
32 | public DependentList<$type$> $name$
33 | {
34 | get {
35 | if (_$name$ == null)
36 | _$name$ = new DependentList<$type$>("$name$", () => {
37 | $expr$
38 | });
39 | return _$name$;
40 | }
41 | }]]>
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/NuGet/Snippets/tools/ind.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ind
6 | ind
7 | Code snippet for 'Independent<T>'
8 | David Piepgrass
9 |
10 | Expansion
11 |
12 |
13 |
14 |
15 |
16 | type
17 | string
18 | Data type
19 |
20 |
21 | name
22 | Name
23 | Property Name
24 |
25 |
26 | _$name$ = new Independent<$type$>("$name$", default($type$));
27 | public $type$ $name$
28 | {
29 | get { return _$name$.Value; }
30 | set { _$name$.Value = value; }
31 | }]]>
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/NuGet/Snippets/tools/indList.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | indList
6 | indList
7 | Code snippet for 'IndependentList<T>'
8 | David Piepgrass
9 |
10 | Expansion
11 |
12 |
13 |
14 |
15 |
16 | type
17 | string
18 | Data type of each element
19 |
20 |
21 | name
22 | List
23 | Property Name
24 |
25 |
26 | _$name$ = new IndependentList<$type$>();
27 | public IList<$type$> $name$
28 | {
29 | get { return _$name$; }
30 | }]]>
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/NuGet/Snippets/tools/install.ps1:
--------------------------------------------------------------------------------
1 | # Install script for code snippets with NuGet
2 | # =============================================
3 | # Written by Geert van Horrik (see http://blog.catenalogic.com)
4 | #
5 | # Version 1.0 / 2011-02-18
6 | #
7 | # Required call to get environment variables
8 |
9 | param($installPath, $toolsPath, $package, $project)
10 |
11 | # You only have to customize the $snippetFolder name below,
12 | # don't forget to rename the $snippetFolder of the other file
13 | # ("uninstall.ps1") as well
14 |
15 | $snippetFolder = "UpdateControls"
16 |
17 | # Actual script start
18 | $source = "$toolsPath\*.snippet"
19 | $vsVersions = @("2005", "2008", "2010")
20 |
21 | Foreach ($vsVersion in $vsVersions)
22 | {
23 | $myCodeSnippetsFolder = "$HOME\My Documents\Visual Studio $vsVersion\Code Snippets\Visual C#\My Code Snippets\"
24 |
25 | if (Test-Path $myCodeSnippetsFolder)
26 | {
27 | $destination = "$myCodeSnippetsFolder$snippetFolder"
28 | if (!($myCodeSnippetsFolder -eq $destination))
29 | {
30 | if (!(Test-Path $destination))
31 | {
32 | New-Item $destination -itemType "directory"
33 | }
34 |
35 | "Installing code snippets for Visual Studio $vsVersion"
36 | Copy-Item $source $destination
37 | }
38 | else
39 | {
40 | "Define a value for snippetFolder variable, cannot be empty"
41 | }
42 | }
43 | else
44 | {
45 | "Path not found $myCodeSnippetsFolder"
46 | }
47 | }
--------------------------------------------------------------------------------
/NuGet/Snippets/tools/uninstall.ps1:
--------------------------------------------------------------------------------
1 | # Uninstall script for code snippets with NuGet
2 | # =============================================
3 | # Written by Geert van Horrik (see http://blog.catenalogic.com)
4 | #
5 | # Version 1.0 / 2011-02-18
6 | #
7 | # Required call to get environment variables
8 |
9 | param($installPath, $toolsPath, $package, $project)
10 |
11 | # You only have to customize the $snippetFolder name below,
12 | # don't forget to rename the $snippetFolder of the other file
13 | # ("install.ps1") as well
14 |
15 | $snippetFolder = "UpdateControls"
16 |
17 | # Actual script start
18 | $vsVersions = @("2005", "2008", "2010")
19 |
20 | Foreach ($vsVersion in $vsVersions)
21 | {
22 | $myCodeSnippetsFolder = "$HOME\My Documents\Visual Studio $vsVersion\Code Snippets\Visual C#\My Code Snippets\"
23 | if (Test-Path $myCodeSnippetsFolder)
24 | {
25 | $destination = "$myCodeSnippetsFolder$snippetFolder"
26 | if (!($myCodeSnippetsFolder -eq $destination))
27 | {
28 | if (Test-Path $destination)
29 | {
30 | "Uninstalling code snippets for Visual Studio $vsVersion"
31 | Remove-Item $destination -recurse -force
32 | }
33 | }
34 | else
35 | {
36 | "Define a value for snippetFolder variable, cannot be empty"
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/NuGet/Snippets/updatecontrols.snippets.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | UpdateControls.Snippets
5 | 2.2.1.0
6 | Qwertie
7 | Michael L Perry
8 | Code snippets for Update Controls.
9 | http://updatecontrols.codeplex.com/license
10 | http://updatecontrols.net/
11 | http://updatecontrols.net/images/logosmall.png
12 | false
13 | en-US
14 | mvvm viewmodel databinding inotifypropertychanged inpc wpf silverlight wp7
15 |
16 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/CollectionContentTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using UpdateControls.UnitTest.ContactListData;
3 | using System.Linq;
4 |
5 | namespace UpdateControls.UnitTest
6 | {
7 | [TestClass]
8 | public class CollectionContentTest
9 | {
10 | private ContactList _contactList;
11 | private ContactListViewModel _viewModel;
12 | private int _collectionChangedCount;
13 |
14 | [TestInitialize]
15 | public void Initialize()
16 | {
17 | _contactList = new ContactList();
18 | _viewModel = new ContactListViewModel(_contactList);
19 | _contactList.AddContact(new Contact() { FirstName = "Michael", LastName = "Perry" });
20 | _contactList.AddContact(new Contact() { FirstName = "Ada", LastName = "Lovelace" });
21 | _contactList.AddContact(new Contact() { FirstName = "Charles", LastName = "Babbage" });
22 |
23 | _collectionChangedCount = 0;
24 | _viewModel.ContactsCollectionChanged +=
25 | delegate
26 | {
27 | _collectionChangedCount++;
28 | };
29 | }
30 |
31 | [TestMethod]
32 | public void WhenContactAddedShouldNotifyCollectionChanged()
33 | {
34 | ContactViewModel firstByDefaultOrder = _viewModel.Contacts.First();
35 | _contactList.AddContact(new Contact() { FirstName = "Martin", LastName = "Fowler" });
36 |
37 | Assert.AreEqual(1, _collectionChangedCount);
38 | }
39 |
40 | [TestMethod]
41 | public void WhenContactDeletedShouldNotifyCollectionChanged()
42 | {
43 | ContactViewModel firstByDefaultOrder = _viewModel.Contacts.First();
44 | _contactList.DeleteContact(_contactList.Contacts.First());
45 |
46 | Assert.AreEqual(1, _collectionChangedCount);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/CollectionData/SourceCollection.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace UpdateControls.UnitTest.CollectionData
4 | {
5 | public class SourceCollection
6 | {
7 | private List _numbers = new List();
8 | private Independent _indNumbers = new Independent();
9 |
10 | public void Insert(int number)
11 | {
12 | _indNumbers.OnSet();
13 | _numbers.Add(number);
14 | }
15 |
16 | public IEnumerable Numbers
17 | {
18 | get { _indNumbers.OnGet(); return _numbers; }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/CollectionData/TargetCollection.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace UpdateControls.UnitTest.CollectionData
5 | {
6 | public class TargetCollection
7 | {
8 | private SourceCollection _source;
9 | private List _results = new List();
10 | private Dependent _depResults;
11 |
12 | public TargetCollection(SourceCollection source)
13 | {
14 | _source = source;
15 | _depResults = new Dependent(UpdateResults);
16 | }
17 |
18 | public IEnumerable Results
19 | {
20 | get { _depResults.OnGet(); return _results; }
21 | }
22 |
23 | private void UpdateResults()
24 | {
25 | _results = _source.Numbers.Select(number => number + 1).ToList();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/CollectionTest.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using UpdateControls.UnitTest.CollectionData;
4 |
5 | namespace UpdateControls.UnitTest
6 | {
7 | [TestClass]
8 | public class CollectionTest
9 | {
10 | private SourceCollection _source;
11 |
12 | [TestInitialize]
13 | public void Initialize()
14 | {
15 | _source = new SourceCollection();
16 | }
17 |
18 | [TestMethod]
19 | public void InsertIntoSourceShouldCauseNewElementInTarget()
20 | {
21 | TargetCollection target = new TargetCollection(_source);
22 |
23 | _source.Insert(3);
24 | int firstNumber = target.Results.Single();
25 | Assert.AreEqual(4, firstNumber);
26 | }
27 |
28 | [TestMethod]
29 | public void InsertIntoSourceBeforeTargetCreatedShouldCauseNewElementInTarget()
30 | {
31 | _source.Insert(3);
32 |
33 | TargetCollection target = new TargetCollection(_source);
34 |
35 | int firstNumber = target.Results.Single();
36 | Assert.AreEqual(4, firstNumber);
37 | }
38 |
39 | [TestMethod]
40 | public void InsertASecondIntoSourceTargetShouldUpdate()
41 | {
42 | TargetCollection target = new TargetCollection(_source);
43 | _source.Insert(42);
44 | target.Results.Single();
45 |
46 | _source.Insert(43);
47 | int[] results = target.Results.ToArray();
48 |
49 | Assert.AreEqual(2, results.Length);
50 | Assert.AreEqual(43, results[0]);
51 | Assert.AreEqual(44, results[1]);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/ContactListData/Contact.cs:
--------------------------------------------------------------------------------
1 | using UpdateControls;
2 |
3 | namespace UpdateControls.UnitTest.ContactListData
4 | {
5 | public class Contact
6 | {
7 | private string _firstName;
8 | private string _lastName;
9 |
10 | #region Independent properties
11 | // Generated by Update Controls --------------------------------
12 | private Independent _indFirstName = new Independent();
13 | private Independent _indLastName = new Independent();
14 |
15 | public string FirstName
16 | {
17 | get { _indFirstName.OnGet(); return _firstName; }
18 | set { _indFirstName.OnSet(); _firstName = value; }
19 | }
20 |
21 | public string LastName
22 | {
23 | get { _indLastName.OnGet(); return _lastName; }
24 | set { _indLastName.OnSet(); _lastName = value; }
25 | }
26 | // End generated code --------------------------------
27 | #endregion
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/ContactListData/ContactList.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UpdateControls.Collections;
3 |
4 | namespace UpdateControls.UnitTest.ContactListData
5 | {
6 | public class ContactList
7 | {
8 | private IndependentList _contacts = new IndependentList();
9 |
10 | public void AddContact(Contact contact)
11 | {
12 | _contacts.Add(contact);
13 | }
14 |
15 | public void AddContacts(IEnumerable contacts)
16 | {
17 | _contacts.AddRange(contacts);
18 | }
19 |
20 | public void DeleteContact(Contact contact)
21 | {
22 | _contacts.Remove(contact);
23 | }
24 |
25 | public IEnumerable Contacts
26 | {
27 | get { return _contacts; }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/ContactListData/ContactListSortOrder.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace UpdateControls.UnitTest.ContactListData
3 | {
4 | public enum ContactListSortOrder
5 | {
6 | NoOrder,
7 | FirstName,
8 | LastName
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/ContactListData/ContactListViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace UpdateControls.UnitTest.ContactListData
6 | {
7 | public class ContactListViewModel
8 | {
9 | private ContactList _contactList;
10 | private ContactListSortOrder _sortOrder;
11 | private Independent _indSortOrder = new Independent();
12 |
13 | private List _contactViewModels;
14 | private Dependent _depContactViewModels;
15 |
16 | public delegate void NotifyCollectionChanged();
17 | public event NotifyCollectionChanged ContactsCollectionChanged;
18 |
19 | public ContactListViewModel(ContactList contactList)
20 | {
21 | _contactList = contactList;
22 | _depContactViewModels = new Dependent(UpdateContactViewModels);
23 | _depContactViewModels.Invalidated += new Action(_depContactViewModels_Invalidated);
24 | }
25 |
26 | void _depContactViewModels_Invalidated()
27 | {
28 | ContactsCollectionChanged();
29 | }
30 |
31 | public ContactListSortOrder SortOrder
32 | {
33 | get
34 | {
35 | _indSortOrder.OnGet();
36 | return _sortOrder;
37 | }
38 | set
39 | {
40 | if (_sortOrder != value) _indSortOrder.OnSet();
41 | _sortOrder = value;
42 | }
43 | }
44 |
45 | public IEnumerable Contacts
46 | {
47 | get
48 | {
49 | _depContactViewModels.OnGet();
50 | return _contactViewModels;
51 | }
52 | }
53 |
54 | private void UpdateContactViewModels()
55 | {
56 | IEnumerable contacts = _contactList.Contacts;
57 | if (SortOrder == ContactListSortOrder.FirstName)
58 | contacts = contacts.OrderBy(contact => contact.FirstName);
59 | else if (SortOrder == ContactListSortOrder.LastName)
60 | contacts = contacts.OrderBy(contact => contact.LastName);
61 |
62 | _contactViewModels = contacts
63 | .Select(contact => new ContactViewModel(contact))
64 | .ToList();
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/ContactListData/ContactViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UpdateControls.UnitTest.ContactListData
4 | {
5 | public class ContactViewModel
6 | {
7 | private Contact _contact;
8 |
9 | public ContactViewModel(Contact contact)
10 | {
11 | _contact = contact;
12 | }
13 |
14 | public string FullName
15 | {
16 | get
17 | {
18 | return string.Format("{0} {1}", _contact.FirstName, _contact.LastName);
19 | }
20 | }
21 |
22 | public override bool Equals(object obj)
23 | {
24 | if (this == obj)
25 | return true;
26 | ContactViewModel that = obj as ContactViewModel;
27 | if (that == null)
28 | return false;
29 | return _contact == that._contact;
30 | }
31 |
32 | public override int GetHashCode()
33 | {
34 | return _contact.GetHashCode();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/DirectDependent.cs:
--------------------------------------------------------------------------------
1 | using UpdateControls.Fields;
2 |
3 | namespace UpdateControls.UnitTest
4 | {
5 | public class DirectDependent
6 | {
7 | private SourceData _source;
8 |
9 | private Dependent _property;
10 |
11 | public DirectDependent(SourceData source)
12 | {
13 | _source = source;
14 | _property = new Dependent(() => _source.SourceProperty);
15 | }
16 |
17 | public int DependentProperty
18 | {
19 | get { return _property; }
20 | }
21 |
22 | public bool IsUpToDate
23 | {
24 | get { return _property.DependentSentry.IsUpToDate; }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/IndirectDependent.cs:
--------------------------------------------------------------------------------
1 | using UpdateControls.Fields;
2 |
3 | namespace UpdateControls.UnitTest
4 | {
5 | public class IndirectDependent
6 | {
7 | private DirectDependent _indermediateDependent;
8 |
9 | private Dependent _property;
10 |
11 | public IndirectDependent(DirectDependent indermediateDependent)
12 | {
13 | _indermediateDependent = indermediateDependent;
14 | _property = new Dependent(() => _indermediateDependent.DependentProperty);
15 | }
16 |
17 | public int DependentProperty
18 | {
19 | get { return _property; }
20 | }
21 |
22 | public bool IsUpToDate
23 | {
24 | get { return _property.DependentSentry.IsUpToDate; }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/MultithreadedData/SourceThread.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using UpdateControls.Fields;
3 |
4 | namespace UpdateControls.UnitTest.MultithreadedData
5 | {
6 | public class SourceThread
7 | {
8 | public const int MaxValue = 10000;
9 |
10 | private Thread _thread;
11 | private Independent _value = new Independent();
12 |
13 | public SourceThread()
14 | {
15 | _thread = new Thread(ThreadProc);
16 | }
17 |
18 | public void Start()
19 | {
20 | _thread.Start();
21 | }
22 |
23 | public void Join()
24 | {
25 | _thread.Join();
26 | }
27 |
28 | private void ThreadProc()
29 | {
30 | for (int i = 0; i <= MaxValue; i++)
31 | {
32 | Value = i;
33 | }
34 | }
35 |
36 | public int Value
37 | {
38 | get
39 | {
40 | lock (this)
41 | return _value;
42 | }
43 | set
44 | {
45 | lock (this)
46 | _value.Value = value;
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/MultithreadedData/TargetThread.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading;
4 | using UpdateControls.Fields;
5 |
6 | namespace UpdateControls.UnitTest.MultithreadedData
7 | {
8 | public class TargetThread
9 | {
10 | private SourceThread[] _sources;
11 | private Thread _thread;
12 | private Dependent _total;
13 |
14 | public TargetThread(SourceThread[] sources)
15 | {
16 | _sources = sources;
17 | _thread = new Thread(ThreadProc);
18 | _total = new Dependent(() => _sources.Sum(source => source.Value));
19 | }
20 |
21 | public void Start()
22 | {
23 | _thread.Start();
24 | }
25 |
26 | public void Join()
27 | {
28 | _thread.Join();
29 | }
30 |
31 | public int Total
32 | {
33 | get
34 | {
35 | lock (this)
36 | return _total;
37 | }
38 | }
39 |
40 | private void ThreadProc()
41 | {
42 | for (int i = 0; i < SourceThread.MaxValue; i++)
43 | {
44 | int total = Total;
45 | if (total < 0) // This will never happen, but we need to ensure that the property get is not optimized out.
46 | throw new InvalidOperationException();
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/MultithreadedTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 | using UpdateControls.UnitTest.MultithreadedData;
7 |
8 | namespace UpdateControls.UnitTest
9 | {
10 | [TestClass]
11 | public class MultithreadedTest
12 | {
13 | [TestMethod]
14 | public void IsThreadSafe()
15 | {
16 | const int ThreadCount = 10;
17 |
18 | // Start source threads.
19 | SourceThread[] sources = new SourceThread[ThreadCount];
20 | for (int i = 0; i < ThreadCount; i++)
21 | {
22 | sources[i] = new SourceThread();
23 | sources[i].Start();
24 | }
25 |
26 | // Start target threads.
27 | TargetThread[] targets = new TargetThread[ThreadCount];
28 | for (int i = 0; i < ThreadCount; i++)
29 | {
30 | targets[i] = new TargetThread(sources);
31 | targets[i].Start();
32 | }
33 |
34 | // Wait for all threads to finish.
35 | for (int i = 0; i < ThreadCount; i++)
36 | {
37 | sources[i].Join();
38 | targets[i].Join();
39 | }
40 |
41 | // All targets are in the correct state.
42 | for (int i = 0; i < ThreadCount; i++)
43 | {
44 | Assert.AreEqual(ThreadCount * SourceThread.MaxValue, targets[i].Total);
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UpdateControls.UnitTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UpdateControls.UnitTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("93f186f5-6e37-40b1-8767-4c2305929548")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Portable/UpdateControls.UnitTest/SourceData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using UpdateControls.Fields;
4 |
5 | namespace UpdateControls.UnitTest
6 | {
7 | public class SourceData
8 | {
9 | private Independent _sourceProperty = new Independent();
10 | private AutoResetEvent _continue = new AutoResetEvent(false);
11 |
12 | public int SourceProperty
13 | {
14 | get
15 | {
16 | int result = _sourceProperty;
17 | ThreadPool.QueueUserWorkItem(o =>
18 | {
19 | if (AfterGet != null)
20 | AfterGet();
21 | _continue.Set();
22 | });
23 | _continue.WaitOne();
24 | return result;
25 | }
26 | set { _sourceProperty.Value = value; }
27 | }
28 |
29 | public event Action AfterGet;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/Collections/DependentList.cs:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Update Controls .NET
4 | * Copyright 2011 Michael L Perry
5 | * MIT License
6 | *
7 | * http://updatecontrols.net
8 | * http://www.codeplex.com/updatecontrols/
9 | *
10 | **********************************************************************/
11 |
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | namespace UpdateControls.Collections
16 | {
17 | public class DependentList : IEnumerable
18 | {
19 | private readonly Func> _computeCollection;
20 |
21 | private List _list = new List();
22 | private Dependent _dependentSentry;
23 |
24 | public DependentList(Func> computeCollection)
25 | {
26 | _computeCollection = computeCollection;
27 |
28 | _dependentSentry = new NamedDependent(MemoizedTypeName>.GenericName(),
29 | delegate {
30 | using (var bin = new RecycleBin(_list))
31 | {
32 | _list.Clear();
33 |
34 | foreach (T item in computeCollection())
35 | _list.Add(bin.Extract(item));
36 | }
37 | });
38 | }
39 |
40 | public int IndexOf(T item)
41 | {
42 | _dependentSentry.OnGet();
43 | return _list.IndexOf(item);
44 | }
45 |
46 | public T this[int index]
47 | {
48 | get
49 | {
50 | _dependentSentry.OnGet();
51 | return _list[index];
52 | }
53 | }
54 |
55 | public bool Contains(T item)
56 | {
57 | _dependentSentry.OnGet();
58 | return _list.Contains(item);
59 | }
60 |
61 | public void CopyTo(T[] array, int arrayIndex)
62 | {
63 | _dependentSentry.OnGet();
64 | _list.CopyTo(array, arrayIndex);
65 | }
66 |
67 | public int Count
68 | {
69 | get { _dependentSentry.OnGet(); return _list.Count; }
70 | }
71 |
72 | public IEnumerator GetEnumerator()
73 | {
74 | _dependentSentry.OnGet();
75 | return _list.GetEnumerator();
76 | }
77 |
78 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
79 | {
80 | _dependentSentry.OnGet();
81 | return ((System.Collections.IEnumerable)_list).GetEnumerator();
82 | }
83 |
84 | public Dependent DependentSentry
85 | {
86 | get { return _dependentSentry; }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/Collections/Impl/UpdateCollectionHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace UpdateControls.Collections.Impl
7 | {
8 | /// Helper structure used by DependentDictionary and
9 | /// IndependentDictionary to represent the "Keys" and "Values" members.
10 | ///
11 | /// If you save a reference to the Keys or Values property of ,
12 | /// the independent sentry should be informed when that collection is accessed.
13 | /// This helper class ensures that the sentry is notified.
14 | ///
15 | /// For , this class is even more
16 | /// important. Whenever DependentDictionary is updated, a new dictionary is
17 | /// created to hold the updated content, so the Keys and Values collections
18 | /// change frequently. This wrapper ensure that you do not accidentally hold
19 | /// a reference to an out-of-date version of the Keys or Values collection.
20 | /// It also ensures that the dictionary is updated if necessary when it is
21 | /// accessed through the Keys or Values collection.
22 | ///
23 | public struct UpdateCollectionHelper : ICollection
24 | {
25 | readonly Func> _get;
26 |
27 | public UpdateCollectionHelper(Func> getCollection)
28 | {
29 | _get = getCollection;
30 | }
31 |
32 | public void Add(T item)
33 | {
34 | throw new NotSupportedException();
35 | }
36 | public void Clear()
37 | {
38 | throw new NotSupportedException();
39 | }
40 | public bool Contains(T item)
41 | {
42 | return _get().Contains(item);
43 | }
44 | public void CopyTo(T[] array, int arrayIndex)
45 | {
46 | _get().CopyTo(array, arrayIndex);
47 | }
48 | public int Count
49 | {
50 | get { return _get().Count; }
51 | }
52 | public bool IsReadOnly
53 | {
54 | get { return true; }
55 | }
56 | public bool Remove(T item)
57 | {
58 | throw new NotSupportedException();
59 | }
60 |
61 | public IEnumerator GetEnumerator()
62 | {
63 | return _get().GetEnumerator();
64 | }
65 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
66 | {
67 | return GetEnumerator();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/DependentJob.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace UpdateControls
7 | {
8 | public class DependentJob : IUpdatable, IDisposable
9 | {
10 | Dependent _dependent;
11 | bool _running;
12 |
13 | public DependentJob(Action action)
14 | {
15 | _dependent = new Dependent(action);
16 | _dependent.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
17 | }
18 |
19 | public void Start()
20 | {
21 | if (_dependent == null)
22 | throw new InvalidOperationException("Cannot restart DependentJob");
23 | _running = true;
24 | UpdateScheduler.ScheduleUpdate(this);
25 | }
26 |
27 | public void Stop()
28 | {
29 | _running = false;
30 | _dependent.Dispose();
31 | _dependent = null;
32 | }
33 |
34 | public void Dispose() { Stop(); }
35 |
36 | void IUpdatable.UpdateNow()
37 | {
38 | if (_running)
39 | _dependent.OnGet();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/Fields/Dependent.cs:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Update Controls .NET
4 | * Copyright 2011 Michael L Perry
5 | * MIT License
6 | *
7 | * This class based on a contribution by David Piepgrass.
8 | *
9 | * http://updatecontrols.net
10 | * http://www.codeplex.com/updatecontrols/
11 | *
12 | **********************************************************************/
13 |
14 | using System;
15 | using System.ComponentModel;
16 |
17 | namespace UpdateControls.Fields
18 | {
19 | public class Dependent : NamedDependent
20 | {
21 | protected internal T _value;
22 | protected Func _computeValue;
23 |
24 | public Dependent(Func compute) : base((string)null, null)
25 | {
26 | base._update = Update; _computeValue = compute;
27 | }
28 | public Dependent(string name, Func compute) : base(name, null)
29 | {
30 | base._update = Update; _computeValue = compute;
31 | }
32 |
33 | protected void Update()
34 | {
35 | _value = _computeValue();
36 | // TODO: don't propagate updates when _value did not change.
37 | // T oldValue = _value;
38 | // _value = _computeValue();
39 | // return _value == null ? oldValue != null : !_value.Equals(oldValue);
40 | }
41 |
42 | public T Value
43 | {
44 | get { base.OnGet(); return _value; }
45 | }
46 | public static implicit operator T(Dependent dependent)
47 | {
48 | return dependent.Value;
49 | }
50 |
51 | public override string VisualizerName(bool withValue)
52 | {
53 | string s = VisualizerName(_name ?? "NamedDependent");
54 | if (withValue)
55 | s += " = " + (_value == null ? "null" : _value.ToString());
56 | return s;
57 | }
58 | internal static string VisualizerName(string name)
59 | {
60 | string typeName = MemoizedTypeName.GenericName();
61 | if (!string.IsNullOrEmpty(name))
62 | return string.Format("{0}: {1}", name, typeName);
63 | else
64 | return typeName;
65 | }
66 |
67 | [Obsolete, EditorBrowsable(EditorBrowsableState.Never)]
68 | public Dependent DependentSentry
69 | {
70 | get { return this; }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/Fields/Independent.cs:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Update Controls .NET
4 | * Copyright 2011 Michael L Perry
5 | * MIT License
6 | *
7 | * This class based on a contribution by David Piepgrass.
8 | *
9 | * http://updatecontrols.net
10 | * http://www.codeplex.com/updatecontrols/
11 | *
12 | **********************************************************************/
13 | using System;
14 | using System.ComponentModel;
15 |
16 | namespace UpdateControls.Fields
17 | {
18 | public class Independent : NamedIndependent
19 | {
20 | protected internal T _value;
21 |
22 | public Independent() { }
23 | public Independent(T value) : this((string)null, value) { }
24 |
25 | // Oops, this constructor causes ambiguity in case of Independent.
26 | // In that case, C# compilers will reinterpret existing code that previously
27 | // used the Independent(value) constructor to call Independent(name) instead.
28 | //public Independent(string name) : base(name) { }
29 |
30 | public Independent(string name, T value) : base(name) { _value = value; }
31 | public Independent(Type containerType, string name) : base(containerType, name) { }
32 | public Independent(Type containerType, string name, T value) : base(containerType, name) { _value = value; }
33 |
34 | public T Value
35 | {
36 | get { base.OnGet(); return _value; }
37 | set {
38 | if (_value == null ? value != null : !_value.Equals(value))
39 | {
40 | base.OnSet();
41 | _value = value;
42 | }
43 | }
44 | }
45 | public static implicit operator T(Independent independent)
46 | {
47 | return independent.Value;
48 | }
49 |
50 | public override string VisualizerName(bool withValue)
51 | {
52 | string s = "[I] " + Dependent.VisualizerName(Name);
53 | if (withValue)
54 | s += " = " + (_value == null ? "null" : _value.ToString());
55 | return s;
56 | }
57 |
58 | [Obsolete, EditorBrowsable(EditorBrowsableState.Never)]
59 | public Independent IndependentSentry
60 | {
61 | get { return this; }
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/Portable/UpdateControls/IUpdatable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace UpdateControls
7 | {
8 | public interface IUpdatable
9 | {
10 | void UpdateNow();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/MemoizedTypeName.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace UpdateControls
7 | {
8 | /// .NET Framework reflection doesn't offer complete type names for
9 | /// generic types such as "List<int>" (the Type.Name value of that class is
10 | /// "List`1"). fills in the gap, and also saves the
11 | /// computed name for fast repeated lookups.
12 | public static class MemoizedTypeName
13 | {
14 | static Dictionary _shortNames = new Dictionary();
15 |
16 | /// Computes a short language-agnostic name for a type, including
17 | /// generic parameters, e.g. GenericName(typeof(int)) is "Int32";
18 | /// GenericName(typeof(Dictionary<int, string>)) is
19 | /// "Dictionary<Int32, String>".
20 | /// Type whose name you want
21 | /// Name with generic parameters, as explained in the summary.
22 | /// The result is memoized for generic types, so that the name is
23 | /// computed only once.
24 | public static string GenericName(Type type)
25 | {
26 | if (type == null)
27 | return null;
28 | string name;
29 | lock (_shortNames)
30 | {
31 | if (!_shortNames.TryGetValue(type, out name))
32 | {
33 | if (type.IsGenericType)
34 | _shortNames[type] = name = ComputeGenericName(type);
35 | else
36 | name = type.Name;
37 | }
38 | }
39 | return name;
40 | }
41 |
42 | /// Computes a type's name without memoization.
43 | internal static string ComputeGenericName(Type type)
44 | {
45 | string result = type.Name;
46 | if (type.IsGenericType)
47 | {
48 | // remove genric indication (e.g. `1)
49 | result = result.Substring(0, result.LastIndexOf('`'));
50 |
51 | result = string.Format(
52 | "{0}<{1}>",
53 | result,
54 | string.Join(", ", type.GetGenericArguments()
55 | .Select(t => GenericName(t)).ToArray()));
56 | }
57 | return result;
58 | }
59 |
60 | /// Extension method on Type that is an alias for the method.
61 | public static string NameWithGenericParams(this Type t)
62 | {
63 | return GenericName(t);
64 | }
65 | }
66 |
67 | public static class MemoizedTypeName
68 | {
69 | static string _name;
70 | public static string GenericName()
71 | {
72 | if (_name == null)
73 | _name = MemoizedTypeName.GenericName(typeof(T));
74 | return _name;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/NamedPrecedents.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Diagnostics;
6 | using System.Reflection;
7 |
8 | namespace UpdateControls
9 | {
10 | public class NamedDependent : Dependent
11 | {
12 | public NamedDependent(Action update) : this(null, update) { }
13 | public NamedDependent(string name, Action update) : base(update) { _name = name; }
14 |
15 | protected string _name;
16 | public string Name
17 | {
18 | get {
19 | if (_name == null)
20 | _name = ComputeName();
21 | return _name;
22 | }
23 | }
24 |
25 | public override string VisualizerName(bool withValue)
26 | {
27 | return VisNameWithOptionalHash(Name, withValue);
28 | }
29 | public static string GetClassAndMethodName(Delegate d)
30 | {
31 | return MemoizedTypeName.GenericName(d.Method.DeclaringType) + "." + d.Method.Name;
32 | }
33 | protected virtual string ComputeName()
34 | {
35 | return GetClassAndMethodName(_update) + "()";
36 | }
37 | }
38 |
39 | public class NamedIndependent : Independent
40 | {
41 | public NamedIndependent() : base() { }
42 | public NamedIndependent(string name) : base() { _name = name; }
43 | public NamedIndependent(Type valueType) : this(valueType.NameWithGenericParams()) { }
44 | public NamedIndependent(Type containerType, string name) :
45 | this(string.Format("{0}.{1}", containerType.NameWithGenericParams(), name)) { }
46 |
47 | public override void OnGet()
48 | {
49 | // TODO: Figure out _name
50 | base.OnGet();
51 | }
52 |
53 | protected string _name;
54 | public string Name
55 | {
56 | get { return _name ?? "NamedIndependent"; }
57 | set { _name = value; }
58 | }
59 |
60 | public override string VisualizerName(bool withValue)
61 | {
62 | return VisNameWithOptionalHash("[I] " + Name, withValue);
63 | }
64 | }
65 |
66 | [Obsolete]
67 | public class NamedIndependent : UpdateControls.Fields.Independent
68 | {
69 | public NamedIndependent() : base() { }
70 | public NamedIndependent(T value) : base(value) { }
71 | public NamedIndependent(string name, T value) : base(name, value) { }
72 | public NamedIndependent(Type containerType, string name) : base(containerType, name) { }
73 | public NamedIndependent(Type containerType, string name, T value) : base(containerType, name, value) { }
74 | }
75 |
76 | [Obsolete]
77 | public class NamedDependent : UpdateControls.Fields.Dependent
78 | {
79 | public NamedDependent(Func compute) : base(compute) { }
80 | public NamedDependent(string name, Func compute) : base(name, compute) { }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | [assembly: AssemblyTitle("UpdateControls")]
7 | [assembly: AssemblyProduct("UpdateControls")]
8 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/ThreadLocal.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading;
3 |
4 | namespace UpdateControls
5 | {
6 | public class ThreadLocal
7 | {
8 | private Dictionary _valueByThread = new Dictionary();
9 |
10 | public T Get()
11 | {
12 | lock (this)
13 | {
14 | T value;
15 | if (!_valueByThread.TryGetValue(Thread.CurrentThread.ManagedThreadId, out value))
16 | return default(T);
17 | return value;
18 | }
19 | }
20 |
21 | public void Set(T value)
22 | {
23 | lock (this)
24 | {
25 | _valueByThread[Thread.CurrentThread.ManagedThreadId] = value;
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/UpdateControlsExtensions.cs:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Update Controls .NET
4 | * Copyright 2010 Michael L Perry
5 | * MIT License
6 | *
7 | * http://updatecontrols.net
8 | * http://www.codeplex.com/updatecontrols/
9 | *
10 | **********************************************************************/
11 |
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | namespace UpdateControls
16 | {
17 | public static class UpdateControlsExtensions
18 | {
19 | ///
20 | /// Moves all objects into a new recycle bin, from which they can be extracted.
21 | ///
22 | /// A collection of objects to add to the bin.
23 | ///
24 | /// After the objects are added to the bin, the collection
25 | /// is cleared. Then it can be repopulated by extraction from
26 | /// the bin.
27 | ///
28 | public static RecycleBin Recycle(this ICollection collection)
29 | {
30 | RecycleBin bin = new RecycleBin(collection);
31 |
32 | if (collection != null)
33 | collection.Clear();
34 |
35 | return bin;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Portable/UpdateControls/UpdateScheduler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace UpdateControls
5 | {
6 | public class UpdateScheduler
7 | {
8 | private static Action _runOnUIThread;
9 | private static ThreadLocal _currentSet = new ThreadLocal();
10 |
11 | public static void Initialize(Action runOnUIThread)
12 | {
13 | if (_runOnUIThread == null)
14 | {
15 | _runOnUIThread = runOnUIThread;
16 | }
17 | }
18 |
19 | public static UpdateScheduler Begin()
20 | {
21 | // If someone is already capturing the affected set,
22 | // let them keep that responsibility.
23 | if (_currentSet.Get() != null)
24 | return null;
25 |
26 | UpdateScheduler currentSet = new UpdateScheduler();
27 | _currentSet.Set(currentSet);
28 | return currentSet;
29 | }
30 |
31 | public static void ScheduleUpdate(IUpdatable updatable)
32 | {
33 | UpdateScheduler currentSet = _currentSet.Get();
34 | if (currentSet != null)
35 | currentSet._updatables.Add(updatable);
36 | else if (_runOnUIThread != null)
37 | _runOnUIThread(updatable.UpdateNow);
38 | }
39 |
40 | private List _updatables = new List();
41 |
42 | public IEnumerable End()
43 | {
44 | System.Diagnostics.Debug.Assert(_currentSet.Get() == this);
45 | _currentSet.Set(null);
46 | return _updatables;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Silverlight/UpdateControls.XAML/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("UpdateControls.XAML")]
6 | [assembly: AssemblyProduct("UpdateControls.XAML")]
7 | [assembly: ComVisible(false)]
8 |
--------------------------------------------------------------------------------
/Silverlight/UpdateControls.XAML/Wrapper/ClassInstance.cs:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Update Controls .NET
4 | * Copyright 2010 Michael L Perry
5 | * MIT License
6 | *
7 | * http://updatecontrols.net
8 | * http://updatecontrols.codeplex.com/
9 | *
10 | **********************************************************************/
11 |
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Reflection;
16 |
17 | namespace UpdateControls.XAML.Wrapper
18 | {
19 | public class ClassInstance : DelegatedType
20 | {
21 | private Type _wrappedType;
22 | private Type _objectInstanceType;
23 | private List _classProperties;
24 |
25 | public ClassInstance(Type wrappedType, Type objectInstanceType)
26 | : base(wrappedType)
27 | {
28 | _wrappedType = wrappedType;
29 | _objectInstanceType = objectInstanceType;
30 |
31 | // Create a wrapper for each non-collection property.
32 | _classProperties = _wrappedType
33 | .GetProperties()
34 | .Select(p => new ClassProperty(p, objectInstanceType))
35 | .ToList();
36 | }
37 |
38 | public IEnumerable ClassProperties
39 | {
40 | get { return _classProperties; }
41 | }
42 |
43 | public override string ToString()
44 | {
45 | return _wrappedType.Name;
46 | }
47 |
48 | protected override PropertyInfo DelegatePropertyInfo(PropertyInfo rawPropertyInfo)
49 | {
50 | return new ClassProperty(rawPropertyInfo, _objectInstanceType);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Silverlight/UpdateControls.XAML/Wrapper/CollectionItem.cs:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Update Controls .NET
4 | * Copyright 2010 Michael L Perry
5 | * MIT License
6 | *
7 | * http://updatecontrols.net
8 | * http://updatecontrols.codeplex.com/
9 | *
10 | **********************************************************************/
11 |
12 | using System;
13 | using System.Collections.ObjectModel;
14 |
15 | namespace UpdateControls.XAML.Wrapper
16 | {
17 | class CollectionItem : IDisposable
18 | {
19 | private ObservableCollection