当前位置: 首页>>代码示例>>C#>>正文


C# WeakReference.Get方法代码示例

本文整理汇总了C#中System.WeakReference.Get方法的典型用法代码示例。如果您正苦于以下问题:C# WeakReference.Get方法的具体用法?C# WeakReference.Get怎么用?C# WeakReference.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.WeakReference的用法示例。


在下文中一共展示了WeakReference.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _segmentBarButton = new UIBarButtonItem(_viewSegment);
            _segmentBarButton.Width = View.Frame.Width - 10f;
            ToolbarItems = new [] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _segmentBarButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) };
            var vm = (MyIssuesViewModel)ViewModel;
            var weakVm = new WeakReference<MyIssuesViewModel>(vm);

            vm.Bind(x => x.SelectedFilter).Subscribe(x =>
            {
                var goodVm = weakVm.Get();

                if (x == 2 && goodVm != null)
                {
                    var filter = new CodeHub.iOS.Views.Filters.MyIssuesFilterViewController(goodVm.Issues);
                    var nav = new UINavigationController(filter);
                    PresentViewController(nav, true, null);
                }

                // If there is searching going on. Finish it.
                FinishSearch();
            });

            this.BindCollection(vm.Issues, CreateElement);

            OnActivation(d =>
            {
                d(vm.Bind(x => x.SelectedFilter, true).Subscribe(x => _viewSegment.SelectedSegment = (nint)x));
                d(_viewSegment.GetChangedObservable().Subscribe(x => vm.SelectedFilter = x));
            });
        }
开发者ID:RaineriOS,项目名称:CodeHub,代码行数:33,代码来源:MyIssuesView.cs

示例2: CreateElement

 private static Element CreateElement(SourceTreeViewModel.SourceModel x, WeakReference<SourceTreeViewModel> viewModel)
 {
     if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase))
     {
         var e = new StringElement(x.Name, AtlassianIcon.Devtoolsfolderclosed.ToImage());
         e.Clicked.Select(_ => x).BindCommand(viewModel.Get()?.GoToSourceCommand);
         return e;
     }
     if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase))
     {
         var e = new StringElement(x.Name, AtlassianIcon.Devtoolsfile.ToImage());
         e.Clicked.Select(_ => x).BindCommand(viewModel.Get()?.GoToSourceCommand);
         return e;
     }
     return new StringElement(x.Name) { Image = AtlassianIcon.Devtoolsfilebinary.ToImage() };
 }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:16,代码来源:SourceTreeView.cs

示例3: CreateElement

 protected IssueElement CreateElement(IssueModel x)
 {
     var weakVm = new WeakReference<IBaseIssuesViewModel>(ViewModel);
     var isPullRequest = x.PullRequest != null && !(string.IsNullOrEmpty(x.PullRequest.HtmlUrl));
     var assigned = x.Assignee != null ? x.Assignee.Login : "unassigned";
     var kind = isPullRequest ? "Pull" : "Issue";
     var commentString = x.Comments == 1 ? "1 comment" : x.Comments + " comments";
     var el = new IssueElement(x.Number.ToString(), x.Title, assigned, x.State, commentString, kind, x.UpdatedAt);
     el.Tapped += () => weakVm.Get()?.GoToIssueCommand.Execute(x);
     return el;
 }
开发者ID:GitWatcher,项目名称:CodeHub,代码行数:11,代码来源:BaseIssuesView.cs

示例4: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var vm = (TeamsViewModel) ViewModel;
            var weakVm = new WeakReference<TeamsViewModel>(vm);
            this.BindCollection(vm.Teams, x => {
                var e = new StringElement(x.Name);
                e.Clicked.Subscribe(_ => weakVm.Get()?.GoToTeamCommand.Execute(x));
                return e;
            });
        }
开发者ID:RaineriOS,项目名称:CodeHub,代码行数:12,代码来源:TeamsViewController.cs

示例5: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var vm = (ChangesetBranchesViewModel) ViewModel;
            var weakVm = new WeakReference<ChangesetBranchesViewModel>(vm);
            BindCollection(vm.Branches, x => {
                var e = new StringElement(x.Name);
                e.Clicked.Subscribe(_ => weakVm.Get()?.GoToBranchCommand.Execute(x));
                return e;
            });
        }
开发者ID:RaineriOS,项目名称:CodeHub,代码行数:12,代码来源:ChangesetBranchesView.cs

示例6: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var vm = (BaseUserCollectionViewModel)ViewModel;
            var weakVm = new WeakReference<BaseUserCollectionViewModel>(vm);
            BindCollection(vm.Users, x =>
            {
                var e = new UserElement(x.Username, string.Empty, string.Empty, new Avatar(x.Avatar));
                e.Clicked.Subscribe(_ => weakVm.Get()?.GoToUserCommand.Execute(x));
                return e;
            });
        }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:13,代码来源:BaseUserCollectionView.cs

示例7: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

			var vm = (GroupsViewModel) ViewModel;
            var weakVm = new WeakReference<GroupsViewModel>(vm);
			BindCollection(vm.Organizations, x =>
			{
                var e = new StringElement(x.Name);
                e.Clicked.Select(_ => x).BindCommand(weakVm.Get()?.GoToGroupCommand);
				return e;
			});
        }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:13,代码来源:GroupsView.cs

