AcManager.Pages.Dialogs.ShowroomCreateDialog.ViewModel.Create C# (CSharp) Метод

Create() приватный Метод

private Create ( ) : void
Результат void
            private void Create() {
                if (ResultId == string.Empty) {
                    ResultId = AcStringValues.IdFromName(ResultName);

                    if (ResultId == string.Empty) {
                        for (var i = 1; ; i++) {
                            if (i > 10000) throw new Exception();

                            var candidate = $"generated_showroom_{i}";
                            if (ShowroomsManager.Instance.GetById(candidate) != null) continue;

                            ResultId = candidate;
                            break;
                        }
                    }
                }

                if (ShowroomsManager.Instance.GetById(ResultId) != null) {
                    throw new InformativeException(ToolsStrings.Common_IdIsTaken, ToolsStrings.Common_IdIsTaken_Commentary);
                }

                if (ResultName == string.Empty) {
                    ResultName = AcStringValues.NameFromId(ResultId);
                }

                var location = ShowroomsManager.Instance.Directories.GetLocation(ResultId, true);
                FileUtils.EnsureDirectoryExists(Path.Combine(location, "ui"));

                new IniFile {
                    ["LIGHT"] = {
                        ["LOCK_SUN"] = @"1",
                        ["SUN_DIRECTION"] = @"1,1,0.8"
                    }
                }.Save(Path.Combine(location, "settings.ini"));

                File.WriteAllText(Path.Combine(location, @"ui", @"ui_showroom.json"), new JObject {
                    [@"author"] = SettingsHolder.Sharing.SharingName,
                    [@"name"] = ResultName,
                    [@"tags"] = new JArray {
                        InShadow ? @"in shadow" : @"lighted",
                        @"panorama based"
                    }
                }.ToString());

                using (var unpackedKn5 = new MemoryStream()) {
                    using (var stream = new MemoryStream(BinaryResources.ShowroomPanoramaTemplate))
                    using (var archive = new ZipArchive(stream))
                    using (var entry = archive.GetEntry(@"0").Open()) {
                        entry.CopyTo(unpackedKn5);
                    }

                    unpackedKn5.Position = 0;

                    var kn5 = Kn5.FromStream(unpackedKn5);
                    kn5.SetTexture("0", PanoramaFilename);
                    kn5.Nodes.First(x => x.Name == @"0" && x.NodeClass == Kn5NodeClass.Mesh).CastShadows = InShadow;

                    var material = kn5.Materials.Values.First(x => x.Name == @"0");
                    material.GetPropertyByName("ksAmbient").ValueA = InShadow ? 3f : 1f;
                    material.GetPropertyByName("ksDiffuse").ValueA = InShadow ? 0f : 2f;

                    kn5.Save(Path.Combine(location, ResultId + ".kn5"));
                }
            }
        }
ShowroomCreateDialog.ViewModel