public void TestBufferedServer() { m_noAdmitCount = 0; m_admitCount = 0; m_model = new Model(); ((Model)m_model).RandomServer = new Randoms.RandomServer(54321, 100); ItemSource factory = CreatePatientGenerator("Patient_", 25, 5.0, 3.0); NormalDistribution dist = new NormalDistribution(m_model, "SvcDistribution", Guid.NewGuid(), 15.0, 3.0); IPeriodicity per = new Periodicity(dist, Periodicity.Units.Minutes); IResourceManager rscPool = new SelfManagingResource(m_model, "RscMgr", Guid.NewGuid(), 5.0, 5.0, false, true, true); BufferedServer bs = new BufferedServer(m_model, "RscSvr", Guid.NewGuid(), per, new IResourceRequest[] { new SimpleResourceRequest(1.0, rscPool) }, true, false); bs.PlaceInService(); ConnectorFactory.Connect(factory.Output, bs.Input); factory.Output.PortDataPresented += new PortDataEvent(FactoryOutput_PortDataPresented); bs.PreQueue.LevelChangedEvent += new QueueLevelChangeEvent(Queue_LevelChangedEvent); bs.ServiceBeginning += new ServiceEvent(Server_ServiceBeginning); bs.ServiceCompleted += new ServiceEvent(Server_ServiceCompleted); m_model.Start(); }
/// <summary> /// Removes all views that are not longer part of the ItemSource to avoid duplicated views. /// </summary> void DisposeOldElements() { List <Xamarin.Forms.View> removableItems; if (ItemSource == null) { //Remove all items if the new ItemSource is empty. removableItems = ContentGrid.Children.ToList(); Debug.WriteLine("Remove all items from gallerie."); } else { //Only remove items that are no longer part of the new ItemSource removableItems = ContentGrid.Children.Where(o => !ItemSource.Contains(o.BindingContext)).ToList(); } //Remove items and dispose the handler while (removableItems.Any()) { var view = removableItems.First(); ((TapGestureRecognizer)view.GestureRecognizers[0]).Tapped -= GestureRekognizerOnTapped; ContentGrid.Children.Remove(view); removableItems.RemoveAt(0); } }
public void AddItem() { IDocument doc = documentManagerService.CreateDocument("WarranteeView", null, this); doc.Id = documentManagerService.Documents.Count(); doc.Title = "新增被担保人信息"; var docVM = (WarranteeViewModel)doc.Content; docVM.IsRead = false; var Main = Content.WarranteeItems.SingleOrDefault(x => x.IsMain == true); if (Main != null) { docVM.IsMain = false; } else { docVM.IsMain = true; } doc.Show(); if (docVM.IsChange) { Content.WarranteeItems.Add(docVM.Content); ItemSource.Add(docVM.Content); if (docVM.Content.IsMain) { MainWarrantee = docVM.Content; } } }
/// <summary> /// Adds a tree view item /// </summary> /// <param name="parent">Parent of the item</param> /// <param name="item">The item to be added</param> private void Add(DisplayableTreeViewItem parent, DisplayableTreeViewItem item) { ObservableCollection <DisplayableTreeViewItem> siblings; if (parent == null) { siblings = ItemSource; } else { siblings = parent.Items; parent.IsExpanded = true; } int index = FindIndex(siblings, item); if (index == -1) { index = 0; } if (parent == null) { ItemSource.Insert(index, item); } else { parent.Items.Insert(index, item); } CheckVisibility(); }
private async Task <ScItemsResponse> GetItemByIdWithItemSource(ItemSource itemSource) { var session = SitecoreSSCSessionBuilder.AuthenticatedSessionWithHost(testData.InstanceUrl) .Credentials(testData.Users.Admin) .DefaultLanguage(itemSource.Language) .DefaultDatabase(itemSource.Database) .BuildReadonlySession(); IReadItemsByIdRequest request = null; if (null == itemSource.VersionNumber) { request = this.requestWithItemId; } else { request = ItemSSCRequestBuilder.ReadItemsRequestWithId(testData.Items.ItemWithVersions.Id) .Version(itemSource.VersionNumber.Value) .Build(); } var response = await session.ReadItemAsync(request); return(response); }
public void TestItemSourceDatabaseIsOptional() { var result = new ItemSource(null, "en", 1); Assert.IsNotNull(result); Assert.IsNull(result.Database); }
public PropertyItemViewModel(PropertyItemViewModel p) { ItemSource = p.ItemSource; Parent = p.Parent; _property = p._property.Clone() as PropertyDef; _property.Name = Utils.GetUniqueName(p.Name, ItemSource.Select(x => (x as PropertyItemViewModel).Name)); }
public ScApiSession( ISessionConfig config, IEntitySource entitySource, IScCredentials credentials, IMediaLibrarySettings mediaSettings, ItemSource defaultSource = null) { if (null == config) { throw new ArgumentNullException("ScApiSession.config cannot be null"); } if (entitySource != null) { this.entitySource = entitySource.ShallowCopy(); } this.sessionConfig = config.SessionConfigShallowCopy(); this.requestMerger = new UserRequestMerger(this.sessionConfig, defaultSource, this.entitySource); if (null != credentials) { this.credentials = credentials.CredentialsShallowCopy(); } if (null != mediaSettings) { this.mediaSettings = mediaSettings.MediaSettingsShallowCopy(); } this.cookies = new CookieContainer(); this.handler = new HttpClientHandler(); this.handler.CookieContainer = cookies; this.httpClient = new HttpClient(this.handler); }
private void Delete(IEditable deleteObj) { if (deleteObj is IQuestioner) { ItemSource.Remove(deleteObj as IQuestioner); } }
public Tome Update(UpdateTome cmd, ItemSource baseItem) { Id = cmd.TomeId; Text = cmd.Text; BaseItem = baseItem; return(this); }
public async void TestOverrideVersionAndDbInRequestById() { const string Db = "master"; const string Language = "en"; const int Version = 2; var source = new ItemSource("web", Language, 1); var session = SitecoreSSCSessionBuilder.AuthenticatedSessionWithHost(testData.InstanceUrl) .Credentials(testData.Users.Admin) .DefaultDatabase(source.Database) .DefaultLanguage(source.Language) .BuildReadonlySession(); var request = ItemSSCRequestBuilder.ReadItemsRequestWithId(testData.Items.ItemWithVersions.Id) .Version(Version) .Database(Db) .Build(); var response = await session.ReadItemAsync(request); testData.AssertItemsCount(1, response); var resultItem = response[0]; testData.AssertItemsAreEqual(testData.Items.ItemWithVersions, resultItem); var sourceExpected = new ItemSource(Db, Language, Version); testData.AssertItemSourcesAreEqual(sourceExpected, resultItem.Source); Assert.AreEqual("English version 2 master", resultItem["Title"].RawValue); }
public void TestItemVersionIsOptionalForItemSource() { var result = new ItemSource("core", "da", null); Assert.IsNotNull(result); Assert.IsNull(result.VersionNumber); }
void ExecuteLoadMoreCommand() { Task.Run(() => { Thread.Sleep(1000); if (ItemSource == null) { ItemSource = new List <MailData>(); } foreach (MailData mail in this.repository.MailMessages) { this.currentDate = this.currentDate.AddMinutes(-1 * this.random.Next(5, 240)); ItemSource.Add(new MailData() { SenderName = mail.SenderName, SenderEmail = mail.SenderEmail, Subject = mail.Subject, Body = mail.Body, MailTime = this.currentDate, }); } IsRefreshing = false; }); }
public ISitecoreSSCSession BuildSession() { string optionalMediaRoot = this.OptionalMediaRoot(); string optionalMediaExtension = this.OptionalMediaExtension(); string optionalMediaPrefix = this.OptionalMediaPrefix(); //////// SessionConfig conf = new SessionConfig(this.instanceUrl); var mediaSettings = new MediaLibrarySettings( optionalMediaRoot, optionalMediaExtension, optionalMediaPrefix); var itemSource = new ItemSource( this.itemSourceAccumulator.Database, this.itemSourceAccumulator.Language, this.itemSourceAccumulator.VersionNumber); var entitySource = new EntitySource( this.entitySourceAccumulator.EntityNamespace, this.entitySourceAccumulator.EntityController, this.entitySourceAccumulator.EntityId, this.entitySourceAccumulator.EntityAction); var result = new ScApiSession(conf, entitySource, this.credentials, mediaSettings, itemSource); return(result); }
void UpdateConnectGroups(NetInfo netInfo) { LogCalled(); ConnectGroupsHash = ConnectGroups?.Select(item => item.GetHashCode()).ToArray(); if (ConnectGroupsHash.IsNullorEmpty()) { ConnectGroupsHash = null; } foreach (var node in netInfo.m_nodes) { node.GetMetaData()?.Update(); } NodeConnectGroupsHash = GetNodeConnectGroupsHash(netInfo).ToArray(); if (NodeConnectGroupsHash.IsNullorEmpty()) { NodeConnectGroupsHash = null; } var itemSource = ItemSource.GetOrCreate(typeof(NetInfo.ConnectGroup)); foreach (var connectGroup in GetAllConnectGroups(netInfo)) { itemSource.Add(connectGroup); } }
public ScApiSession( ISessionConfig config, IWebApiCredentials credentials, IMediaLibrarySettings mediaSettings, ItemSource defaultSource = null) { if (null == config) { throw new ArgumentNullException("ScApiSession.config cannot be null"); } this.sessionConfig = config.SessionConfigShallowCopy(); this.requestMerger = new UserRequestMerger(this.sessionConfig, defaultSource); if (null != credentials) { this.credentials = credentials.CredentialsShallowCopy(); } if (null != mediaSettings) { this.mediaSettings = mediaSettings.MediaSettingsShallowCopy(); } this.httpClient = new HttpClient(); }
public void TestDefaultSource() { ItemSource defaultSource = LegacyConstants.DefaultSource(); Assert.AreEqual(defaultSource.Database, "web"); Assert.AreEqual(defaultSource.Language, "en"); }
public CompareItem (ListViewItem item, CompareResult CompareResultTag, ItemSource ItemSourceTag) : base() { Item = item; compareResultTag = CompareResultTag; itemSourceTag = ItemSourceTag; }
public void TestItemSourceLanguageIsOptional() { var result = new ItemSource("master", null, 1); Assert.IsNotNull(result); Assert.IsNull(result.Language); }
public ISitecoreWebApiSession BuildSession() { string optionalWebApiVersion = this.OptionalWebApiVersion(); string optionalMediaRoot = this.OptionalMediaRoot(); string optionalMediaExtension = this.OptionalMediaExtension(); string optionalMediaPrefix = this.OptionalMediaPrefix(); //////// SessionConfig conf = new SessionConfig( this.instanceUrl, this.site, optionalWebApiVersion); var mediaSettings = new MediaLibrarySettings( optionalMediaRoot, optionalMediaExtension, optionalMediaPrefix, this.resizingFlag); var itemSource = new ItemSource( this.itemSourceAccumulator.Database, this.itemSourceAccumulator.Language, this.itemSourceAccumulator.VersionNumber); var result = new ScApiSession(conf, this.credentials, mediaSettings, itemSource); return(result); }
public void TestResourceServer() { m_noAdmitCount = 0; m_admitCount = 0; m_model = new Model(); ((Model)m_model).RandomServer = new Randoms.RandomServer(54321, 100); ItemSource factory = CreatePatientGenerator("Patient_", 25, 5.0, 3.0); Queue queue = new Queue(m_model, "TestQueue", Guid.NewGuid()); ConnectorFactory.Connect(factory.Output, queue.Input); NormalDistribution dist = new NormalDistribution(m_model, "SvcDistribution", Guid.NewGuid(), 15.0, 3.0); IPeriodicity per = new Periodicity(dist, Periodicity.Units.Minutes); ResourceManager rscPool = new ResourceManager(m_model, "RscMgr", Guid.NewGuid()); for (int i = 0; i < 3; i++) { rscPool.Add(new Resource(m_model, "rsc_" + i, Guid.NewGuid(), 1.0, 1.0, true, true, true)); } ResourceServer rs = new ResourceServer(m_model, "RscSvr", Guid.NewGuid(), per, new IResourceRequest[] { new SimpleResourceRequest(1.0, rscPool) }); rs.PlaceInService(); ConnectorFactory.Connect(queue.Output, rs.Input); factory.Output.PortDataPresented += new PortDataEvent(FactoryOutput_PortDataPresented); queue.LevelChangedEvent += new QueueLevelChangeEvent(Queue_LevelChangedEvent); rs.ServiceBeginning += new ServiceEvent(Server_ServiceBeginning); rs.ServiceCompleted += new ServiceEvent(Server_ServiceCompleted); m_model.Start(); }
public Target(IRepositoryService repositoryService, int itemCount) : base(repositoryService) { ItemSource = Substitute.For <IVirtualizingListSource <IIssueListItemViewModelBase> >(); ItemSource.GetCount().Returns(itemCount); ItemSource.PageSize.Returns(100); }
public void TestCustomMediaHook() { SessionConfigPOD sessionConfig = new SessionConfigPOD(); sessionConfig.InstanceUrl = "htTP://CUSTOM.hoST"; sessionConfig.ItemWebApiVersion = "v1"; sessionConfig.Site = "/sitecore/shell"; sessionConfig.MediaLibraryRoot = "/SiteCore/Other Media Library"; sessionConfig.DefaultMediaResourceExtension = "ZIP"; sessionConfig.MediaPrefix = "~/MediaXyZ"; ISessionConfig sessionSettings = sessionConfig; IMediaLibrarySettings mediaSettings = sessionConfig; ItemSource itemSource = LegacyConstants.DefaultSource(); this.builder = new MediaItemUrlBuilder(this.restGrammar, this.webApiGrammar, sessionSettings, mediaSettings, itemSource); var customBuilder = new MediaItemUrlBuilder( this.restGrammar, this.webApiGrammar, sessionSettings, mediaSettings, itemSource); string result = customBuilder.BuildUrlStringForPath("~/mediaXYZ/1.png.ashx", null); string expected = "http://custom.host/~/mediaxyz/1.png.ashx?db=web&la=en"; Assert.AreEqual(expected, result); }
/// <summary> /// Writes the provided value to the Item's <see cref="SourceItem"/> or <see cref="Provider"/>, depending on the value /// of the <see cref="Source"/> property. /// </summary> /// <param name="value">The value to write.</param> /// <returns>A value indicating whether the write operation succeeded.</returns> /// <threadsafety instance="true"/> public virtual bool WriteToSource(object value) { bool result = false; ItemSource source = Source; sourceItemLock.EnterWriteLock(); providerLock.EnterWriteLock(); try { if (source == ItemSource.Item) { result = SourceItem.WriteToSource(value); } else if (source == ItemSource.Provider && Provider is IWriteable) { result = ((IWriteable)Provider).Write(this, value); } } finally { providerLock.ExitWriteLock(); sourceItemLock.ExitWriteLock(); } if (result) { ChangeValue(value); } return(result); }
public override nint GetPresentationCount(UIPageViewController pageViewController) { var count = ItemSource.Count(); return(PageIndicatorEnabled ? (count == 1 ? 0 : count) : 0); }
public override void UpdateItems() { try { ItemSource.UpdateItems(); } catch (Exception e) { SafeElement.LogSafeError(ItemSource, e, "UpdateItems"); } }
public static Tome Create(ItemSource baseItem, string text) { return(new Tome { Text = text, BaseItem = baseItem }); }
/// <summary> /// Invoked internally to add a new object at a specific /// </summary> /// <param name="index">The index in which the item will be added.</param> /// <param name="obj">The object to insert at the index.</param> protected virtual void Add(int index, T obj) { ItemSource.Insert(index, obj); if (!(ItemSource is INotifyCollectionChanged)) { HandleCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, obj, index)); } }
public void AddTab(TabItem tab, int position = 0, bool selectNewPosition = false) { if (selectNewPosition) { _position = position; } ItemSource.Insert(position, tab); }
/// <summary> /// Gives this player a certain amount of a particular type of item /// </summary> /// <param name="itemSource"></param> /// <param name="amount"></param> public void GiveItemsOfType(ItemSource itemSource, int amount) { for (var i = 0; i < amount; i++) { var newItem = Item.Create(this, itemSource); Items.Add(newItem); } }
static string Format (ItemSource s) { switch (s) { case ItemSource.Metadata: return "MD"; case ItemSource.CIL: return "IL"; default: throw new ArgumentException ("Unknown source"); } }
protected override void ProcessRecord() { source = new ItemSource {Name = Name}; //Create source – source should be based on BaseSource if (Item != null) { source.Database = Item.Database.Name; source.Root = Item.Paths.Path; } else { source.Database = Database; source.Root = Root; } source.SkipVersions = SkipVersions.IsPresent; source.Converter.Transforms.Add(new InstallerConfigurationTransform(new BehaviourOptions(InstallMode, MergeMode))); }
private void UpdateLocateCider() { if (G.get().ciderManager.HasCider()) { ciderSource = G.get().ciderManager.GetNearestCiderPos(transform.position); changeState(ThiefState.MOVE_TO_CIDER); } else { changeState(ThiefState.IDLE_WHEN_NO_CIDER); } }
// Use this for initialization void Start () { state = ThiefState.LOCATE_CIDER; ciderSource = null; carryOverheadBehaviour = gameObject.GetComponent<CarryOverheadBehaviour>(); }