Exemple #1
0
 void initLazyLoaders(bool newOrder)
 {
     _OemInfoLoader = new LazyLoader <OEMInfo>(() => OEMService.QueryOEMById(OEMID.Value));
     if (newOrder)
     {
         _applyformLoader    = new EnumerableLazyLoader <BaseApplyform>();
         _operationLoader    = new EnumerableLazyLoader <Log.Domain.OrderLog>();
         _coordinationLoader = new EnumerableLazyLoader <Coordination>();
     }
     else
     {
         _applyformLoader = new EnumerableLazyLoader <BaseApplyform>(() => {
             return(ApplyformQueryService.QueryApplyforms(this.Id));
         });
         _operationLoader = new EnumerableLazyLoader <Log.Domain.OrderLog>(() => {
             return(LogService.QueryOrderLog(this.Id));
         });
         _coordinationLoader = new EnumerableLazyLoader <Coordination>(() => {
             return(CoordinationService.QueryOrderCoordinations(this.Id));
         });
     }
     _associateOrderLoader   = new LazyLoader <Order>();
     _distributionBillLoader = new LazyLoader <Service.Distribution.Domain.OrderBill>(() => {
         return(DistributionQueryService.QueryOrderBill(this.Id));
     });
 }
        public AdministrationManager()
            : base()
        {
            LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());

            this.ConfigureAutoMapper();
        }
Exemple #3
0
        //
        // AsyncDbListBase core methods implementation

        /// <summary>
        ///   Fully load lazy loaded items.
        /// </summary>
        protected override async Task DoFurtherLoadAsync()
        {
            IEnumerable <Card> cards;
            HashSet <int>      cardsId;

            lock (LockObject)
            {
                cards =
                    Objects.Skip(GetFurtherLoadedIndex())
                    .Take(
                        Math.Max(Index - GetFurtherLoadedIndex(), 0) + IncrementalFurtherLoadMax
                        - IncrementalFurtherLoadMin);

                cardsId = new HashSet <int>(cards.Select(c => c.Id));
            }

            IEnumerable <Card> updateCards =
                await
                Db.Table <Card>()
                .FurtherLoad(LazyLoader)
                .Where(c => cardsId.Contains(c.Id))
                .ToListAsync()
                .ConfigureAwait(false);

            lock (LockObject)
            {
                foreach (Card card in cards)
                {
                    LazyLoader.UpdateFromFurtherLoad(
                        card, updateCards.FirstOrDefault(uc => uc.Id == card.Id));
                }

                FurtherLoadedIndex = FurtherLoadedIndex + updateCards.Count();
            }
        }
 public void LazyLoaderImplicitCastTest()
 {
     LazyLoader<string> target = new LazyLoader<string>(() => new string(new[] { 'a', 'b', 'c' }));
     Assert.AreEqual("abc", (string)target);
     target = "Hello";
     Assert.AreEqual("Hello", (string)target);
 }
Exemple #5
0
        public ElementBehaviorManager()
        {
            _getBehaviorStyles = new LazyLoader <string>(() =>
            {
                StringBuilder stylesBuilder = new StringBuilder();
                foreach (ElementBehaviorDefinition behaviorDefinition in _behaviorDefinitions)
                {
                    stylesBuilder.Append(behaviorDefinition.TargetClass + " { behavior: url(#default#" +
                                         behaviorDefinition.HtmlId + ") }\r\n");
                }
                return(stylesBuilder.ToString());
            });

            _getBehaviorObjectTags = new LazyLoader <string>(() =>
            {
                StringBuilder objectTagsBuilder = new StringBuilder();
                foreach (ElementBehaviorDefinition behaviorDefinition in _behaviorDefinitions)
                {
                    objectTagsBuilder.Append("<object id=\"" + behaviorDefinition.HtmlId + "\" clsid=\"clsid:" +
                                             behaviorDefinition.Clsid +
                                             "\" style=\"visibility: hidden\" width=\"0px\" height=\"0px\"> </object>\r\n");
                }
                return(objectTagsBuilder.ToString());
            });
        }
 protected School(LazyLoader lazyLoader)//Нужен для ленивой загрузки в обычном режиме если опреден конструктор кроме стандартного
     : this()
     //Если прокси обьект видит, что в классе сущности есть контсруктор кроме стандартного - ищет подходящий себе конструктор
     //или выбрасывает исключение
 {
     LazyLoader = lazyLoader;
 }
Exemple #7
0
        private void ConfigureViewService()
        {
            LazyLoader.Set <MacroEditorView>(() => new MacroEditorView());
            LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());

            ViewService.Configure(e =>
            {
                e.Bind <AddRecordView, AddRecordViewModel>()
                .OnShow(vm =>
                {
                    vm.Refresh();
                    this.View.As <WorkbenchViewModel>().SaveCommand.TryExecute();
                })
                .OnClosing(() => this.View.As <WorkbenchViewModel>().RefreshCommand.TryExecute());

                e.Bind <AddFolderView, AddFolderViewModel>()
                .OnShow(() => this.View.As <WorkbenchViewModel>().SaveCommand.TryExecute())
                .OnClosing(() => this.View.As <WorkbenchViewModel>().RefreshCommand.TryExecute());

                e.Bind <MacroEditorView, MacroEditorViewModel>()
                .OnShow(vm =>
                {
                    this.View.As <WorkbenchViewModel>().SaveCommand.TryExecute();
                    vm.RefreshCommand.TryExecute();
                })
                .OnClosing(vm =>
                {
                    vm.SaveCommand.TryExecute();
                    this.View.As <WorkbenchViewModel>().RefreshCommand.TryExecute();
                });

                e.Bind <RecordHistoryView, RecordHistoryViewModel>();
            });
        }
Exemple #8
0
 protected OrderRoleInfo(Guid companyId, string name)
 {
     this.CompanyId = companyId;
     this.Name      = name;
     _companyLoader = new LazyLoader <DataTransferObject.Organization.CompanyInfo>(() => {
         return(ChinaPay.B3B.Service.Organization.CompanyService.GetCompanyDetail(this.CompanyId));
     });
 }
Exemple #9
0
 private void Select()
 {
     LazyLoader.Get <AddPrescriptionView>().As <AddPrescriptionViewModel>().Prescriptions.Add(new PrescriptionDto()
     {
         Drug = this.SelectedDrug
     });
     this.Close();
 }
Exemple #10
0
 private void ConfigureViewService()
 {
     LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());
     ViewService.Configure(e =>
     {
         e.Bind <WorkbenchView, WorkbenchViewModel>();
     });
 }
Exemple #11
0
 void initLazyLoaders()
 {
     _operationLoader    = new EnumerableLazyLoader <Log.Domain.OrderLog>(() => LogService.QueryApplyformLog(this.Id));
     _coordinationLoader = new EnumerableLazyLoader <Coordination>(() => CoordinationService.QueryApplyformCoordinations(this.Id));
     _orderLoader        = new LazyLoader <Order>(() => OrderQueryService.QueryOrder(this.OrderId));
     _purchaserLoader    = new LazyLoader <DataTransferObject.Organization.CompanyInfo>(() => Organization.CompanyService.GetCompanyDetail(this.PurchaserId));
     _providerLoader     = new LazyLoader <DataTransferObject.Organization.CompanyInfo>(() => Organization.CompanyService.GetCompanyDetail(this.ProviderId));
     _OemInfoLoader      = new LazyLoader <OEMInfo>(() => OEMService.QueryOEMById(OEMID.Value));
 }
Exemple #12
0
        public static ImageViewer DetectImageViewer(string html, string sourceUrl)
        {
            List <ImageViewer>         viewers = imageViewers;
            LazyLoader <List <Regex> > regexes = new LazyLoader <List <Regex> >(delegate
            {
                List <Regex> regexList = new List <Regex>(viewers.Count);
                foreach (ImageViewer v in viewers)
                {
                    regexList.Add(new Regex(v.Pattern, RegexOptions.CultureInvariant));
                }
                return(regexList);
            });

            HtmlExtractor ex = new HtmlExtractor(html);

            while (ex.Seek("<script src>").Success)
            {
                BeginTag tag = (BeginTag)ex.Element;
                string   src = tag.GetAttributeValue("src");

                if (String.IsNullOrEmpty(src))
                {
                    continue;
                }

                try
                {
                    if (!UrlHelper.IsUrl(src))
                    {
                        // We need absolute URLs.
                        src = UrlHelper.EscapeRelativeURL(sourceUrl, src);
                    }

                    Uri srcUri = new Uri(src);
                    if (srcUri.IsAbsoluteUri)
                    {
                        // WinLive 248276: We want just the path portion since there could be an additional query or
                        // fragment on the URL that our regexs can't handle.
                        src = srcUri.GetLeftPart(UriPartial.Path);
                    }
                }
                catch (UriFormatException)
                {
                    // We'll just use the regex on the raw attribute value.
                }

                List <Regex> regexList = regexes.Value;
                for (int i = 0; i < regexList.Count; i++)
                {
                    if (regexList[i].IsMatch(src))
                    {
                        return(viewers[i]);
                    }
                }
            }
            return(null);
        }
