public async Task TestListVMRunCommands() { string location = DefaultLocation.Replace(" ", ""); string documentId = "RunPowerShellScript"; // Verify the List of commands var runCommandList = VirtualMachineRunCommandsOperations.ListAsync(location); var runCommandListResponse = await runCommandList.ToEnumerableAsync(); Assert.NotNull(runCommandListResponse); Assert.True(runCommandListResponse.Count() > 0, "ListRunCommands should return at least 1 command"); RunCommandDocumentBase documentBase = runCommandListResponse.FirstOrDefault(x => string.Equals(x.Id, documentId)); Assert.NotNull(documentBase); // Verify Get a specific RunCommand RunCommandDocument document = await VirtualMachineRunCommandsOperations.GetAsync(location, documentId); Assert.NotNull(document); Assert.NotNull(document.Script); Assert.True(document.Script.Count > 0, "Script should contain at least one command."); Assert.NotNull(document.Parameters); Assert.True(document.Parameters.Count == 2, "Script should have 2 parameters."); }
public ServiceAppSettings(Dictionary <string, string> cStrings, Dictionary <string, double> intervals, OpenCageData openCageData, OpenWeatherData openWeatherData, DefaultLocation defaultLocation) { ConnectionStrings = cStrings; Intervals = intervals; OpenCageData = openCageData; OpenWeatherData = openWeatherData; DefaultLocation = defaultLocation; }
public async Task TestListVMSizes() { string location = DefaultLocation.Replace(" ", ""); var virtualMachineSizeListResponse = await(VirtualMachineSizesOperations.ListAsync(location)).ToEnumerableAsync(); Helpers.ValidateVirtualMachineSizeListResponse(virtualMachineSizeListResponse); }
/// <summary> /// Extension method for extracting defaults and apikeys from iconfiguration instance /// </summary> /// <param name="config"></param> /// <returns></returns> public static ServiceAppSettings ExtractWeatherSettings(this IConfiguration config) { Dictionary <string, string> cStrings = config.GetSection("ConnectionStrings").Get <Dictionary <string, string> >(); Dictionary <string, double> intervals = config.GetSection("DefaultIntervals").Get <Dictionary <string, double> >(); OpenCageData openCageData = config.GetSection("OpenCageData").Get <OpenCageData>(); OpenWeatherData openWeatherData = config.GetSection("OpenWeatherData").Get <OpenWeatherData>(); DefaultLocation defaultLocation = config.GetSection("DefaultLocation").Get <DefaultLocation>(); return(new ServiceAppSettings(cStrings, intervals, openCageData, openWeatherData, defaultLocation)); }
/// <summary> /// Returns true if Team instances are equal /// </summary> /// <param name="other">Instance of Team to be compared</param> /// <returns>Boolean</returns> public bool Equals(Team other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Uuid == other.Uuid || Uuid != null && Uuid.Equals(other.Uuid) ) && ( Code == other.Code || Code != null && Code.Equals(other.Code) ) && ( Status == other.Status || Status != null && Status.Equals(other.Status) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( DefaultLocation == other.DefaultLocation || DefaultLocation != null && DefaultLocation.Equals(other.DefaultLocation) ) && ( CurrentLocation == other.CurrentLocation || CurrentLocation != null && CurrentLocation.Equals(other.CurrentLocation) ) && ( Members == other.Members || Members != null && Members.SequenceEqual(other.Members) )); }
private void SetPosition(DefaultLocation option) { int marginX = 150; int marginY = 20; var workingArea = System.Windows.SystemParameters.WorkArea; switch (option) { case DefaultLocation.Random: this.Left = rnd.Next(marginX, (int)workingArea.Width - marginX - (int)NotificationBody.Width); this.Top = rnd.Next(marginY, (int)workingArea.Height - marginY - (int)NotificationBody.Height); break; case DefaultLocation.RandomCorner: var enumValues = Enum.GetValues(typeof(DefaultLocation)) .Cast <DefaultLocation>() .Where(w => w != DefaultLocation.Random) .ToList(); var randomEnum = enumValues[rnd.Next(0, enumValues.Count)]; this.SetPosition(randomEnum); break; case DefaultLocation.UpperLeft: this.Left = marginX / 2 - (int)NotificationBody.Width; this.Top = 0; break; case DefaultLocation.UpperRight: this.Left = (int)workingArea.Width - marginX / 2 - (int)NotificationBody.Width; this.Top = 0; break; case DefaultLocation.LowerLeft: this.Left = marginX / 2 - (int)NotificationBody.Width; this.Top = (int)workingArea.Height - (int)NotificationBody.Height; break; case DefaultLocation.LowerRight: default: this.Left = (int)workingArea.Width - marginX / 2 - (int)NotificationBody.Width; this.Top = (int)workingArea.Height - (int)NotificationBody.Height; break; } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Uuid != null) { hashCode = hashCode * 59 + Uuid.GetHashCode(); } if (Code != null) { hashCode = hashCode * 59 + Code.GetHashCode(); } if (Status != null) { hashCode = hashCode * 59 + Status.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (DefaultLocation != null) { hashCode = hashCode * 59 + DefaultLocation.GetHashCode(); } if (CurrentLocation != null) { hashCode = hashCode * 59 + CurrentLocation.GetHashCode(); } if (Members != null) { hashCode = hashCode * 59 + Members.GetHashCode(); } return(hashCode); } }
private async Task <bool> RestoreFileToDisk(Node node, string destinationPath) { var success = false; try { var newFile = BackupIOFactory.GetBackupFile(destinationPath); var tempFilePath = await DefaultLocation.GetFile(node.Hash); var restoredFile = new FileInfo(newFile.FullName); using (var inStream = File.OpenRead(tempFilePath)) using (var outStream = newFile.Create()) { if (inStream == null) { return(false); } inStream.CopyTo(outStream); } restoredFile.CreationTime = node.CreationTime; restoredFile.LastWriteTime = node.ModifiedTime; restoredFile.Attributes = node.FileAttributes; restoredFile.IsReadOnly = node.ReadOnly; using (var verifyStream = newFile.OpenRead()) { var verifyHash = Hasher.GetFileHash(verifyStream); success = verifyHash.SequenceEqual(node.Hash); } } catch (Exception ex) { return(false); } return(success); }
internal static void RemoveDefaultLocation(DefaultLocation dl, P1Context DB) { DB.DefaultLocations.Remove(dl); DB.SaveChanges(); }
internal static void UpdateDefaultLocation(DefaultLocation dl, P1Context DB) { DB.DefaultLocations.Update(dl); DB.SaveChanges(); }
internal static void AddDefaultLocation(DefaultLocation dl, P1Context DB) { DB.DefaultLocations.Add(dl); DB.SaveChanges(); }
private SourcePoint GetInsertionPoint(TypeDeclaration activeType, LanguageElementType elementType, RelativeLocation relativeLocation, DefaultLocation defaultLocation) { LanguageElementType[] elementTypes; if (elementType == LanguageElementType.Variable) { elementTypes = new LanguageElementType[2]; elementTypes[0] = LanguageElementType.Variable; elementTypes[1] = LanguageElementType.InitializedVariable; } else { elementTypes = new LanguageElementType[1]; elementTypes[0] = elementType; } ElementEnumerable elementEnumerable = new ElementEnumerable(activeType, elementTypes); LanguageElement lastElement = null; foreach (LanguageElement element in elementEnumerable) { if (relativeLocation == RelativeLocation.Before) return element.GetFullBlockCutRange().Top; else // RelativeLocation.After... lastElement = element; } if (lastElement != null) return lastElement.GetFullBlockCutRange().Bottom; if (defaultLocation == DefaultLocation.Top) return activeType.BlockCodeRange.Top; else // Bottom... return activeType.BlockCodeRange.Bottom; }