public void AddElements(IList <T> elements, TreeItem parent, int insertPosition) { if (elements == null) { throw new ArgumentNullException("elements", Maintainer.ConstructError("elements is null!")); } if (elements.Count == 0) { throw new ArgumentNullException("elements", Maintainer.ConstructError("elements Count is 0: nothing to add!")); } if (parent == null) { throw new ArgumentNullException("parent", Maintainer.ConstructError("parent is null!")); } if (parent.Children == null) { parent.Children = new List <TreeItem>(); } parent.Children.InsertRange(insertPosition, elements.Cast <TreeItem> ()); foreach (var element in elements) { element.Parent = parent; element.depth = parent.depth + 1; TreeItemUtility.UpdateDepthValues(element); } TreeItemUtility.TreeToList(root, data); Changed(); }
public void Copy_cost_settings_from_root() { var supplier = DataMother.CreateSupplier(s => { s.Prices.First().AddCost(); }); Save(supplier); var client = DataMother.TestClient(); var price = supplier.Prices.First(); var baseCost = price.Costs.First(); var notBaseCost = price.Costs[1]; var intersection = session.Query <Intersection>().Single(i => i.Client == client && i.Price == price); Assert.That(intersection.Cost, Is.EqualTo(baseCost)); intersection.Cost = notBaseCost; Save(intersection); var org = new LegalEntity("тараканов и сыновья", client.Payers.First()); Save(org); Flush(); Maintainer.LegalEntityCreated(session, org); intersection = session.Query <Intersection>().Single(i => i.Client == client && i.Price == price && i.Org == org); Assert.That(intersection.Cost.Id, Is.EqualTo(notBaseCost.Id), "идентификатор intersection {0}", intersection.Id); }
public static void UpdateDepthValues <T>(T root) where T : TreeElement { if (root == null) { throw new ArgumentNullException("root", Maintainer.ConstructError("The root is null!")); } if (!root.HasChildren) { return; } var stack = new Stack <TreeElement>(); stack.Push(root); while (stack.Count > 0) { var current = stack.Pop(); if (current.children != null) { foreach (var child in current.children) { child.depth = current.depth + 1; stack.Push(child); } } } }
public override int GetHashCode() { int hash = 1; if (CpeUri.Length != 0) { hash ^= CpeUri.GetHashCode(); } if (Architecture != 0) { hash ^= Architecture.GetHashCode(); } if (latestVersion_ != null) { hash ^= LatestVersion.GetHashCode(); } if (Maintainer.Length != 0) { hash ^= Maintainer.GetHashCode(); } if (Url.Length != 0) { hash ^= Url.GetHashCode(); } if (Description.Length != 0) { hash ^= Description.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static void ValidateDepthValues <T>(T[] array) where T : TreeElement { if (array.Length == 0) { throw new ArgumentException(Maintainer.ConstructError("list should have items, count is 0, check before calling ValidateDepthValues!"), "array"); } if (array[0].depth != -1) { throw new ArgumentException(Maintainer.ConstructError("list item at index 0 should have a depth of -1 (since this should be the hidden root of the tree). Depth is: " + array[0].depth + "!"), "array"); } for (var i = 0; i < array.Length - 1; i++) { var depth = array[i].depth; var nextDepth = array[i + 1].depth; if (nextDepth > depth && nextDepth - depth > 1) { throw new ArgumentException(Maintainer.ConstructError(string.Format("Invalid depth info in input list. Depth cannot increase more than 1 per row. Index {0} has depth {1} while index {2} has depth {3}!", i, depth, i + 1, nextDepth))); } } for (var i = 1; i < array.Length; ++i) { if (array[i].depth < 0) { throw new ArgumentException(Maintainer.ConstructError("Invalid depth value for item at index " + i + ". Only the first item (the root) should have depth below 0!")); } } if (array.Length > 1 && array[1].depth != 0) { throw new ArgumentException(Maintainer.ConstructError("Input list item at index 1 is assumed to have a depth of 0!"), "array"); } }
public void StartListener() { try { Maintainer rpi_maintainer = new Maintainer(usersData.Rpi_users, usersData.SyncRpi_users); Maintainer desktop_maintainer = new Maintainer(usersData.Desktop_users, usersData.SyncDesktop_users); Thread MaintainerDesktoptask = new Thread(new ParameterizedThreadStart(MaintainceUsers)); Thread MaintainerRpitask = new Thread(new ParameterizedThreadStart(MaintainceUsers)); MaintainerDesktoptask.Start(desktop_maintainer); MaintainerRpitask.Start(rpi_maintainer); while (true) { Console.WriteLine("Waiting for a connection..."); TcpClient client = server.AcceptTcpClient(); Console.WriteLine("Connected!"); Thread t = new Thread(new ParameterizedThreadStart(RegisterDevice)); t.Start(client); //Wjebac tych klientow do slownika z kluczem zarejsetrowanym nicku i tcpclient czyli de facto socket } } catch (SocketException e) { Console.WriteLine("SocketException: {0}", e); server.Stop(); } }
public static bool IsPropertyHasMissingReference(SerializedProperty currentProperty) { if (currentProperty.propertyType != SerializedPropertyType.ObjectReference) { return(false); } if (currentProperty.objectReferenceValue != null) { return(false); } if (currentProperty.objectReferenceInstanceIDValue != 0) { return(true); } #if UNITY_2018_3_OR_NEWER var fileId = currentProperty.FindPropertyRelative("m_FileID"); if (fileId != null) { if (fileId.intValue != 0) { return(true); } } else { Maintainer.ConstructReportWarning( "Property seems to be missing reference but m_FileID could not be found!", IssuesFinder.ModuleName); } #endif return(false); }
public static ActiveEditorTracker GetActiveEditorTrackerForSelectedObject() { var inspectorWindow = GetInspectorWindow(); if (inspectorWindow == null) { return(null); } if (CSReflectionTools.inspectorWindowType == null) { return(null); } inspectorWindow.Repaint(); ActiveEditorTracker result = null; var trackerProperty = CSReflectionTools.GetPropertyInfo(CSReflectionTools.inspectorWindowType, "tracker"); if (trackerProperty != null) { result = (ActiveEditorTracker)trackerProperty.GetValue(inspectorWindow, null); } else { Debug.LogError(Maintainer.ConstructError("Can't get ActiveEditorTracker from the InspectorWindow!")); } return(result); }
public static void SetInspectorToDebug(SerializedObject serializedObject) { if (inspectorModeCachedSetter == null) { var pi = typeof(SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance); if (pi != null) { var mi = pi.GetSetMethod(true); if (mi != null) { inspectorModeCachedSetter = (Action <SerializedObject, InspectorMode>)Delegate.CreateDelegate(typeof(Action <SerializedObject, InspectorMode>), mi); } else { Debug.LogError(Maintainer.ConstructError("Can't get the setter for the SerializedObject.inspectorMode property!")); return; } } else { Debug.LogError(Maintainer.ConstructError("Can't get the SerializedObject.inspectorMode property!")); return; } } inspectorModeCachedSetter.Invoke(serializedObject, InspectorMode.Debug); }
private void GetSplitterState() { if (splitterState != null) { return; } var savedState = MaintainerPersonalSettings.References.splitterState; object result; try { if (!string.IsNullOrEmpty(savedState)) { result = JsonUtility.FromJson(savedState, CSReflectionTools.splitterStateType); } else { result = Activator.CreateInstance(CSReflectionTools.splitterStateType, new [] { 100f, 50f }, new [] { 90, 47 }, null); } } catch (Exception e) { Debug.LogError(Maintainer.ConstructError("Couldn't create instance of the SplitterState class!\n" + e, ReferencesFinder.ModuleName)); throw e; } splitterState = result; }
public static string[] GetAssetImporterDependencies(string path) { var importer = AssetImporter.GetAtPath(path); if (importer == null) { Debug.LogWarning(Maintainer.ConstructWarning("Couldn't find AssetImporter for " + path)); return(null); } var method = importer.GetType().GetMethod("GatherDependenciesFromSourceFile", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method == null) { // this importer does not implement optional GatherDependenciesFromSourceFile message (starting from Unity 2020.1) return(null); } var items = (string[])method.Invoke(null, new [] { path }); if (items != null && items.Length > 0) { return(items); } return(null); }
private static void CheckLightMapSettings(TreeConjunction conjunction, int candidateInstanceId) { lightmapSettings = lightmapSettings ? lightmapSettings : CSSettingsTools.GetInSceneLightmapSettings(); if (lightmapSettings == null) { return; } lightmapSettingsSo = lightmapSettingsSo ?? new SerializedObject(lightmapSettings); lightmapParametersField = lightmapParametersField ?? lightmapSettingsSo.FindProperty( "m_LightmapEditorSettings.m_LightmapParameters"); if (lightmapParametersField != null && lightmapParametersField.propertyType == SerializedPropertyType.ObjectReference) { if (lightmapParametersField.objectReferenceInstanceIDValue == candidateInstanceId) { var entry = new ReferencingEntryData { location = Location.SceneLightingSettings, prefixLabel = "Lighting settings (Scene tab > Lightmapping Settings > Lightmap Parameters)" }; conjunction.referencedAtInfo.AddNewEntry(entry); } } else { Debug.LogError( Maintainer.ConstructError( "Can't find m_LightmapParameters at the LightmapSettings!")); } }
private static long GetUniqueObjectIdFromAssetObject(Object unityObject) { /*var go = unityObject as GameObject; * if (go != null) * { * unityObject = go.transform; * }*/ long result = -1; var path = AssetDatabase.GetAssetPath(unityObject); if (!string.IsNullOrEmpty(path)) { #if UNITY_2018_2_OR_NEWER result = GetAssetLocalIdentifierInFile(unityObject); #else if (AssetDatabase.IsMainAsset(unityObject)) { result = path.GetHashCode(); } else { result = GetLocalIdentifierInFile(unityObject); } #endif } else { Debug.LogError(Maintainer.ConstructError("Can't get path to the asset " + unityObject.name)); } return(result); }
public static void TreeToList <T>(T root, IList <T> result) where T : TreeElement { if (result == null) { throw new NullReferenceException(Maintainer.ConstructError("The input 'IList<T> result' list is null!")); } result.Clear(); var stack = new Stack <T>(); stack.Push(root); while (stack.Count > 0) { var current = stack.Pop(); result.Add(current); if (current.children == null || current.children.Count <= 0) { continue; } for (var i = current.children.Count - 1; i >= 0; i--) { stack.Push((T)current.children[i]); } } }
public void MoveElements(TreeItem parentItem, int insertionIndex, List <TreeItem> elements) { if (insertionIndex < 0) { throw new ArgumentException(Maintainer.ConstructError("Invalid input: insertionIndex is -1, client needs to decide what index elements should be reparented at!")); } if (parentItem == null) { return; } if (insertionIndex > 0) { insertionIndex -= parentItem.Children.GetRange(0, insertionIndex).Count(elements.Contains); } foreach (var draggedItem in elements) { draggedItem.Parent.Children.Remove(draggedItem); draggedItem.Parent = parentItem; } if (parentItem.Children == null) { parentItem.Children = new List <TreeItem>(); } parentItem.Children.InsertRange(insertionIndex, elements); TreeItemUtility.UpdateDepthValues(root); TreeItemUtility.TreeToList(root, data); Changed(); }
private static bool RevealAndSelectGameObjectInPrefab(string enclosingAssetPath, string transformPath, long objectId, long componentId) { var targetAsset = AssetDatabase.LoadMainAssetAtPath(enclosingAssetPath) as GameObject; if (targetAsset == null) { return(false); } Object target = CSObjectTools.FindChildGameObjectRecursive(targetAsset.transform, objectId, targetAsset.transform.name, transformPath); // in some cases, prefabs can have nested non-GameObject items if (target == null) { var allObjectsInPrefab = AssetDatabase.LoadAllAssetsAtPath(enclosingAssetPath); foreach (var objectOnPrefab in allObjectsInPrefab) { if (objectOnPrefab is BillboardAsset || objectOnPrefab is TreeData) { var objectOnPrefabId = CSObjectTools.GetUniqueObjectId(objectOnPrefab); if (objectOnPrefabId == objectId) { target = objectOnPrefab; } } } } if (target == null) { Debug.LogError(Maintainer.ConstructError("Couldn't find target Game Object " + transformPath + " at " + enclosingAssetPath + " with ObjectID " + objectId + "!")); return(false); } if (target is GameObject) { CSObjectTools.SelectGameObject((GameObject)target, false); } else { Selection.activeObject = target; } if (transformPath.Split('/').Length > 2) { EditorApplication.delayCall += () => { EditorGUIUtility.PingObject(targetAsset); }; } if (componentId != -1) { return(TryFoldAllComponentsExceptId(componentId)); } return(true); }
private static List <string> ExtractReferencedAssets(Object assetGroup) { var so = new SerializedObject(assetGroup); var serializedEntries = so.FindProperty("m_SerializeEntries"); if (serializedEntries == null) { // legacy package version used this name serializedEntries = so.FindProperty("m_serializeEntries"); if (serializedEntries == null) { Debug.LogError(Maintainer.ConstructError("Can't reach serialize entries in AddressableAssetGroup!")); return(null); } } if (!serializedEntries.isArray) { Debug.LogError(Maintainer.ConstructError("Can't find serialize entries array in AddressableAssetGroup!")); return(null); } var result = new List <string>(); var count = serializedEntries.arraySize; for (var i = 0; i < count; i++) { var item = serializedEntries.GetArrayElementAtIndex(i); if (item == null) { Debug.LogWarning(Maintainer.ConstructWarning("Serialize entry from AddressableAssetGroup is null!")); continue; } var referencedGUID = item.FindPropertyRelative("m_GUID"); if (referencedGUID == null || referencedGUID.propertyType != SerializedPropertyType.String) { Debug.LogError(Maintainer.ConstructError("Can't reach Serialize entry GUID of AddressableAssetGroup!")); return(null); } var path = AssetDatabase.GUIDToAssetPath(referencedGUID.stringValue); if (!path.StartsWith("Assets")) { continue; } var guid = AssetDatabase.AssetPathToGUID(path); if (!string.IsNullOrEmpty(guid)) { result.Add(guid); } } return(result); }
public void Dispose() { if (!IsDisposing) { IsDisposing = true; Maintainer.Dispose(); } }
public static long GetUniqueObjectId(Object unityObject, bool recursiveCall = false) { var id = -1L; var siblingId = 0; if (unityObject == null) { return(id); } var go = unityObject as GameObject; if (go != null) { siblingId = go.transform.GetSiblingIndex(); //unityObject = go.transform; } if (CSPrefabTools.IsInstance(unityObject)) { var prefabAssetSource = CSPrefabTools.GetAssetSource(unityObject); if (prefabAssetSource != null) { if (!recursiveCall) { id = GetUniqueObjectId(prefabAssetSource, true); return(id + siblingId); } Debug.LogError(Maintainer.ConstructError("Couldn't reach asset source: " + unityObject.name), unityObject); } } if (AssetDatabase.Contains(unityObject)) { id = GetUniqueObjectIdFromAssetObject(unityObject); } else { id = GetLocalIdentifierInFile(unityObject); if (id <= 0) { id = unityObject.GetInstanceID(); } } if (id <= 0) { id = siblingId; } if (id <= 0) { id = unityObject.name.GetHashCode(); } return(id); }
private static void CheckRenderSettingsTexture(TreeConjunction conjunction, int candidateInstanceId) { renderSettings = renderSettings ? renderSettings : CSSettingsTools.GetInSceneRenderSettings(); if (renderSettings == null) { return; } renderSettingsSo = renderSettingsSo ?? new SerializedObject(renderSettings); renderHaloField = renderHaloField ?? renderSettingsSo.FindProperty("m_HaloTexture"); if (renderHaloField != null && renderHaloField.propertyType == SerializedPropertyType.ObjectReference) { if (renderHaloField.objectReferenceInstanceIDValue == candidateInstanceId) { var entry = new ReferencingEntryData { location = Location.SceneLightingSettings, prefixLabel = "Lighting settings (Scene tab > Other Settings > Halo Texture)" }; conjunction.referencedAtInfo.AddNewEntry(entry); } } else { Debug.LogError(Maintainer.ConstructError("Can't find m_HaloTexture at the RenderSettings!")); } renderSpotField = renderSpotField ?? renderSettingsSo.FindProperty("m_SpotCookie"); if (renderSpotField != null && renderSpotField.propertyType == SerializedPropertyType.ObjectReference) { if (renderSpotField.objectReferenceInstanceIDValue == candidateInstanceId) { var entry = new ReferencingEntryData { location = Location.SceneLightingSettings, prefixLabel = "Lighting settings (Scene tab > Other Settings > Spot Cookie)" }; conjunction.referencedAtInfo.AddNewEntry(entry); } } else { Debug.LogError(Maintainer.ConstructError("Can't find m_SpotCookie at the RenderSettings!")); } /*var iterator = renderSettingsSo.GetIterator(); * while (iterator.Next(true)) * { * if (iterator.propertyType == SerializedPropertyType.ObjectReference) * { * Debug.Log(iterator.propertyPath + " [" + iterator.objectReferenceValue + "]"); * } * }*/ }
void CurrentDomain_ProcessExit(object sender, EventArgs e) { Logger.LogInformation("Shutdown Dispose start"); CancellationTokenSource.Cancel(); Maintainer?.Dispose(); CancellationTokenSource.Dispose(); Logger.LogInformation("Shutdown Dispose finished"); NLog.LogManager.Shutdown(); }
private static bool RevealAndSelectGameObjectInPrefab(string enclosingAssetPath, string transformPath, long objectId, long componentId) { /*Debug.Log("LOOKING FOR objectId " + objectId); * Debug.Log("enclosingAssetPath " + enclosingAssetPath);*/ var targetAsset = AssetDatabase.LoadMainAssetAtPath(enclosingAssetPath) as GameObject; var prefabType = PrefabUtility.GetPrefabAssetType(targetAsset); GameObject target; if (prefabType == PrefabAssetType.Model) { target = targetAsset; } else { if (!AssetDatabase.OpenAsset(targetAsset)) { Debug.LogError(Maintainer.ConstructError("Couldn't open prefab at " + enclosingAssetPath + "!")); return(false); } var stage = PrefabStageUtility.GetCurrentPrefabStage(); if (stage == null) { Debug.LogError(Maintainer.ConstructError("Couldn't get prefab stage for prefab at " + enclosingAssetPath + "!")); return(false); } target = stage.prefabContentsRoot; } if (target == null) { Debug.LogError(Maintainer.ConstructError("Couldn't find target Game Object " + transformPath + " at " + enclosingAssetPath + " with ObjectID " + objectId + "!")); return(false); } target = CSObjectTools.FindChildGameObjectRecursive(target.transform, objectId, target.transform.name, transformPath); EditorApplication.delayCall += () => { CSObjectTools.SelectGameObject(target, false); EditorGUIUtility.PingObject(targetAsset); if (componentId != -1) { EditorApplication.delayCall += () => { TryFoldAllComponentsExceptId(componentId); }; } }; return(true); }
public static OpenSceneResult OpenScene(string path, bool activate = true) { #if UNITY_2018_3_OR_NEWER StageUtility.GoToMainStage(); #endif var result = new OpenSceneResult(); if (string.IsNullOrEmpty(path)) { Debug.LogError(Maintainer.ConstructError("Can't open scene since path is absent!")); return(result); } var targetScene = SceneManager.GetSceneByPath(path); result.scene = targetScene; result.scenePath = path; if (targetScene == SceneManager.GetActiveScene()) { result.success = true; return(result); } if (!targetScene.isLoaded) { result.sceneWasAdded = EditorSceneManager.GetSceneManagerSetup().All(s => s.path != targetScene.path); try { targetScene = EditorSceneManager.OpenScene(path, OpenSceneMode.Additive); } catch (Exception e) { Debug.LogError(Maintainer.ConstructError("Error while opening scene: " + path + "\n" + e)); return(result); } result.scene = targetScene; if (!targetScene.IsValid()) { Debug.LogError(Maintainer.ConstructError("Can't open scene since path leads to invalid scene!")); return(result); } result.sceneWasLoaded = true; } result.success = true; if (activate) { SceneManager.SetActiveScene(targetScene); } return(result); }
public void Search_suppliers() { session.Save(DataMother.CreateSupplier()); Flush(); Maintainer.MaintainIntersection(session, client, client.Orgs().First()); var suppliers = controller.SearchSuppliers(client.Id, "тест"); Assert.That(suppliers.Length, Is.GreaterThan(0)); }
private static bool RevealAndSelectGameObjectInScene(string path, string transformPath, long objectId, long componentId) { Scene targetScene; if (!string.IsNullOrEmpty(path)) { var openResult = OpenSceneForReveal(path); if (!openResult.success) { return(false); } targetScene = openResult.scene; } else { targetScene = CSSceneTools.GetUntitledScene(); } if (!targetScene.IsValid()) { Debug.LogError(Maintainer.ConstructError("Target scene is not valid or not found! Scene path: " + path + ", looked for ObjectID " + objectId + "!")); return(false); } var target = CSObjectTools.FindGameObjectInScene(targetScene, objectId, transformPath); if (target == null) { Debug.LogError(Maintainer.ConstructError("Couldn't find target Game Object " + transformPath + " at " + path + " with ObjectID " + objectId + "!")); return(false); } // workaround for a bug when Unity doesn't expand hierarchy in scene EditorApplication.delayCall += () => { EditorGUIUtility.PingObject(target); }; CSObjectTools.SelectGameObject(target, true); var enclosingAssetInstanceId = CSAssetTools.GetMainAssetInstanceID(path); EditorApplication.delayCall += () => { EditorGUIUtility.PingObject(enclosingAssetInstanceId); }; if (componentId != -1) { return(TryFoldAllComponentsExceptId(componentId)); } return(true); }
public static void Save() { if (cachedMap != null) { SaveMap(MapPath, cachedMap); } else { Debug.LogError(Maintainer.ConstructError("Can't save AssetsMap, no cache found!")); } }
public static Object GetInSceneRenderSettings() { var mi = CSReflectionTools.GetGetRenderSettingsMethodInfo(); if (mi != null) { return((Object)mi.Invoke(null, null)); } Debug.LogError(Maintainer.ConstructError("Can't retrieve RenderSettings object via reflection!")); return(null); }
// Control the view of maintainer main page // GET: Maintainer public ActionResult Index() { try { // Set the LastMaintainerID as the current logged-in user return(View(Maintainer.GetWeatherInfos(User.Identity.Name).ToList())); } catch (Exception e) { return(View("Error", new HandleErrorInfo(e, "Maintainer", "Index"))); } }
public static int GetMainAssetInstanceID(string path) { var mi = CSReflectionTools.GetGetMainAssetInstanceIDMethodInfo(); if (mi != null) { return((int)mi.Invoke(null, new object[] { path })); } Debug.LogError(Maintainer.ConstructError("Can't retrieve InstanceID From path via reflection!")); return(-1); }
public void AddJuridicalOrganization([ARDataBind("juridicalOrganization", AutoLoad = AutoLoadBehavior.NewRootInstanceIfInvalidKey)] LegalEntity legalEntity, uint payerId) { if (IsValid(legalEntity)) { var payer = DbSession.Load <Payer>(payerId); legalEntity.Payer = payer; DbSession.Save(legalEntity); Maintainer.LegalEntityCreated(DbSession, legalEntity); Notify("Юридическое лицо создано"); } RedirectToReferrer(); }