Exemple #13
0
        public WordCounter(string text)
        {
            countText = HtmlUtils.HTMLToPlainText(text);

            llWords = new LazyLoader <int>(delegate { return(regexWords.Matches(countText).Count); });
            llChars = new LazyLoader <int>(delegate { return(regexChars.Matches(countText).Count); });
            llCharsWithoutSpaces = new LazyLoader <int>(delegate { return(regexCharsWithoutSpace.Matches(countText).Count); });
            llParagraphs         = new LazyLoader <int>(delegate { return(countText.Length == 0 ? 0 : regexParagraph.Matches(countText).Count + 1); });
        }
 private void Search()
 {
     try
     {
         LazyLoader.Get <WorkbenchView>().As <WorkbenchViewModel>().RefreshPrescriptions(this.StartCriteria, this.EndCriteria);
         this.Close();
     }
     catch (Exception ex) { this.Handle.Error(ex, Messages.Msg_ErrorSearchingPrescriptions); }
 }
        public MigrationInfo(long version, string description, TransactionBehavior transactionBehavior, Func<IMigration> migrationFunc)
        {
            if (migrationFunc == null) throw new ArgumentNullException("migrationFunc");

            Version = version;
            Description = description;
            TransactionBehavior = transactionBehavior;
            _lazyMigration = new LazyLoader<IMigration>(migrationFunc);
        }
Exemple #16
0
        public void LazyLoader_Integration_Serialization_Optimal()
        {
            const String Value = "This is a test.";
            LazyLoader<String> original = new LazyLoader<String>(() => Value);
            original.Load();

            LazyLoader<String> clone = original.SerializeBinary();
            Assert.AreEqual(false, clone.IsInitialized);
            Assert.AreEqual(Value, clone.Object);
        }
Exemple #17
0
        /// <summary>
        /// Initialises this plugin. Basicaly it should configure the menus into the PluginHost
        /// Every task that could throw exception should be in this method and not in the ctor.
        /// </summary>
        public override void Initialise()
        {
            PluginContext.Host.Invoke(() =>
            {
                LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());

                this.BuildButtons();
                this.BuildContextMenu();
                this.ConfigureWindowManager();
            });
        }
        public static ImageViewer DetectImageViewer(string html, string sourceUrl)
        {
            List<ImageViewer> viewers = imageViewers;
            LazyLoader<List<Regex>> regexes = new LazyLoader<List<Regex>>(delegate
              {
                  List<Regex> regexList = new List<Regex>(viewers.Count);
                  foreach (ImageViewer v in viewers)
                  {
                      regexList.Add(new Regex(v.Pattern, RegexOptions.CultureInvariant));
                  }
                  return regexList;
              });

            HtmlExtractor ex = new HtmlExtractor(html);
            while (ex.Seek("<script src>").Success)
            {
                BeginTag tag = (BeginTag)ex.Element;
                string src = tag.GetAttributeValue("src");

                if (String.IsNullOrEmpty(src))
                {
                    continue;
                }

                try
                {
                    if (!UrlHelper.IsUrl(src))
                    {
                        // We need absolute URLs.
                        src = UrlHelper.EscapeRelativeURL(sourceUrl, src);
                    }

                    Uri srcUri = new Uri(src);
                    if (srcUri.IsAbsoluteUri)
                    {
                        // WinLive 248276: We want just the path portion since there could be an additional query or
                        // fragment on the URL that our regexs can't handle.
                        src = srcUri.GetLeftPart(UriPartial.Path);
                    }
                }
                catch (UriFormatException)
                {
                    // We'll just use the regex on the raw attribute value.
                }

                List<Regex> regexList = regexes.Value;
                for (int i = 0; i < regexList.Count; i++)
                {
                    if (regexList[i].IsMatch(src))
                        return viewers[i];
                }
            }
            return null;
        }
