コード例 #1
0
        public void ПересчитатьПриоритет()
        {
            ReferenceObject referenceObject = this.Context.ReferenceObject;
            UserRequest     userRequest     = new UserRequest(referenceObject);

            RecalcPriority(userRequest);
        }
コード例 #2
0
        /// <summary>
        /// Возможность редактирования объекта, если можно true, иначе   false
        /// </summary>
        static bool CanEditObject(ReferenceObject projectElement)
        {
            if (projectElement == null)
            {
                return(false);
            }

            projectElement.Unlock();
            if (projectElement.CanEdit)
            {
                try
                {
                    projectElement.BeginChanges();
                    projectElement.EndChanges();
                }
                catch (ObjectLockErrorException)
                {
                    return(false);
                }
                finally
                {
                    projectElement.Unlock();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        static public ReferenceObject CopyPE(ReferenceObject исходныйОбъект, ReferenceObject целевойОбъект, List <Guid> listParametersToSkip)
        {
            ReferenceObject копияИсходногоОбъекта = References.ProjectManagementReference.CreateReferenceObject(целевойОбъект, References.Class_ProjectManagementWork);

            foreach (Parameter parameter in копияИсходногоОбъекта.ParameterValues)
            {
                if (parameter.IsReadOnly)
                {
                    continue;
                }

                if (listParametersToSkip.Contains(parameter.ParameterInfo.Guid) || listLinksToSkip.Contains(parameter.ParameterInfo.Guid))
                {
                    continue;
                }

                копияИсходногоОбъекта[parameter.ParameterInfo].Value = исходныйОбъект[parameter.ParameterInfo].Value;
            }

            копияИсходногоОбъекта.SetParent(целевойОбъект);

            копияИсходногоОбъекта.EndChanges();

            if (копияИсходногоОбъекта != null)
            {
                return(копияИсходногоОбъекта);
            }
            else
            {
                MessageBox.Show("Не удалось создать копию в целевом объекте - " + целевойОбъект.ToString());
            }
            return(null);
        }
コード例 #4
0
        /// <summary>
        /// Получить  нерасходуемые ресурсы
        /// </summary>
        /// <param name="ro"></param>
        /// <returns></returns>
        static public IEnumerable <UsedResource> GetLinkedUsedNonConsumableResources(ReferenceObject ro, bool IsOnlyPlanned)
        {
            List <ReferenceObject> resources = ro.GetObjects(ProjectManagementWork.PM_link_UsedResources_GUID)
                                               .Where(res => (res.Class == References.Class_NonConsumableResources)).ToList();

            List <UsedResource> NonConsumableResources = new List <UsedResource>();

            //Console.WriteLine("IsOnlyPlanned " + IsOnlyPlanned);

            foreach (var res in resources)
            {
                UsedResource usedResource = new UsedResource(res);


                if (IsOnlyPlanned)
                {
                    if (usedResource.IsPlanned)
                    {
                        NonConsumableResources.Add(usedResource);
                    }
                }
                else
                {
                    NonConsumableResources.Add(usedResource);
                }
            }

            return(NonConsumableResources);
        }
コード例 #5
0
        public void DeserializeSelfRefObject()
        {
            ReferenceObject robj = new ReferenceObject();

            robj.ID   = 0;
            robj.Type = typeof(SomeClass);

            Field nameField   = new Field();
            Field ageField    = new Field();
            Field parentField = new Field();

            nameField.Name   = "name";
            ageField.Name    = "age";
            parentField.Name = "parent";

            nameField.Value   = NullObject.Default;
            parentField.Value = robj;
            ageField.Value    = GetIntegerValueObject(55);

            robj.Fields.Add(nameField);
            robj.Fields.Add(ageField);
            robj.Fields.Add(parentField);

            SomeClass res = (SomeClass)robj.GetValue();

            Assert.AreEqual(res.Name, null);
            Assert.AreEqual(res.Parent, res);
            Assert.AreEqual(res.Age, 55);
        }
コード例 #6
0
 private void NewGUID(ReferenceObject refobj)
 {
     Undo.RecordObject(refobj, "RefObj");
     refobj.Data.GUID = GUIDHelper.NewGUID();
     PrefabUtility.RecordPrefabInstancePropertyModifications(refobj);
     RefreshData();
 }
コード例 #7
0
ファイル: SceneReference.cs プロジェクト: SeanTongTx/SeanLib
    public virtual UnityEngine.Object Resolve()
    {
        if (!ReferenceRoot.Instance)
        {
            return(null);
        }

#if UNITY_EDITOR
        if (ResolvedObj)
        {
            RefObj = ReferenceRoot.Instance.Get(this);
        }
#endif

        if (!Dynamic && ResolvedObj)
        {
            return(ResolvedObj);
        }
        RefObj = ReferenceRoot.Instance.Get(this);
        if (!RefObj)
        {
            return(null);
        }

        if (string.IsNullOrEmpty(Type))
        {
            ResolvedObj = RefObj.Resolve();
        }
        else
        {
            ResolvedObj = RefObj.Resolve(Type);
        }
        return(ResolvedObj);
    }
コード例 #8
0
ファイル: SceneReference.cs プロジェクト: SeanTongTx/SeanLib
    public virtual T Resolve <T>() where T : UnityEngine.Component
    {
        if (!ReferenceRoot.Instance)
        {
            return(null);
        }

#if UNITY_EDITOR
        if (ResolvedObj)
        {
            RefObj = ReferenceRoot.Instance.Get(this);
        }
#endif

        if (!Dynamic && ResolvedObj)
        {
            return(ResolvedObj as T);
        }
        RefObj = ReferenceRoot.Instance.Get(this);
        if (!RefObj)
        {
            ResolvedObj = null;
            return(null);
        }
        ResolvedObj = RefObj.Resolve <T>();
        return(ResolvedObj as T);
    }
コード例 #9
0
ファイル: ReferenceObject.cs プロジェクト: grifdail/GGJ2016
	// Destroy
	public static void SafeDestroy(ReferenceObject a_rRef)
	{
		if(a_rRef != null)
		{
			Object.DestroyImmediate(a_rRef);
		}
	}
コード例 #10
0
        public void TestReferenceUpdate()
        {
            var so1 = new SimpleObject {
                ValueOne = 1, ValueTwo = 2
            };
            var so2 = new SimpleObject {
                ValueOne = 3, ValueTwo = 4
            };
            var ro = new ReferenceObject {
                ReferenceOne = so1
            };

            var clone = (ReferenceObject)CopyUtils.CloneObjectTest(ro);

            clone.ReferenceOne = so2;

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreNotSame(ro.ReferenceOne, clone.ReferenceOne);

            CopyUtils.UpdateFromClone(ro, clone);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }
コード例 #11
0
    private static void AddObjectWithoutSelfObject(ReferenceObject refObject, Queue <ReferenceObject> objects)
    {
        var value = refObject.value as Object;

        if (value == null || value.GetType().IsPrimitive)
        {
            return;
        }

        if (value is GameObject)
        {
            var obj = value as GameObject;
            if (obj != refObject.rootComponent.gameObject)
            {
                objects.Enqueue(refObject);
            }
        }
        else if (value is Component)
        {
            var component = value as Component;
            if (component.gameObject != refObject.rootComponent.gameObject)
            {
                objects.Enqueue(refObject);
            }
        }
    }
コード例 #12
0
        public ProjectManagementWork(string stringGuid)
        {
            Guid = new Guid(stringGuid);
            ReferenceObject work = FindWork(Guid);

            ReferenceObject = work;
        }
コード例 #13
0
        /// <summary>
        /// Use GetSyncronizedWorks
        /// Возвращает список синхронизированных работ из указанного пространства планирования
        /// </summary>
        /// <param name="work"></param>
        /// <param name="planningSpaceGuidString"></param>
        /// <param name="returnOnlyMasterWorks"> если true только укрупнения, если false только детализации</param>
        /// <returns></returns>
        public static List <ReferenceObject> GetSynchronizedWorksFromSpace(ReferenceObject work,
                                                                           string planningSpaceGuidString, bool?returnOnlyMasterWorks = null)
        {
            if (string.IsNullOrEmpty(planningSpaceGuidString))
            {
                planningSpaceGuidString = Guid.Empty.ToString();
            }

            string guidStringForSearch = work.SystemFields.Guid.ToString();
            List <ReferenceObject> DependenciesObjects = GetDependenciesObjects(returnOnlyMasterWorks, guidStringForSearch);

            List <ReferenceObject> result = new List <ReferenceObject>();

            foreach (var guidPE in getListGuidObjectsByFilter(DependenciesObjects, work))
            {
                var PE = References.ProjectManagementReference.Find(guidPE);

                if (PE == null)
                {
                    continue;
                }

                ProjectManagementWork tempWork = new ProjectManagementWork(PE);

                if (tempWork.PlanningSpace.ToString() == planningSpaceGuidString)
                {
                    result.Add(References.ProjectManagementReference.Find(guidPE));
                }
            }
            return(result);
        }
コード例 #14
0
        public void SynchronizingСomposition(TreeViewModel treeViewModel, bool IsCopyRes, bool IsCopyOnlyPlan /*, ref int amountAddObjects*//*, MainWindowViewModel mainWindowViewModel = null*/)
        {
            if (Worker.Cancel)
            {
                return;
            }

            Worker.CurrentNumberIterat++;

            if (Worker.Percent == "0%")
            {
                Worker.numberAllIterat = treeViewModel.ProjectElement.Children.RecursiveLoad().Count + 1;
            }

            ReferenceObject Parent = treeViewModel.PEForSync;

            if (Parent != null)
            {
                Parent = syncComposition(treeViewModel, IsCopyRes: IsCopyRes, IsCopyOnlyPlan: IsCopyOnlyPlan /*, ref amountAddObjects*/);
            }

            foreach (TreeViewModel treeViewModelItem in treeViewModel.Children)
            {
                if (Parent != null && treeViewModelItem.PEForSync == null)
                {
                    treeViewModelItem.PEForSync = Parent;
                }
                SynchronizingСomposition(treeViewModelItem, IsCopyRes: IsCopyRes, IsCopyOnlyPlan: IsCopyOnlyPlan /*, ref amountAddObjects*/);
            }
        }
コード例 #15
0
 bool filtRefObj(ReferenceObject refobj)
 {
     if (search.Current.IsNullOrEmpty())
     {
         return(true);
     }
     foreach (var kvFilter in search.filter.filters)
     {
         if (kvFilter.Key == "t" && refobj.GetType().FullName.ToLower().Contains(kvFilter.Value.ToLower()))
         {
             if (search.filter.value.IsNullOrEmpty())
             {
                 return(true);
             }
             else
             {
                 return(refobj.Data.GUID.ToLower().Contains(search.filter.value.ToLower()));
             }
         }
         else if (kvFilter.Key == "n" && refobj.name.ToLower().Contains(kvFilter.Value.ToLower()))
         {
             if (search.filter.value.IsNullOrEmpty())
             {
                 return(true);
             }
             else
             {
                 return(refobj.Data.GUID.ToLower().Contains(search.filter.value.ToLower()));
             }
         }
     }
     return(search.GeneralValid(refobj.Data.GUID));
 }
コード例 #16
0
        private static ReferenceFile GetSceneReference(string scenePath, PropertyFilter filter,
                                                       bool containsEmpty = false)
        {
            var scene            = UnityApi.MakeSureSceneOpened(scenePath);
            var referenceObjects = scene.GetRootGameObjects()
                                   .SelectMany(go => UnityApi.GetAllComponentsInChildren(go)
                                               .Select(t => t.component == null
                        ? containsEmpty
                            ? ReferenceObject.EmptyComponent(
                                                           UnityApi.GetTransformPath(t.gameObject))
                            : null
                        : GetReferenceObject(t.component, filter, true))
                                               .Append(go == null
                        ? containsEmpty
                            ? ReferenceObject.EmptyGameObject
                            : null
                        : GetReferenceObject(go, filter, true))
                                               )
                                   .Where(refObj => refObj != null)
                                   .ToArray();

            return(referenceObjects.Length > 0
                ? new ReferenceFile {
                ReferenceFilePath = scenePath,
                ReferenceObjects = referenceObjects,
            }
                : null);
        }
コード例 #17
0
 /// <summary>
 /// Очистка коллекции
 /// </summary>
 protected override void OnDispose()
 {
     startRefObject           = null;
     StartObject              = null;
     SelectedDetailingProject = null;
     _detailingProjects       = null;
     _tree = null;
 }
コード例 #18
0
ファイル: SceneObject.cs プロジェクト: SeanTongTx/SeanLib
    /// <summary>
    /// 数据绑定到Gameobject
    /// </summary>
    /// <param name="go"></param>
    /// <returns></returns>
    public ReferenceObject BindInstance(GameObject go)
    {
        ReferenceObject component = ReferenceRoot.AddReference(AssemblyTool.FindTypesInCurrentDomainByName(RefType), go, null);

        this.state     = SceneObjectState.binding;
        component.Data = this;
        return(component);
    }
コード例 #19
0
 public bool ПрименитьИзменения()
 {
     if (ЕстьИзмененияДляСохраненияВБД)
     {
         return(ReferenceObject.ApplyChanges());
     }
     return(false);
 }
コード例 #20
0
    void Start()
    {
        propertyNames     = new List <GameObject>();
        propertyValues    = new List <GameObject>();
        IsCancelRequested = false;

        var objectTag = ReferenceObject.tag;

        if (objectTag == "Car")
        {
            for (int i = 0; i < 6; i++)
            {
                var property = Instantiate(propertyPrefab);
                property.transform.SetParent(transform);
                property.transform.localScale = Vector3.one;

                propertyNames.Add(property.transform.Find("Name").gameObject);
                propertyValues.Add(property.transform.Find("Value").gameObject);
            }

            propertyNames[0].GetComponent <TextMeshProUGUI>().SetText("Object ID");
            propertyValues[0].GetComponent <TextMeshProUGUI>().SetText(ReferenceObject.GetInstanceID().ToString());
            propertyNames[1].GetComponent <TextMeshProUGUI>().SetText("Object Type");
            propertyValues[1].GetComponent <TextMeshProUGUI>().SetText(ReferenceObject.tag);

            propertyNames[2].GetComponent <TextMeshProUGUI>().SetText("Velocity");
            propertyNames[3].GetComponent <TextMeshProUGUI>().SetText("Expected velocity");
            propertyNames[4].GetComponent <TextMeshProUGUI>().SetText("Accleration");
            propertyNames[5].GetComponent <TextMeshProUGUI>().SetText("Max accleration");
        }
        if (objectTag == "Lane")
        {
            var nextRoads = ReferenceObject.GetComponent <Line>().nextRoads;

            for (int i = 0; i < nextRoads.Count + 2; i++)
            {
                var property = Instantiate(propertyPrefab);
                property.transform.SetParent(transform);
                property.transform.localScale = Vector3.one;

                propertyNames.Add(property.transform.Find("Name").gameObject);
                propertyValues.Add(property.transform.Find("Value").gameObject);
            }

            propertyNames[0].GetComponent <TextMeshProUGUI>().SetText("Object ID");
            propertyValues[0].GetComponent <TextMeshProUGUI>().SetText(ReferenceObject.GetInstanceID().ToString());
            propertyNames[1].GetComponent <TextMeshProUGUI>().SetText("Object Type");
            propertyValues[1].GetComponent <TextMeshProUGUI>().SetText(ReferenceObject.tag);

            for (int i = 2; i < nextRoads.Count + 2; i++)
            {
                propertyNames[i].GetComponent <TextMeshProUGUI>().SetText($"Next Road id [{i}]");
                propertyValues[i].GetComponent <TextMeshProUGUI>().SetText(nextRoads[i - 2].gameObject.GetInstanceID().ToString());
            }
        }

        var task = UpdatePropertyValue(objectTag);
    }
コード例 #21
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (ReferenceObject.Expression != null)
            {
                targetCommand.AddParameter("ReferenceObject", ReferenceObject.Get(context));
            }

            if (DifferenceObject.Expression != null)
            {
                targetCommand.AddParameter("DifferenceObject", DifferenceObject.Get(context));
            }

            if (SyncWindow.Expression != null)
            {
                targetCommand.AddParameter("SyncWindow", SyncWindow.Get(context));
            }

            if (Property.Expression != null)
            {
                targetCommand.AddParameter("Property", Property.Get(context));
            }

            if (ExcludeDifferent.Expression != null)
            {
                targetCommand.AddParameter("ExcludeDifferent", ExcludeDifferent.Get(context));
            }

            if (IncludeEqual.Expression != null)
            {
                targetCommand.AddParameter("IncludeEqual", IncludeEqual.Get(context));
            }

            if (PassThru.Expression != null)
            {
                targetCommand.AddParameter("PassThru", PassThru.Get(context));
            }

            if (Culture.Expression != null)
            {
                targetCommand.AddParameter("Culture", Culture.Get(context));
            }

            if (CaseSensitive.Expression != null)
            {
                targetCommand.AddParameter("CaseSensitive", CaseSensitive.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
コード例 #22
0
	// Check fro lost references
	private void CheckForLostReferences()
	{
		if(m_oRef_Last != m_oRef)
		{
			if(m_oRef_Last != null && m_oRef_Last.Owner == m_rOwner)
			{
				UnityEngine.Object.DestroyImmediate(m_oRef_Last);
			}
			m_oRef_Last = m_oRef;
		}
	}
コード例 #23
0
    private static void AddObject(ReferenceObject refObject, Queue<ReferenceObject> objects)
    {
        var value = refObject.value as Object;
        if (value == null || value.GetType ().IsPrimitive)
            return;

        if(value is GameObject)
        {
            objects.Enqueue(refObject);
        }else if(value is Component){
            objects.Enqueue(refObject);
        }
    }
コード例 #24
0
	// Check for reference validity
	private bool CheckForReferenceValidity()
	{
		if(m_oRef == null || m_oRef.Owner != m_rOwner)
		{
			m_oRef = ScriptableObject.CreateInstance<ReferenceObject>();
			m_oRef.Create(CreateReference(), m_rOwner, m_bOwnResource);
#if UNITY_EDITOR
			EditorUtility.SetDirty(m_rOwner);
#endif				
			CheckForLostReferences();
			
			return false;
		}
		return true;
	}
コード例 #25
0
    private static void AddObjectWithoutSelfObject(ReferenceObject refObject, Queue<ReferenceObject> objects)
    {
        var value = refObject.value as Object;
        if (value == null || value.GetType ().IsPrimitive)
            return;

        if(value is GameObject)
        {
            var obj = value as GameObject;
            if( obj != refObject.rootComponent.gameObject )
                objects.Enqueue(refObject);
        }else if(value is Component){
            var component = value as Component;
            if(component.gameObject != refObject.rootComponent.gameObject)
                objects.Enqueue(refObject);
        }
    }
コード例 #26
0
    public static void GetComponents()
    {
        var obj = Selection.activeGameObject;
        if( obj == null ){
            return;
        }

        Queue<ReferenceObject> objects = new Queue<ReferenceObject>();

        foreach( var component in obj.GetComponents<Component>())
        {

            var type = component.GetType();

            foreach( var field in type.GetFields(
                BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance |
                BindingFlags.Static | BindingFlags.DeclaredOnly))
            {
                var item = new ReferenceObject(){
                    rootComponent = component,
                    value = field.GetValue(component),
                    memberName = field.Name,
                };
                AddObject(item, objects);
            }

            foreach( var property in type.GetProperties(
                BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static))
            {
                var item = new ReferenceObject(){
                    rootComponent = component,
                    value = property.GetValue(component, null),
                    memberName = property.Name,
                };
                AddObjectWithoutSelfObject(item, objects);
            }
        }

        foreach( var collectedObj in objects)
        {
            Debug.Log(collectedObj.rootComponent.name + "." + collectedObj.memberName + "/" + collectedObj.value);
        }
    }
コード例 #27
0
ファイル: Game.cs プロジェクト: rcashie/SBContentManager
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            GamePadState _gamePadState = GamePad.GetState(PlayerIndex.One);
            if (_gamePadState.Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            KeyboardState _keyBoardState = Keyboard.GetState();
            if (mRequestBatch == null
                && (_keyBoardState.IsKeyDown(Keys.Enter) || _gamePadState.Buttons.A == ButtonState.Pressed))
            {
                // Start loading the texture asynchronously.

                // First get a free asset session.
                AssetSession _assetSession = mAssetManager.GetNewSession();

                // Create a request batch.
                mRequestBatch = new AssetRequestBatch(_assetSession);
                mTexture = new ReferenceObject<Texture2D>(null);

                // Add the texture to be loaded. We can add multiple files to be loaded asynchronously here.
                mRequestBatch.AddItem<Texture2D>(mTexture, "Granny");

                // Add the request batch to the asset manager
                mAssetManager.AddRequestBatch(mRequestBatch);

                // Flush the session so that the content starts loading.
                mAssetManager.FlushRequestBatches(_assetSession);
            }
            else if (mRequestBatch != null
                && _keyBoardState.IsKeyDown(Keys.Back) || _gamePadState.Buttons.B == ButtonState.Pressed)
            {
                // Unload the texture.

                // First free the session.
                mAssetManager.FreeSession(mRequestBatch.mSession);
                mRequestBatch = null;
                mTexture = null;

                // Next unload all unused assets. Only freed sessions will be unloaded.
                mAssetManager.UnloadUnusedAssets();
            }

            base.Update(gameTime);
        }
コード例 #28
0
        public void TestReferenceClone() {
            var so = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var ro = new ReferenceObject {ReferenceOne = so};

            var clone = (ReferenceObject) CopyUtils.CloneObjectTest(ro);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());

            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }
コード例 #29
0
        public void TestReferenceUpdate() {
            var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4};
            var ro = new ReferenceObject {ReferenceOne = so1};

            var clone = (ReferenceObject) CopyUtils.CloneObjectTest(ro);
            clone.ReferenceOne = so2;

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreNotSame(ro.ReferenceOne, clone.ReferenceOne);

            CopyUtils.UpdateFromClone(ro, clone);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }
コード例 #30
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ReferenceObject obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }