The "identity" variable from my snippet is a reference of type CustomizationIdentitySettings. Not shown in the snippet,
but I got it from the "identity" property of a CustomizationSpec:
which I turn read via CustomizationSpecManager, just as you do.
If you look up CustomizationIdentitySettings:
you'll see it is an abstract type for one of three concrete types. So my snippet is testing if the object I have
is actually of concrete type "CustomizationSysprep", and if it is casting the reference to that type. The code doesn't
create that object, it's already there, the code just needs to refer to that object using the correct concrete type.
The code then creates an object of either type CustomizationFixedName or CustomizationVirtualMachineName (both
of which inherit from abstract type CustomizationName) and adds it to the CustomizationUserData object that is
already attached to the CustomizationSysprep.
All these "attachments" are references, so my original CustomizationSpec still refers to my CustomizationSysprep, which
still refers to the same CustomizationUserData, which now refers to this new object I attached to it. That CustomizationSpec
can now be fed back into clone.
I don't have a .NET setup, but I'd imagine it would look something like:
CustomizationSysrep winIdentity = (CustomizationSysprep) mySpec.Customization.Identity; CustomizationFixedName fname = new CustomizationFixedName(); fname.Name = myHostName; winIdentity.UserData.ComputerName = fname;