Exemple #19
0
        async Task InitializeComponents()
        {
            Data["TopMenu"] = "MainMenu";
            Title           = "Contact details";

            await Body.Add(ContactFormLoader = new LazyLoader { Id = "ContactFormLoader" });

            await ContactFormLoader.Add(ContactForm = new Modules.ContactForm {
                Id = "ContactForm"
            });
        }
Exemple #20
0
        public StructContext(IIResultSaver saver, IIDecompiledData decompiledData, LazyLoader
                             loader)
        {
            this.saver          = saver;
            this.decompiledData = decompiledData;
            this.loader         = loader;
            ContextUnit defaultUnit = new ContextUnit(ContextUnit.Type_Folder, null, string.Empty
                                                      , true, saver, decompiledData);

            Sharpen.Collections.Put(units, string.Empty, defaultUnit);
        }
Exemple #21
0
        public MigrationInfo(long version, string description, TransactionBehavior transactionBehavior, Func <IMigration> migrationFunc)
        {
            if (migrationFunc == null)
            {
                throw new ArgumentNullException("migrationFunc");
            }

            Version             = version;
            Description         = description;
            TransactionBehavior = transactionBehavior;
            _lazyMigration      = new LazyLoader <IMigration>(migrationFunc);
        }
Exemple #22
0
 private void ConfigureViewService()
 {
     LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());
     ViewService.Configure(e =>
     {
         e.Bind <AddBmiView, AddBmiViewModel>()
         .OnShow(vm => vm.CurrentBmi = new BmiDto()
         {
             Height = PluginContext.Host.SelectedPatient.Height
         })
         .OnClosing(() => this.Workbench.As <WorkbenchViewModel>().RefreshCommand.TryExecute());
     });
 }
Exemple #23
0
        private void ConfigureViewService()
        {
            LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());
            ViewService.Configure(e =>
            {
                e.Bind <AddCategoryView, AddCategoryViewModel>()
                .OnClosing(() => this.View.As <WorkbenchViewModel>().Refresh());

                e.Bind <AddMeetingView, AddMeetingViewModel>()
                .OnClosing(() => this.View.As <WorkbenchViewModel>().Refresh());

                e.Bind <RemoveMeetingView, RemoveMeetingViewModel>()
                .OnClosing(() => this.View.As <WorkbenchViewModel>().Refresh());
            });
        }
Exemple #24
0
        private void ConfigureViewService()
        {
            LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());
            ViewService.Configure(e =>
            {
                e.Bind <AddPathologyCategoryView, AddPathologyCategoryViewModel>()
                .OnClosing(() => this.View.As <WorkbenchViewModel>().Refresh());

                e.Bind <AddPathologyView, AddPathologyViewModel>()
                .OnShow(vm => vm.Refresh())
                .OnClosing(() => this.View.As <WorkbenchViewModel>().Refresh());

                e.Bind <AddPeriodView, AddPeriodViewModel>()
                .OnClosing(() => this.View.As <WorkbenchViewModel>().Refresh());
            });
        }
            internal BlogPreviewInfo(string blogId, string[] elementIds, bool isRtl, TemplateHtmlDelegate templateHtmlDelegate, string postBodyHtml)
            {
                IsRtl                   = isRtl;
                _blogId                 = blogId;
                _elementIds             = elementIds;
                _templateHtmlLazyLoader = new LazyLoader <string>(delegate
                {
                    return(templateHtmlDelegate());
                });

                string style = isRtl ? "dir=\"rtl\" style=\"direction: rtl; text-align: right" : "dir=\"ltr\" style=\"direction: ltr; text-align: left";

                style        += "; width: 500px; text-indent: 0px; margin: 0px; overflow: visible; vertical-align: baseline; white-space: nowrap; line-height: normal; position: static\"";
                _postBodyHtml = postBodyHtml.Replace("{style}", style);

                _bitmaps = new Dictionary <string, Bitmap>(elementIds.Length);
            }
