private string FormatDiskValueText(IStorageResource resourceData, string diskLabel) { if (displayDiskCapacity && resourceData.TryCalcRequiredDiskCapacity(out ulong capacity)) { return($"{diskLabel} ({Util.DiskSizeString(capacity)})"); } return(diskLabel); }
private string FormatDiskValueText(IStorageResource resourceData, string disklabel) { if (displayDiskCapacity) { return(string.Format("{0} ({1})", disklabel, Util.DiskSizeString(resourceData.RequiredDiskCapacity))); } return(disklabel); }
private DataGridViewComboBoxCell FillGridComboBox(object xenRef, List <object> targetRefs, IStorageResource resource, ref List <ToStringWrapper <SR> > commonSRs) { var cb = new DataGridViewComboBoxCell { FlatStyle = FlatStyle.Flat }; foreach (var pbd in TargetConnection.Cache.PBDs) { if (pbd.SR == null) { continue; } var sr = TargetConnection.Resolve(pbd.SR); if (sr == null || sr.IsDetached) { continue; } if ((sr.content_type.ToLower() == "iso" || sr.type.ToLower() == "iso") && !resource.SRTypeInvalid) { continue; } if (sr.content_type.ToLower() != "iso" && resource.SRTypeInvalid) { continue; } bool srOnHost = pbd.host != null && pbd.host.Equals(xenRef); if ((sr.shared || srOnHost) && (ulong)sr.FreeSpace > resource.RequiredDiskCapacity && SrIsSuitable(sr)) { var count = (from ToStringWrapper <SR> existingItem in cb.Items where existingItem.item.opaque_ref == sr.opaque_ref select existingItem).Count(); if (count > 0) { continue; //iterating through pbds } var newItem = new ToStringWrapper <SR>(sr, GetSRDropDownItemDisplayString); cb.Items.Add(newItem); if (SR.IsDefaultSr(sr)) { cb.Value = newItem; } //store items to populate the m_comboBoxSr //note that at this point the m_totalSpaceRequired is not the final value yet, //but we can add the check to get a smaller list if ((sr.shared || (targetRefs.Count == 1 && srOnHost && targetRefs[0].Equals(xenRef)))) { var num = (from ToStringWrapper <SR> existingItem in commonSRs where existingItem.item.opaque_ref == sr.opaque_ref select existingItem).Count(); if (num <= 0) { commonSRs.Add(newItem); } } } } return(cb); }
private DataGridViewComboBoxCell FillGridComboBox(object xenRef, List <object> targetRefs, IStorageResource resource, ref List <ToStringWrapper <SR> > commonSRs) { var cb = new DataGridViewComboBoxCell { FlatStyle = FlatStyle.Flat }; foreach (var pbd in TargetConnection.Cache.PBDs) { if (pbd.SR == null) { continue; } var sr = TargetConnection.Resolve(pbd.SR); if (sr == null || sr.IsDetached() || !sr.Show(XenAdminConfigManager.Provider.ShowHiddenVMs)) { continue; } if ((sr.content_type.ToLower() == "iso" || sr.type.ToLower() == "iso") && !resource.SRTypeInvalid) { continue; } if (sr.content_type.ToLower() != "iso" && resource.SRTypeInvalid) { continue; } bool srOnHost = pbd.host != null && pbd.host.Equals(xenRef); if ((sr.shared || srOnHost) && (!IsExtraSpaceNeeded(resource.SR, sr) || resource.TryCalcRequiredDiskCapacity(out ulong capacity) && (ulong)sr.FreeSpace() > capacity && SrsAreSuitable(resource.SR, sr))) { var count = (from ToStringWrapper <SR> existingItem in cb.Items where existingItem.item.opaque_ref == sr.opaque_ref select existingItem).Count(); if (count > 0) { continue; //iterating through pbds } var newItem = new ToStringWrapper <SR>(sr, GetSRDropDownItemDisplayString); cb.Items.Add(newItem); if (SR.IsDefaultSr(sr)) { cb.Value = newItem; } //store items to populate the m_comboBoxSr if ((sr.shared || (targetRefs.Count == 1 && srOnHost && targetRefs[0].Equals(xenRef)))) { var num = (from ToStringWrapper <SR> existingItem in commonSRs where existingItem.item.opaque_ref == sr.opaque_ref select existingItem).Count(); if (num <= 0) { commonSRs.Add(newItem); } } } } return(cb); }
public StorageScope(IStorageResource scope) { Token = new TransactionToken(scope); TransactionScope = this.StartTransaction(); }
public void Setup() { Resource = Mock.Of <IStorageResource>(); }
public TransactionToken(IStorageResource scope) { Scope = scope; Scope.TransactionLevel++; Debug.WriteLine($"[TransactionLevel]: {Scope.TransactionLevel}"); }
private string FormatDiskValueText(IStorageResource resourceData, string disklabel) { if(displayDiskCapacity) return string.Format("{0} ({1})", disklabel, Util.DiskSizeString(resourceData.RequiredDiskCapacity)); return disklabel; }
private DataGridViewComboBoxCell FillGridComboBox(object xenRef, List<object> targetRefs, IStorageResource resource, ref List<ToStringWrapper<SR>> commonSRs) { var cb = new DataGridViewComboBoxCell { FlatStyle = FlatStyle.Flat }; foreach (var pbd in TargetConnection.Cache.PBDs) { if (pbd.SR == null) continue; var sr = TargetConnection.Resolve(pbd.SR); if (sr == null) continue; if ((sr.content_type.ToLower() == "iso" || sr.type.ToLower() == "iso") && !resource.SRTypeInvalid) continue; if (sr.content_type.ToLower() != "iso" && resource.SRTypeInvalid) continue; bool srOnHost = pbd.host != null && pbd.host.Equals(xenRef); if ((sr.shared || srOnHost) && (ulong)sr.FreeSpace > resource.RequiredDiskCapacity && SrIsSuitable(sr)) { var count = (from ToStringWrapper<SR> existingItem in cb.Items where existingItem.item.opaque_ref == sr.opaque_ref select existingItem).Count(); if (count > 0) continue; //iterating through pbds var newItem = new ToStringWrapper<SR>(sr, GetSRDropDownItemDisplayString); cb.Items.Add(newItem); if (SR.IsDefaultSr(sr)) cb.Value = newItem; //store items to populate the m_comboBoxSr //note that at this point the m_totalSpaceRequired is not the final value yet, //but we can add the check to get a smaller list if ((sr.shared || (targetRefs.Count == 1 && srOnHost && targetRefs[0].Equals(xenRef)))) { var num = (from ToStringWrapper<SR> existingItem in commonSRs where existingItem.item.opaque_ref == sr.opaque_ref select existingItem).Count(); if (num <= 0) commonSRs.Add(newItem); } } } return cb; }
public static void UseSybase(this IStorageResource storage) => storage.Use(StorageType.Sybase);
public static void UsePostgres(this IStorageResource storage) => storage.Use(StorageType.Postgres);