private bool GeneratePerspective() { //Create Perspective var perspective = new PerspectiveItem() { Id = WorkspaceRoot.Id, ParentId = WorkspaceRoot.Parent, EnumerationId = WorkspaceRootItem.Id }; //if (PerspectiveItemExists(perspective.Id)) return true; if (_existingPerspectives.Select(pers => pers.Id).Contains(perspective.Id)) { return(true); } PerspectiveItem perspectiveItemSaved = ExplorerProviderFactory.CreateProvider(ExplorerProviderFactory.Key.Instance).SavePerspectiveItem(perspective); if (perspectiveItemSaved != null) { if (perspectiveItemSaved.HasErrors) { return(false); } return(true); } return(false); }
public PerspectiveItem SavePerspectiveItem(PerspectiveItem perspectiveItem) { IExplorer clt = null; try { clt = CreateClient(); return(clt.SavePerspectiveItem(perspectiveItem)); } finally { CloseClient(clt); } }
/// <summary> /// /// </summary> public static bool Generate() { LogInfo("Generate"); LogInfo("Creating agents"); _explorerAgent = ExplorerAgentFactory.CreateAgent(ExplorerAgentFactory.Key.Instance); _mediaAgent = MediaAgentFactory.CreateMediaAgent(); using (var scope = new TransactionScope(TransactionScopeOption.Required)) { LogInfo("Transaction begin"); try { LogInfo("Creating objects; perspectiveItemRoot, enumerationItemRoot and descriptionItems"); PerspectiveItem perspectiveItemRoot = GetPerspectiveItemRoot(); EnumerationItem enumerationItemRoot = GetEnumerationItemRoot(); IEnumerable <DescriptionItem> descriptionItems = GetDescriptionItems(); LogInfo("Saving enumerationItemRoot and perspectiveItemRoot"); if (SaveEnumerationItem(enumerationItemRoot) && SavePerspectiveItem(perspectiveItemRoot)) { var language = CultureInfo.CurrentCulture.Name; var items = from i in descriptionItems where i.CultureId.Equals(language) select i; LogInfo("Saving descriptionItems for culture {0}", language); if (SaveDescriptionItems(items)) { scope.Complete(); return(LogInfo("Transaction complete")); } } } catch (Exception ex) { return(LogError("Method Generate throws exception;\n" + ex)); } } return(LogError("Generate = false")); }
/// <summary> /// Saves the perspective item. /// </summary> /// <param name="perspectiveItem">The hierarchy.</param> private static bool SavePerspectiveItem(PerspectiveItem perspectiveItem) { if (PerspectiveItemExists(perspectiveItem.Id)) { return(true); } LogInfo("Saving perspectiveItem"); PerspectiveItem perspectiveItemSaved = _explorerAgent.SavePerspectiveItem(perspectiveItem); if (perspectiveItemSaved != null) { if (perspectiveItemSaved.HasErrors) { LogInfo("PerspectiveItem ( " + perspectiveItem + ")"); LogInfo("PerspectiveItemSaved ( " + perspectiveItemSaved + ")"); return(LogError("AllErrors = " + perspectiveItemSaved.AllErrors)); } return(LogInfo("SavePerspectiveItem = true")); } return(LogError("Method _explorerAgent.SavePerspectiveItem returned null")); }
/// <summary> /// The inventory has added the specified item. /// </summary> /// <param name="item">The item that was added.</param> private void OnAddItem(Item item) { // The Third Person's PerspectiveItem object will contain a reference to the ThirdPersonObject component. var perspectiveItems = item.GetComponents <PerspectiveItem>(); PerspectiveItem thirdPersonPerspectiveItem = null; for (int i = 0; i < perspectiveItems.Length; ++i) { if (!perspectiveItems[i].FirstPersonItem) { thirdPersonPerspectiveItem = perspectiveItems[i]; break; } } if (thirdPersonPerspectiveItem != null && thirdPersonPerspectiveItem.Object != null) { var thirdPersonObject = thirdPersonPerspectiveItem.Object.GetComponent <ThirdPersonObject>(); // If the third person object exists then it should be added to the materials list. if (thirdPersonObject != null) { var renderers = thirdPersonObject.GetComponentsInChildren <Renderer>(true); for (int i = 0; i < renderers.Length; ++i) { if (!m_RegisteredRenderers.Contains(renderers[i])) { CacheRendererMaterials(renderers[i]); // If the first person perspective is active then any third person item materials should use the invisible material. if (m_CharacterLocomotion.FirstPersonPerspective) { renderers[i].materials = m_InvisibleMaterials[m_InvisibleMaterials.Count - 1]; } } } } } }
public PerspectiveItem SavePerspectiveItem(PerspectiveItem perspectiveItem) { throw new NotImplementedException(); }
/// <summary> /// Saves the perspective item. /// </summary> /// <param name="perspectiveItem">The perspective item.</param> /// <returns></returns> public PerspectiveItem SavePerspectiveItem(PerspectiveItem perspectiveItem) { return(ExplorerProviderFactory .CreateProvider(ExplorerProviderFactory.Key.Instance) .SavePerspectiveItem(perspectiveItem)); }