Exemple #26
0
        private void ConfigureViewService()
        {
            LazyLoader.Set <ConnectionView>(() =>
            {
                ConnectionView view = null;
                PluginContext.Host.Invoke(() => view = new ConnectionView());
                return(view);
            });

            ViewService.Configure(e =>
            {
                e.Bind <AddUserControl, AddUserViewModel>()
                .OnClosing(() => LazyLoader.Get <ConnectionView>().As <ConnectionViewModel>().Refresh());
                e.Bind <ChangePasswordView, ChangePasswordViewModel>();
                e.Bind <UpdateUserControl, UpdateUserViewModel>()
                .OnShow(vm => vm.Refresh());
            });
        }
Exemple #27
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void Reload(LazyLoader loader)
        {
            List <StructClass> lstClasses = new List <StructClass>();

            foreach (StructClass cl in classes)
            {
                string      oldName = cl.qualifiedName;
                StructClass newCl;
                using (DataInputFullStream @in = loader.GetClassStream(oldName))
                {
                    newCl = new StructClass(@in, cl.IsOwn(), loader);
                }
                lstClasses.Add(newCl);
                LazyLoader.Link lnk = loader.GetClassLink(oldName);
                loader.RemoveClassLink(oldName);
                loader.AddClassLink(newCl.qualifiedName, lnk);
            }
            classes = lstClasses;
        }
Exemple #28
0
        private void ConfigureViewService()
        {
            LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());
            LazyLoader.Set <ManageUserView>(() => new ManageUserView());
            LazyLoader.Set <EditAssignedRoleView>(() => new EditAssignedRoleView());

            ViewService.Configure(e =>
            {
                e.Bind <AddRoleView, AddRoleViewModel>()
                .OnClosing(() => this.WorkbenView.As <WorkbenchViewModel>().Refresh());

                e.Bind <EditRoleView, EditRoleViewModel>()
                .OnClosing(() => this.WorkbenView.As <WorkbenchViewModel>().Refresh());

                e.Bind <EditAssignedRoleView, EditAssignedRoleViewModel>()
                .OnShow(vm => vm.Refresh())
                .OnClosing(() =>
                {
                    this.WorkbenView.As <WorkbenchViewModel>().Refresh();
                    this.ManageUserView.As <ManageUserViewModel>().Refresh();
                });
            });
        }
Exemple #29
0
        private void ConfigureViewService()
        {
            LazyLoader.Set <AddPrescriptionView>(() => new AddPrescriptionView());
            LazyLoader.Set <WorkbenchView>(() => new WorkbenchView());

            ViewService.Configure(e =>
            {
                e.Bind <AddDrugTypeView, AddDrugTypeViewModel>()
                .OnClosing(() => this.AddPrescriptionView.As <AddPrescriptionViewModel>().Refresh());
                e.Bind <AddDrugView, AddDrugViewModel>()
                .OnShow(vm => vm.Refresh());
                e.Bind <SearchDrugView, SearchDrugViewModel>()
                .OnShow(vm =>
                {
                    this.isSearching = true;
                    vm.Refresh();
                })
                .OnClosing(() => this.isSearching = false);
                e.Bind <SearchPrescriptionView, SearchPrescriptionViewModel>()
                .OnClosing(vm => this.WorkbenchView.As <WorkbenchViewModel>().RefreshPrescriptions(vm.StartCriteria, vm.EndCriteria));
                e.Bind <EditionView, EditionViewModel>()
                .OnClosing(() => this.WorkbenchView.As <WorkbenchViewModel>().Refresh());
            });
        }
        public WordCounter(string text)
        {
            countText = HtmlUtils.HTMLToPlainText(text);

            llWords = new LazyLoader<int>(delegate { return regexWords.Matches(countText).Count; });
            llChars = new LazyLoader<int>(delegate { return regexChars.Matches(countText).Count; });
            llCharsWithoutSpaces = new LazyLoader<int>(delegate { return regexCharsWithoutSpace.Matches(countText).Count; });
            llParagraphs = new LazyLoader<int>(delegate { return countText.Length == 0 ? 0 : regexParagraph.Matches(countText).Count + 1; });
        }
