private void Initialize() { _Template = new Lazy <AFElementTemplate>(() => { var templateName = _EventFrameLoader.GetEventFrameTemplate(_Connection, this._ID); return(AFElementTemplate.FindByName(templateName)); }, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); _EventFrames = new Lazy <ObservableCollection <AFEventFrame> >(() => { List <AFEventFrame> frames = _EventFrameLoader.GetEventFrames(_Connection, _ID).ToList(); ObservableCollection <AFEventFrame> obsList = new ObservableCollection <AFEventFrame>(frames); obsList.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ChildrenChanged); return(obsList); }, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); _Attributes = new Lazy <ObservableCollection <AFAttribute> >(() => { var attrs = _EventFrameLoader.GetAttributes(_Connection, this._ID, "*", "*", "*", "*", false, "Name", "Ascending", 0, false, false, 1000); ObservableCollection <AFAttribute> obsList = new ObservableCollection <AFAttribute>(); foreach (var attribute in attrs) { obsList.Add(AFAttribute.Find(_Connection, attribute.ID)); } obsList.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(AttributesChanged); return(obsList); }, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); }
/// <summary> /// Builds loader object and sets all callbacks for lazy loading /// </summary> private void Initialize() { //Initialize Category List _Categories = new Lazy <ObservableCollection <string> >(() => { return(new ObservableCollection <string>(_ElementLoader.GetCategories(_Connection, _ID))); }, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); //Initialize Template Loader _Template = new Lazy <AFElementTemplate>(() => { string templateName = _ElementLoader.GetElementTemplate(_Connection, this._ID); return(AFElementTemplate.Find(_Connection, templateName)); }, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); //Initialize Parent Loader string parentPath = Path.Substring(0, Path.LastIndexOf('\\')); _Parent = new Lazy <AFElement>(() => { return(_ElementLoader.FindByPath(_Connection, parentPath)); }, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); //Initialize Attributes Loader _Attributes = new Lazy <ObservableCollection <AFAttribute> >(() => { List <LazyObjects.AFAttribute> resultList = _ElementLoader.GetAttributes(_Connection, this.ID).ToList(); ObservableCollection <AFAttribute> obsList = new ObservableCollection <AFAttribute>(); foreach (var attr in resultList) { obsList.Add(AFAttribute.Find(_Connection, attr.ID)); } obsList.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(AttributesChanged); return(obsList); }, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); //Initialize Children Loader _Children = new Lazy <ObservableCollection <AFElement> >(() => { List <LazyObjects.AFElement> resultList = _ElementLoader.GetElements(_Connection, this.ID).ToList(); ObservableCollection <AFElement> obsList = new ObservableCollection <AFElement>(resultList); obsList.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ChildrenChanged); return(obsList); }, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); }