private bool AffinityGroupVerify(AffinityGroupContext affContext, string name, string label, string location, string description) { bool result = true; Console.WriteLine("AffinityGroup: Name - {0}, Location - {1}, Label - {2}, Description - {3}", affContext.Name, affContext.Location, affContext.Label, affContext.Description); try { Assert.AreEqual(affContext.Name, name, "Error: Affinity Name is not equal!"); Assert.AreEqual(affContext.Label, label, "Error: Affinity Label is not equal!"); Assert.AreEqual(affContext.Location, location, "Error: Affinity Location is not equal!"); Assert.AreEqual(affContext.Description, description, "Error: Affinity Description is not equal!"); } catch (Exception e) { Console.WriteLine(e.ToString()); result = false; } return result; }
protected override void ProcessRecord() { try { Func<AffinityGroup, AffinityGroupContext> func = null; base.ProcessRecord(); Operation operation = null; IEnumerable<AffinityGroup> affinityGroupProcess = this.GetAffinityGroupProcess(out operation); if (affinityGroupProcess != null) { IEnumerable<AffinityGroup> affinityGroups = affinityGroupProcess; if (func == null) { func = (AffinityGroup affinityGroup) => { string str; IEnumerable<AffinityGroupContext.Service> services; IEnumerable<AffinityGroupContext.Service> services1; AffinityGroupContext affinityGroupContext = new AffinityGroupContext(); affinityGroupContext.set_OperationId(operation.OperationTrackingId); affinityGroupContext.set_OperationDescription(this.CommandRuntime.ToString()); affinityGroupContext.set_OperationStatus(operation.Status); affinityGroupContext.Name = affinityGroup.Name; AffinityGroupContext affinityGroupContext1 = affinityGroupContext; if (string.IsNullOrEmpty(affinityGroup.Label)) { str = null; } else { str = ServiceManagementHelper.DecodeFromBase64String(affinityGroup.Label); } affinityGroupContext1.Label = str; affinityGroupContext.Description = affinityGroup.Description; affinityGroupContext.Location = affinityGroup.Location; AffinityGroupContext affinityGroupContext2 = affinityGroupContext; if (affinityGroup.HostedServices != null) { HostedServiceList hostedServices = affinityGroup.HostedServices; services = hostedServices.Select<HostedService, AffinityGroupContext.Service>((HostedService p) => { AffinityGroupContext.Service service = new AffinityGroupContext.Service(); service.Url = p.Url; service.ServiceName = p.ServiceName; return service; }); } else { services = new AffinityGroupContext.Service[0]; } affinityGroupContext2.HostedServices = services; AffinityGroupContext affinityGroupContext3 = affinityGroupContext; if (affinityGroup.StorageServices != null) { StorageServiceList storageServices = affinityGroup.StorageServices; services1 = storageServices.Select<StorageService, AffinityGroupContext.Service>((StorageService p) => { AffinityGroupContext.Service service = new AffinityGroupContext.Service(); service.Url = p.Url; service.ServiceName = p.ServiceName; return service; }); } else { services1 = new AffinityGroupContext.Service[0]; } affinityGroupContext3.StorageServices = services1; return affinityGroupContext; } ; } IEnumerable<AffinityGroupContext> affinityGroupContexts = affinityGroups.Select<AffinityGroup, AffinityGroupContext>(func); base.WriteObject(affinityGroupContexts, true); } } catch (Exception exception1) { Exception exception = exception1; base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null)); } }