Exemple #31
0
 public void LazyLoaderNullInitialiserTest()
 {
     LazyLoader<None> target = new LazyLoader<None>(null);
 }
        public ElementBehaviorManager()
        {
            _getBehaviorStyles = new LazyLoader<string>(() =>
            {
                StringBuilder stylesBuilder = new StringBuilder();
                foreach (ElementBehaviorDefinition behaviorDefinition in _behaviorDefinitions)
                {
                    stylesBuilder.Append(behaviorDefinition.TargetClass + " { behavior: url(#default#" +
                                         behaviorDefinition.HtmlId + ") }\r\n");
                }
                return stylesBuilder.ToString();
            });

            _getBehaviorObjectTags = new LazyLoader<string>(() =>
            {
                StringBuilder objectTagsBuilder = new StringBuilder();
                foreach (ElementBehaviorDefinition behaviorDefinition in _behaviorDefinitions)
                {
                    objectTagsBuilder.Append("<object id=\"" + behaviorDefinition.HtmlId + "\" clsid=\"clsid:" +
                                             behaviorDefinition.Clsid +
                                             "\" style=\"visibility: hidden\" width=\"0px\" height=\"0px\"> </object>\r\n");
                }
                return objectTagsBuilder.ToString();
            });
        }
Exemple #33
0
 internal NormalRefundBill(decimal orderId, decimal applyformId)
     : base(applyformId)
 {
     OrderId        = orderId;
     _payBillLoader = new LazyLoader <NormalPayBill>(() => DistributionQueryService.QueryNormalPayBill(OrderId));
 }
Exemple #34
0
 internal NormalRefundRoleBill(TradeRole owner)
     : base(owner)
 {
     _payRoleBillLoader = new LazyLoader <NormalPayRoleBill>();
 }
Exemple #35
0
 internal PostponeRefundBill(decimal applyformId)
     : base(applyformId)
 {
     _payBillLoader = new LazyLoader <PostponePayBill>(() => DistributionQueryService.QueryPostponePayBill(ApplyformId));
 }
Exemple #36
0
        public void LazyLoader_Unit_Object_Optimal()
        {
            const String value = "This is a test.";
            Func<String> initializer = () => value;
            LazyLoader<String> target = new LazyLoader<String>(initializer);
            Assert.AreEqual(false, target.IsInitialized);

            String actualValue = target.Object;
            Assert.AreEqual(value, actualValue);
            Assert.AreEqual(true, target.IsInitialized);
        }
        private void InitializeImageLoaders()
        {
            largeImage = new LazyLoader<Bitmap>(() => CommandResourceLoader.LoadCommandBitmap(Identifier, "LargeImage") ?? CommandResourceLoader.MissingLarge);
            smallImage = new LazyLoader<Bitmap>(() => CommandResourceLoader.LoadCommandBitmap(Identifier, "SmallImage") ?? CommandResourceLoader.MissingSmall);

            largeHighContrastImage = new LazyLoader<Bitmap>(() => CommandResourceLoader.LoadCommandBitmap(Identifier, "LargeHighContrastImage") ?? largeImage);
            smallHighContrastImage = new LazyLoader<Bitmap>(() => CommandResourceLoader.LoadCommandBitmap(Identifier, "SmallHighContrastImage") ?? smallImage);
        }
Exemple #38
0
        public void LazyLoader_Unit_Load_Optimal()
        {
            const String Value = "This is a test.";
            LazyLoader<String> target = new LazyLoader<String>(() => Value);
            Assert.AreEqual(false, target.IsInitialized);

            target.Load();
            Assert.AreEqual(true, target.IsInitialized);
            Assert.AreEqual(Value, target.Object);
        }
Exemple #39
0
        public void LazyLoader_Unit_Dispose_Optimal()
        {
            Boolean releaseManagedResourcesCalled = false;
            Action releaseManagedResourcesAction = () => releaseManagedResourcesCalled = true;
            Boolean releaseUnmanagedResourcesCalled = false;
            Action releaseUnmanagedResourcesAction = () => releaseUnmanagedResourcesCalled = true;
            Func<Object> initializer = () => new MockDisposableBase(releaseManagedResourcesAction, releaseUnmanagedResourcesAction);
            LazyLoader<Object> target = new LazyLoader<Object>(initializer);
            target.Load();
            Assert.AreEqual(false, releaseManagedResourcesCalled);
            Assert.AreEqual(false, releaseUnmanagedResourcesCalled);

            target.Dispose();
            Assert.AreEqual(true, releaseManagedResourcesCalled);
            Assert.AreEqual(true, releaseUnmanagedResourcesCalled);
            Assert.AreEqual(false, target.IsInitialized);
        }