示例8: Show

 public static GistCreateView Show(UIViewController parent)
 {
     var ctrl = new GistCreateView();
     var weakVm = new WeakReference<GistCreateViewModel>(ctrl.ViewModel);
     ctrl.ViewModel.SaveCommand.Subscribe(_ => parent.DismissViewController(true, null));
     ctrl.NavigationItem.LeftBarButtonItem = new UIBarButtonItem { Image = Images.Buttons.CancelButton };
     ctrl.NavigationItem.LeftBarButtonItem.GetClickedObservable().Subscribe(_ => {
         weakVm.Get()?.CancelCommand.Execute(null);
         parent.DismissViewController(true, null);
     });
     parent.PresentViewController(new ThemedNavigationController(ctrl), true, null);
     return ctrl;
 }
开发者ID:GitWatcher,项目名称:CodeHub,代码行数:13,代码来源:GistCreateView.cs

示例9: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var vm = (OrganizationsViewModel) ViewModel;
            var weakVm = new WeakReference<OrganizationsViewModel>(vm);
            BindCollection(vm.Organizations, x =>
            {
                var avatar = new GitHubAvatar(x.AvatarUrl);
                var e = new UserElement(x.Login, string.Empty, string.Empty, avatar);
                e.Clicked.Subscribe(_ => weakVm.Get()?.GoToOrganizationCommand.Execute(x));
                return e;
            });
        }
开发者ID:RaineriOS,项目名称:CodeHub,代码行数:14,代码来源:OrganizationsViewController.cs

示例10: ViewWillAppear

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var accountsService = Mvx.Resolve<IAccountsService>();
            var weakVm = new WeakReference<AccountsViewController>(this);
            var accountSection = new Section();
            accountSection.AddAll(accountsService.Select(account =>
            {
                var t = new AccountElement(account, account.Equals(accountsService.ActiveAccount));
                t.Tapped += () => weakVm.Get()?.SelectAccount(account);
                return t;
            }));
            Root.Reset(accountSection);

            SetCancelButton();
        }
开发者ID:RaineriOS,项目名称:CodeHub,代码行数:17,代码来源:AccountsViewController.cs

示例11: MakeCallback

 private static Action<object> MakeCallback(WeakReference<BranchesAndTagsViewModel> weakVm, BranchesAndTagsViewModel.ViewObject viewObject)
 {
     return new Action<object>(_ => weakVm.Get()?.GoToSourceCommand.Execute(viewObject));
 }
开发者ID:RaineriOS,项目名称:CodeHub,代码行数:4,代码来源:BranchesAndTagsView.cs

示例12: SetButtons

 public void SetButtons(List<Button> items)
 {
     foreach (var b in _buttons.Zip(items, (x, y) => new { Button = x, Data = y }))
     {
         b.Button.Caption = b.Data.Caption;
         b.Button.Text = b.Data.Text;
         b.Button.UserInteractionEnabled = true;
         var weakRef = new WeakReference<Button>(b.Data);
         b.Button.Touch = () => weakRef.Get()?.Clicked.OnNext(Unit.Default);
     }
 }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:11,代码来源:SplitButtonElement.cs

示例13: CreateAttributedStringFromBlocks

        private static Tuple<NSMutableAttributedString,List<NewsCellView.Link>> CreateAttributedStringFromBlocks(UIFont font, UIColor primaryColor, IEnumerable<TextBlock> blocks)
        {
            var attributedString = new NSMutableAttributedString();
            var links = new List<NewsCellView.Link>();

            nint lengthCounter = 0;
            int i = 0;

            foreach (var b in blocks)
            {
                UIColor color = null;
                if (b.Tapped != null)
                    color = LinkColor;

                color = color ?? primaryColor; 

                var ctFont = new CoreText.CTFont(font.Name, font.PointSize);
                var str = new NSAttributedString(b.Value, new CoreText.CTStringAttributes() { ForegroundColor = color.CGColor, Font = ctFont });
                attributedString.Append(str);
                var strLength = str.Length;

                if (b.Tapped != null)
                {
                    var weakTapped = new WeakReference<Action>(b.Tapped);
                    links.Add(new NewsCellView.Link { Range = new NSRange(lengthCounter, strLength), Callback = () => weakTapped.Get()?.Invoke(), Id = i++ });
                }

                lengthCounter += strLength;
            }

            return new Tuple<NSMutableAttributedString, List<NewsCellView.Link>>(attributedString, links);
        }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:32,代码来源:NewsFeedElement.cs

示例14: MakeCallback

 private static Action<object> MakeCallback(WeakReference<GistViewModel> weakVm, GistFileModel model)
 {
     return new Action<object>(_ => weakVm.Get()?.GoToFileSourceCommand.Execute(model));
 }
开发者ID:GitWatcher,项目名称:CodeHub,代码行数:4,代码来源:GistView.cs

示例15: MakeCallback

 private static Action MakeCallback(WeakReference<CommitsViewModel> weakVm, CommitModel model)
 {
     return new Action(() => weakVm.Get()?.GoToChangesetCommand.Execute(model));
 }
开发者ID:GitWatcher,项目名称:CodeHub,代码行数:4,代码来源:CommitsView.cs


注:本文中的System.WeakReference.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。