コード例 #1
0
 public AcceptDriverActionsAttribute(params DriverAction[] actions)
 {
     foreach (var action in actions)
     {
         Actions |= action;
     }
 }
コード例 #2
0
        public static bool AcceptDriverAction(this Type type, DriverAction action)
        {
            var attribute = type.GetCustomAttribute <AcceptDriverActionsAttribute>(false);

            if (attribute == null && action == DriverAction.None)
            {
                return(true);
            }

            return(attribute != null && attribute.Actions.HasFlag(action));
        }
コード例 #3
0
        public static object InvokeActionMethod(this IDDRef objRef, DriverAction action, params object[] objects)
        {
            var method = objRef.GetActionMethod(action);

            if (method == null)
            {
                return(null);
            }

            return(method.Invoke(objRef, objects));
        }
コード例 #4
0
        public static Object GetRefObj(this IDDEntity domainObj, string key, DriverAction action = DriverAction.None)
        {
            var refType = domainObj.GetRefType(key, action);

            if (refType == null)
            {
                return(null);
            }

            return(refType.CreateInstance());
        }
コード例 #5
0
 internal override void Try(DriverAction action)
 {
     if (!init)
     {
         throw new Exception("ContainerScope not initialized.");
     }
     if (_element != null)
     {
         _element.Try(action);
     }
     RetryUntilTimeout(action);
 }
コード例 #6
0
    public void NextAction()
    {
        if (pathfinding == null)
        {
            Start();
        }
        switch (action)
        {
        case DriverAction.goingToGetStack:
            if (truck.boxStacks.Count > 0)
            {
                if (pathfinding.indoors)
                {
                    StoreObjectFunction_Doorway door = dm.dispensary.Main_c.GetRandomEntryDoor();
                    pathfinding.GetIndoorPath(door.transform.position, ExitDispensary);
                }
                else
                {
                    pathfinding.GetOutdoorPath(truck.vehicleLoadingPosition.transform.position, PickupStack);
                }
            }
            else
            {
                action = DriverAction.goingToTruck;
                NextAction();
            }
            break;

        case DriverAction.droppingOffStack:
            if (!pathfinding.indoors)
            {
                StoreObjectFunction_Doorway door = dm.dispensary.Main_c.GetRandomEntryDoor();
                pathfinding.GetOutdoorPath(door.transform.position, EnterDispensary);
            }
            else
            {
                pathfinding.GetIndoorPath(currentStack.boxStackPosition, DropStack);
            }
            break;

        case DriverAction.goingToTruck:
            if (pathfinding.indoors)
            {
                StoreObjectFunction_Doorway door = dm.dispensary.Main_c.GetRandomEntryDoor();
                pathfinding.GetIndoorPath(door.transform.position, ExitDispensary);
            }
            else
            {
                pathfinding.GetOutdoorPath(truck.vehicleEnterExitPosition.transform.position, EnterTruck);
            }
            break;
        }
    }
コード例 #7
0
ファイル: Driver.cs プロジェクト: manuelcdr/MentalClean
        public static Type GetRefType(string key, string typeName, DriverAction action = DriverAction.None)
        {
            var listTypeName = typeName + action.ToString();

            if (ListedReferenceTypes[key].ContainsKey(listTypeName))
            {
                return(ListedReferenceTypes[key].GetValueOrDefault(listTypeName));
            }

            var domainType = GetDomainType(typeName);

            return(GetRefType(key, domainType, action));
        }
コード例 #8
0
        /// <summary>
        /// Registers the given driver with the {@code DriverManager}.
        /// A newly-loaded driver class should call
        /// the method {@code registerDriver} to make itself
        /// known to the {@code DriverManager}. If the driver is currently
        /// registered, no action is taken.
        /// </summary>
        /// <param name="driver"> the new JDBC Driver that is to be registered with the
        ///               {@code DriverManager} </param>
        /// <param name="da">     the {@code DriverAction} implementation to be used when
        ///               {@code DriverManager#deregisterDriver} is called </param>
        /// <exception cref="SQLException"> if a database access error occurs </exception>
        /// <exception cref="NullPointerException"> if {@code driver} is null
        /// @since 1.8 </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static synchronized void registerDriver(java.sql.Driver driver, DriverAction da) throws SQLException
        public static void RegisterDriver(java.sql.Driver driver, DriverAction da)
        {
            lock (typeof(DriverManager))
            {
                /* Register the driver if it has not already been added to our list */
                if (driver != null)
                {
                    RegisteredDrivers.AddIfAbsent(new DriverInfo(driver, da));
                }
                else
                {
                    // This is for compatibility with the original DriverManager
                    throw new NullPointerException();
                }

                Println("registerDriver: " + driver);
            }
        }
コード例 #9
0
    public bool DropStack()
    {
        action = DriverAction.goingToGetStack;
        currentStack.handTruck = null;
        currentStack.SetParent(null);
        currentStack.SortStack(currentStack.boxStackPosition, true, true);
        currentStack.droppedOff = true;
        dm.dispensary.inventory.AddLooseBoxStack(currentStack);

        /*foreach (Box box in currentStack.boxList)
         * {
         *  StorageBox storageBox = (StorageBox)box.product;
         *  dm.dispensary.inventory.AddLooseBox(storageBox);
         * }*/
        dm.dispensary.inventory.RefreshInventoryList(false);
        handTruck.Tip(true);
        NextAction();
        return(true);
    }
