Exemplo n.º 1
0
        protected override void ProcessRecord()
        {
            // must use this to support processing record remotely.
            if (!string.IsNullOrEmpty(Remote))
            {
                ProcessRecordViaRest();
                return;
            }

            IVMStateEditor editor = PluginLoader.GetInterface(AlternateInterface) ?? Task <IVMStateEditor> .Factory.StartNew(() =>
            {
                PluginLoader.ScanForPlugins();
                return(PluginLoader.GetInterface(AlternateInterface));
            }).Result;

            if (editor == null)
            {
                ThrowTerminatingError(new ErrorRecord(new FileNotFoundException(String.Format("Unable to load the assembly containing a IVMStateEditor named '{0}'.", AlternateInterface)), "Interface failed to load.", ErrorCategory.InvalidArgument, null));
                return;
            }

            WriteObject(
                ParameterSetName.Equals("User", StringComparison.InvariantCultureIgnoreCase)
                            ? editor.WriteUserRegistry(VHD, User, DataPath, Data, DataType)
                            : editor.WriteMachineRegistry(VHD, DataPath, Data, DataType)
                );
        }
Exemplo n.º 2
0
        protected override void ProcessRecord()
        {
            // must use this to support processing record remotely.
            if (!string.IsNullOrEmpty(Remote))
            {
                ProcessRecordViaRest();
                return;
            }

            IVMStateEditor IF = PluginLoader.GetInterface(AlternateInterface) ?? Task <IVMStateEditor> .Factory.StartNew(() =>
            {
                PluginLoader.ScanForPlugins();
                return(PluginLoader.GetInterface(AlternateInterface));
            }).Result;

            if (IF == null)
            {
                ThrowTerminatingError(new ErrorRecord(new FileNotFoundException(String.Format("Unable to load the assembly containing a IVMStateEditor named '{0}'.", AlternateInterface)), "Interface failed to load.", ErrorCategory.InvalidArgument, null));
                return;
            }

            if (!IF.UnmountVHD(VHD))
            {
                WriteWarning(String.Format("Unable to unmount VHD: '{0}'.", VHD));
            }
        }
Exemplo n.º 3
0
        protected override void ProcessRecord()
        {
            // must use this to support processing record remotely.
            if (Remote)
            {
                ProcessRecordViaRest();
                return;
            }

            IVMStateEditor IF = PluginLoader.GetInterface(AlternateInterface) ??
                                Task <IVMStateEditor> .Factory.StartNew(() =>
            {
                PluginLoader.ScanForPlugins();
                return(PluginLoader.GetInterface(AlternateInterface));
            }).Result;

            if (IF == null)
            {
                ThrowTerminatingError(
                    new ErrorRecord(
                        new FileNotFoundException(
                            String.Format("Unable to load the assembly containing a IVMStateEditor named '{0}'.",
                                          AlternateInterface)), "Interface failed to load.",
                        ErrorCategory.InvalidArgument, null));
                return;
            }

            bool status;
            var  results = IF.MountVHD(out status, VHD);

            WriteObject(new
            {
                Status = status,
                Drives = results
            });
        }