Exemple #40
0
        public void LazyLoader_Unit_Dispose_NotDisposable()
        {
            LazyLoader<String> target = new LazyLoader<String>(() => "This is a test.");
            target.Load();

            target.Dispose();
            Assert.AreEqual(false, target.IsInitialized);
        }
 static StringHelper()
 {
     _stripSingleLineFeeds = new LazyLoader<Regex>(() => new Regex(@"(?<=\S)\r?\n(?=\S)"));
     _stripSpaces = new LazyLoader<Regex>(() => new Regex(@"[ \t]*\r?\n[ \t]*"));
 }
        public ContentEditor(IMainFrameWindow mainFrameWindow, Control editorContainer, IBlogPostEditingSite postEditingSite, IInternetSecurityManager internetSecurityManager, BlogPostHtmlEditorControl.TemplateStrategy templateStrategy, int dlControlFlags)
        {
            // create a docked panel to host the editor
            Panel panel = new Panel();
            panel.Dock = DockStyle.Fill;

            if (!BidiHelper.IsRightToLeft)
                panel.DockPadding.Right = 0;
            else
                panel.DockPadding.Left = 0;

            editorContainer.Controls.Add(panel);
            panel.Resize += new EventHandler(panel_Resize);
            if (BidiHelper.IsRightToLeft)
                editorContainer.RightToLeft = RightToLeft.Yes;

            // save references
            _mainFrameWindow = mainFrameWindow;
            _editorContainer = panel;
            _postEditingSite = postEditingSite;

            _commandManager = new CommandManager();

            _userPreferencesMonitor = new UserPreferencesMonitor();

            // To be high-contrast-aware we need to respond to changes in the high contrast mode
            // by invalidating commands, forcing the ribbon to ask us for new high contrast images.
            _userPreferencesMonitor.AccessibilityUserPreferencesChanged +=
                new EventHandler(delegate (object sender, EventArgs args)
                                     {
                                         _commandManager.InvalidateAllImages();
                                     });

            _imageDecoratorsManager = new LazyLoader<ImageDecoratorsManager>(() => new ImageDecoratorsManager(components, CommandManager, GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ImageBorderInherit)));
            _emoticonsManager = new EmoticonsManager(this, this);

            // initialize commands
            InitializeCommands();

            // initialize normal editor
            InitializeNormalEditor(postEditingSite, internetSecurityManager, templateStrategy, dlControlFlags);

            // initialize source editor
            if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.SourceEditor))
                InitializeSourceEditor();

            InitializeViewCommands();

            // initialize custom content
            InitializeContentSources();

            // bring main editor panel to front (this must be here for the sidebar to work!!!!)
            panel.BringToFront();
        }
Exemple #43
0
 internal Refundment(Guid id) : base(id)
 {
     _paymentLoader = new LazyLoader <Payment>(() => DistributionQueryService.QueryPayment(TradeNo));
 }
Exemple #44
0
 public void LazyLoaderNonValueTypeTest()
 {
     LazyLoader<string> target = new LazyLoader<string>(() => new string(new[] { 'a', 'b', 'c' }));
     Assert.AreEqual("abc", (string)target);
 }
Exemple #45
0
 private void initLazyLoaders()
 {
     _applyformLoader  = new LazyLoader <RefundOrScrapApplyform>(() => ApplyformQueryService.QueryRefundOrScrapApplyform(AssociateApplyformId));
     _refundBillLoader = new LazyLoader <NormalRefundBill>(() => DistributionQueryService.QueryNormalRefundBill(AssociateApplyformId));
 }
Exemple #46
0
 public void LazyLoaderValueTypeTest()
 {
     LazyLoader<int> target = new LazyLoader<int>(() => 1);
     Assert.AreEqual(1, (int)target);
 }