コード例 #10
0
ファイル: Driver.cs プロジェクト: manuelcdr/MentalClean
        public static Type GetRefType(string key, Type domainType, DriverAction action = DriverAction.None)
        {
            if (domainType == null)
            {
                return(null);
            }

            var listTypeName = domainType.Name + action.ToString();

            if (ListedReferenceTypes[key].ContainsKey(listTypeName))
            {
                return(ListedReferenceTypes[key].GetValueOrDefault(listTypeName));
            }

            var type = GetRefTypes(key).FindRefType(domainType, action);

            ListedReferenceTypes[key].Add(listTypeName, type);
            return(type);
        }
コード例 #11
0
        public static MethodInfo GetActionMethod(this Type refType, DriverAction action)
        {
            var methods = refType.GetMethods();

            foreach (var method in methods)
            {
                var attribute = method.GetCustomAttribute <AcceptDriverActionsAttribute>(false);
                if (attribute == null)
                {
                    continue;
                }

                if (attribute.Actions.HasFlag(action))
                {
                    return(method);
                }
            }
            return(null);
        }
コード例 #12
0
        public AcceptDriverActionsAttribute(bool none = false)
        {
            if (none)
            {
                Actions |= DriverAction.None;
            }
            else
            {
                foreach (var action in Enum.GetValues(typeof(DriverAction)))
                {
                    if (action.Equals(DriverAction.None))
                    {
                        continue;
                    }

                    Actions |= (DriverAction)action;
                }
            }
        }
コード例 #13
0
    public bool PickupStack()
    {
        action = DriverAction.droppingOffStack;
        if (handTruck == null)
        {
            GameObject handTruckGO = Instantiate(db.GetStoreObject("Hand Truck").gameObject_);
            handTruck        = handTruckGO.GetComponent <Handtruck>();
            handTruck.driver = this;
            handTruckGO.transform.position = handTruckPosition.transform.position;
        }
        BoxStack newStack = truck.UnloadStack();

        currentStack       = newStack;
        newStack.handTruck = handTruck;
        newStack.SetParent(handTruck.gameObject.transform);
        handTruck.LoadBoxes(newStack);
        handTruck.transform.parent = transform;
        handTruck.Tip(true);
        NextAction();
        return(true);
    }
コード例 #14
0
        public static Type FindRefType(this IEnumerable <Type> types, Type domainType, DriverAction action = DriverAction.None)
        {
            var likeTypes = types
                            .Where(t => t.GetCustomAttribute <EntityReferenceAttribute>() != null);

            foreach (var type in likeTypes)
            {
                if (!type.HasDomainType(domainType))
                {
                    continue;
                }

                if (action == DriverAction.None || type.AcceptDriverAction(action))
                {
                    return(type);
                }
            }

            return(null);
        }
コード例 #15
0
        public static object InvokeActionMethod(this Type refType, DriverAction action, params object[] @params)
        {
            var objRef = refType.CreateInstance() as IDDRef;

            return(objRef.InvokeActionMethod(action, @params));
        }
コード例 #16
0
        public void DriveSafelySwitch_Red_Returns_Stop()
        {
            DriverAction action = Flow.DriveSafelySwitch(LightColor.Red);

            Assert.AreEqual(DriverAction.Stop, action);
        }
コード例 #17
0
 internal abstract void Try(DriverAction action);
コード例 #18
0
        public void DriveSafelySwitch_Other_Returns_Unknown()
        {
            DriverAction action = Flow.DriveSafelySwitch((LightColor)42);

            Assert.AreEqual(DriverAction.Unknown, action);
        }
コード例 #19
0
 internal override void Try(DriverAction action)
 {
     RetryUntilTimeout(action);
 }
コード例 #20
0
ファイル: SnapshotElementScope.cs プロジェクト: hnhan/coypu
 internal override void Try(DriverAction action)
 {
     action.Act();
 }
コード例 #21
0
 internal DriverInfo(Driver driver, DriverAction action)
 {
     this.Driver = driver;
     Da          = action;
 }
コード例 #22
0
ファイル: Driver.cs プロジェクト: manuelcdr/MentalClean
 public static MethodInfo GetActionMethod(Type refType, DriverAction action)
 {
     return(refType.GetActionMethod(action));
 }
コード例 #23
0
ファイル: Driver.cs プロジェクト: manuelcdr/MentalClean
 public static object InoveActionMethod(Type refType, DriverAction action, params object[] objects)
 {
     return(refType.InvokeActionMethod(action, objects));
 }
コード例 #24
0
        public void DriveSafelySwitch_Yellow_Returns_StopIfSafe()
        {
            DriverAction action = Flow.DriveSafelySwitch(LightColor.Yellow);

            Assert.AreEqual(DriverAction.StopIfSafe, action);
        }
コード例 #25
0
 public static Type GetRefType(this IDDEntity entity, string key, DriverAction action = DriverAction.None)
 {
     return(Driver.GetRefType(key, entity.GetType(), action));
 }
コード例 #26
0
 public static MethodInfo GetActionMethod(this IDDRef objRef, DriverAction action)
 {
     return(objRef.GetType().GetActionMethod(action));
 }
コード例 #27
0
        public void DriveSafelySwitch_Green_Returns_ProceedWithCaution()
        {
            DriverAction action = Flow.DriveSafelySwitch(LightColor.Green);

            Assert.AreEqual(DriverAction.ProceedWithCaution, action);
        }