示例#1
0
        public bool AddCollection(Collection collection, AddMode addMode)
        {
            if (IsNameUsed(collection.Name))
            {
                switch (addMode)
                {
                case AddMode.Skip:
                    return(false);

                case AddMode.Merge:
                    GetCollectionByName(collection.Name).MergeCollection(collection);
                    return(true);

                case AddMode.Overwrite:
                    RemoveCollection(collection.Name);
                    Collections.Add(collection);
                    return(true);

                default:
                    return(false);
                }
            }
            Collections.Add(collection);
            return(true);
        }
示例#2
0
        public bool AddBeatmapScores(BeatmapScores beatmapScores, AddMode addMode)
        {
            if (IsBeatmapScoresPresent(beatmapScores.MD5))
            {
                switch (addMode)
                {
                case AddMode.Skip:
                    return(false);

                case AddMode.Merge:
                    GetBeatmapScoresByMD5(beatmapScores.MD5).MergeBeatmapScores(beatmapScores);
                    return(true);

                case AddMode.Overwrite:
                    RemoveBeatmapScores(GetBeatmapScoresByMD5(beatmapScores.MD5));
                    Beatmaps.Add(beatmapScores);
                    return(true);

                default:
                    return(false);
                }
            }
            Beatmaps.Add(beatmapScores);
            return(true);
        }
示例#3
0
 public void Merge(CollectionDb collectionDb, AddMode addMode)
 {
     foreach (Collection collection in collectionDb.Collections)
     {
         AddCollection(collection, addMode);
     }
 }
 public override int GetBehaviorHashCode()
 {
     return(AddMode.GetHashCode() ^
            AinitValue.GetHashCode() ^
            Atype.GetHashCode() ^
            Awidth ^
            Bconstant.GetHashCode() ^
            BorrowSense.GetHashCode() ^
            Btype.GetHashCode() ^
            Bvalue.GetHashCode() ^
            Bwidth ^
            BypassCePriority.GetHashCode() ^
            BypassSense.GetHashCode() ^
            ConstantInputValue.GetHashCode() ^
            Generator.GetHashCode() ^
            HasBypass.GetHashCode() ^
            HasCarryIn.GetHashCode() ^
            HasCarryOut.GetHashCode() ^
            HasCE.GetHashCode() ^
            HasConstantInput.GetHashCode() ^
            HasSCLR.GetHashCode() ^
            HasSSET.GetHashCode() ^
            Implementation.GetHashCode() ^
            Latency.GetHashCode() ^
            LatencyConfiguration.GetHashCode() ^
            OutWidth);
 }
        private void AddChunkType(string chunkId, Type chunkType, AddMode addMode)
        {
            Check.IfArgumentNullOrEmpty(chunkId, nameof(chunkId));
            Check.IfArgumentNull(chunkType, nameof(chunkType));

            if (_chunkMap.ContainsKey(chunkId))
            {
                switch (addMode)
                {
                case AddMode.ThrowIfExists:
                    throw new ChunkFileException($"The Chunk Id {chunkId} is already registered.");

                case AddMode.SkipIfExists:
                    break;

                case AddMode.OverwriteExisting:
                    _chunkMap[chunkId] = chunkType;
                    break;

                default:
                    throw new NotImplementedException("Illegal AddMode Enum value.");
                }
            }
            else
            {
                _chunkMap.Add(chunkId, chunkType);
            }
        }
示例#6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (addMode == AddMode.Add || reserveInfo == null)
            {
                addMode          = AddMode.Add;
                reserveInfo      = null;
                ReserveMode      = UIReserveMode.Program;
                CanSelectAutoAdd = false;

                if (comboBox_service.Items.Count > 0)
                {
                    comboBox_service.SelectedIndex = 0;
                }

                SetAddMode(AddMode.Add);
                SetReserveTime(DateTime.Now.AddMinutes(1), DateTime.Now.AddMinutes(31));
                reserveInfo = new ReserveData();
            }
            else
            {
                ReserveMode      = GetReserveModeFromInfo();
                CanSelectAutoAdd = (ReserveMode == UIReserveMode.EPGAuto);

                SetReserveTimeInfo(reserveInfo);
            }

            ResetProgramContent();                  //番組詳細を初期表示
            tabControl.SelectedIndex = openMode;

            initialized = true;
        }
示例#7
0
文件: App.cs 项目: lemj2710/FSharpFun
        public static void StartApp(string[] args)
        {
            switch (args[0])
            {
            case "addMode":
                var mode = new AddMode();
                mode.Execute();
                break;

            case "editMode":
                (new EditMode()).DoIt();
                break;

            case "readMode":
                (new ReadMode()).DoThat(args, args[1]);
                break;

            case "godMode":
                System.Console.WriteLine("Your not god!!");
                break;

            default:
                System.Console.WriteLine("Parameter error");
                break;
            }
        }
示例#8
0
        public void AddPath(SKPath other, AddMode mode = AddMode.Append)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            SkiaApi.sk_path_add_path(Handle, other.Handle, mode);
        }
示例#9
0
文件: Map.cs 项目: Kukks/CryBits
        private static void Calculate_SE(byte x, byte y, byte Layer_Num, byte Layer_Type)
        {
            bool[]  Tile = new bool[4];
            AddMode Mode = AddMode.None;

            // Verifica se existe algo para modificar nos azulejos em volta (Sul, Oeste, Sudeste)
            if (Check(x, y, x, y + 1, Layer_Num, Layer_Type))
            {
                Tile[1] = true;
            }
            if (Check(x, y, x + 1, y + 1, Layer_Num, Layer_Type))
            {
                Tile[2] = true;
            }
            if (Check(x, y, x + 1, y, Layer_Num, Layer_Type))
            {
                Tile[3] = true;
            }

            // Forma que será adicionado o mini azulejo
            if (!Tile[1] && !Tile[3])
            {
                Mode = AddMode.Inside;
            }
            if (!Tile[1] && Tile[3])
            {
                Mode = AddMode.Horizontal;
            }
            if (Tile[1] && !Tile[3])
            {
                Mode = AddMode.Vertical;
            }
            if (Tile[1] && !Tile[2] && Tile[3])
            {
                Mode = AddMode.Exterior;
            }
            if (Tile[1] && Tile[2] && Tile[3])
            {
                Mode = AddMode.Fill;
            }

            // Define o mini azulejo
            switch (Mode)
            {
            case AddMode.Inside: Set(x, y, Layer_Num, Layer_Type, 3, "t"); break;

            case AddMode.Exterior: Set(x, y, Layer_Num, Layer_Type, 3, "d"); break;

            case AddMode.Horizontal: Set(x, y, Layer_Num, Layer_Type, 3, "p"); break;

            case AddMode.Vertical: Set(x, y, Layer_Num, Layer_Type, 3, "l"); break;

            case AddMode.Fill: Set(x, y, Layer_Num, Layer_Type, 3, "h"); break;
            }
        }
示例#10
0
 //+++++++++++++++  方法开始 +++++++++++++++++++++++++
 /// <summary>
 /// 构造窗口
 /// </summary>
 /// <param name="name">原始名称</param>
 /// <param name="mark">备注名称</param>
 /// <param name="dir">所在目录</param>
 /// <param name="owner">父窗口</param>
 public FavoriteAddWnd(string name, AddMode mode = AddMode.Add, string mark = null, string dir = null, string siteName = null, Window owner = null)
 {
     InitializeComponent();
     Owner    = owner;
     ThisWnd  = this;
     addMode  = mode;
     editName = name;
     editMark = mark;
     editDir  = dir;
     editSite = siteName;
 }
        public LandformResource Read(IEnumerable <Modification> modifications, AddMode addMode)
        {
            LandformResource resource = new LandformResource();

            foreach (var modification in modifications)
            {
                var descriptions = Read(modification);
                resource.Add(modification, descriptions.EnumerateDescription(), addMode);
            }

            return(resource);
        }
        /// <summary>
        /// Scans the <paramref name="assembly"/> for types that have the
        /// <see cref="ChunkAttribute"/> applied and adds them to the factory.
        /// </summary>
        /// <param name="assembly">Must not be null.</param>
        /// <param name="replace">If true the Type found in the <paramref name="assembly"/> will replace
        /// an already registered type.</param>
        public void AddChunksFrom(Assembly assembly, AddMode addMode)
        {
            Check.IfArgumentNull(assembly, nameof(assembly));

            var result = from type in assembly.GetTypes()
                         where type.IsClass && type.IsChunk()
                         select new { ChunkId = ChunkAttribute.GetChunkId(type), Type = type };

            foreach (var item in result)
            {
                AddChunkType(item.ChunkId, item.Type, addMode);
            }
        }
示例#13
0
        public void AddRecoil(float amount, AddMode mode = AddMode.Add)
        {
            switch (mode)
            {
            case AddMode.Add:
                CurrentVelocity += amount;
                break;

            case AddMode.Set:
                CurrentVelocity = amount;
                break;
            }
        }
        /// <summary>
        /// Adds an item to list based on the selected option in AddMode enumeration.
        /// </summary>
        /// <param name="value">Item to add. Generic type.</param>
        /// <param name="addMode">Option to add an item.</param>
        public void Add(T value, AddMode addMode)
        {
            switch (addMode)
            {
            case AddMode.FirstPosition:
                AddFirst(new SinglyLinkedListNode <T>(value));
                break;

            case AddMode.LastPosition:
                AddLast(new SinglyLinkedListNode <T>(value));
                break;
            }
        }
示例#15
0
        private void SetAddMode(AddMode mode)
        {
            addMode = mode;
            switch (mode)
            {
            case AddMode.Add:
                this.Title = "予約登録";
                button_chg_reserve.Content = "予約";
                mBinds.SetCommandToButton(button_chg_reserve, EpgCmds.AddInDialog);
                button_del_reserve.Visibility = Visibility.Hidden;
                break;

            case AddMode.Re_Add:
                button_chg_reserve.Content = "再予約";
                mBinds.SetCommandToButton(button_chg_reserve, EpgCmds.AddInDialog);
                //なお、削除ボタンはCanExeの判定でグレーアウトする。
                break;
            }
        }
示例#16
0
    public void AddCommand(Command command, AddMode addMode = AddMode.Standard)
    {
        DebugStringUpdate(command);
        if (debugMode)
        {
            Debug.Log("Adding " + debugString + ", count: " + commands.Count.ToString());
        }
        command.RegisterFinishCallback(Update);

        switch (addMode)
        {
        case AddMode.Standard:
            commands.AddLast(command);
            break;

        case AddMode.Priority:
            LinkedListNode <Command> i = commands.First;
            bool added = false;

            while (i.Value.State != CommandState.Pending)
            {
                if (i == commands.Last)
                {
                    commands.AddLast(command);
                    added = true;
                    break;
                }
                i = i.Next;
            }
            if (!added)
            {
                commands.AddBefore(i, command);
            }
            break;

        case AddMode.Instant:
            commands.AddFirst(command);
            break;
        }

        Update();
    }
示例#17
0
        public bool Add(string name, object value, AddMode addMode)
        {
            bool alreadyExists = Objects.ContainsKey(name);

            if (alreadyExists)
            {
                if (addMode == AddMode.Error)
                {
                    throw new Exception($"key {name} already exists");
                }
                else if (addMode == AddMode.Override)
                {
                    Objects[name] = value;
                }
            }
            else
            {
                Objects[name] = value;
            }
            return(alreadyExists);
        }
示例#18
0
        public void Add(File file, AddMode addMode = AddMode.NewOrReplace)
        {
            File existingFile;

            this.files.TryGetValue(file.Name, out existingFile);

            if (existingFile != null && addMode == AddMode.New)
            {
                throw new ArgumentException("A file with this name already exists", "file");
            }
            else if (existingFile == null && addMode == AddMode.Replace)
            {
                throw new ArgumentException("No such file exists", "file");
            }

            if (existingFile != null)
            {
                this.files.Remove(file.Name);
            }
            this.files.Add(file.Name, file);
        }
示例#19
0
        public void Add(Folder folder, AddMode addMode = AddMode.NewOrReplace)
        {
            Folder existingFolder;

            this.folders.TryGetValue(folder.Name, out existingFolder);

            if (existingFolder != null && addMode == AddMode.New)
            {
                throw new ArgumentException("A folder with this name already exists", "folder");
            }
            else if (existingFolder == null && addMode == AddMode.Replace)
            {
                throw new ArgumentException("No such folder exists", "folder");
            }

            if (existingFolder != null)
            {
                this.folders.Remove(folder.Name);
            }
            this.folders.Add(folder.Name, folder);
        }
示例#20
0
        private void SetAddMode(AddMode mode)
        {
            addMode = mode;
            switch (mode)
            {
            case AddMode.Add:
                if (KeepWin == false)
                {
                    button_chg_reserve.Visibility = Visibility.Collapsed;
                    button_del_reserve.Visibility = Visibility.Collapsed;
                }
                break;

            case AddMode.Re_Add:
                reserveInfo.ReserveID             = 0;
                checkBox_releaseAutoAdd.IsChecked = false;
                text_Status.ItemsSource           = null;
                label_errStar.Content             = null;
                //変更及び削除ボタンはCanExeの判定でグレーアウトする。
                break;
            }
        }
示例#21
0
        public bool AddBeatmap(Beatmap beatmap, AddMode addMode)
        {
            if (IsBeatmapPresent(beatmap.MD5Beatmap))
            {
                switch (addMode)
                {
                case AddMode.Skip:
                    return(false);

                case AddMode.Merge:
                    return(false);

                case AddMode.Overwrite:
                    RemoveBeatmap(beatmap.MD5Beatmap);
                    break;

                default:
                    return(false);
                }
            }
            Beatmaps.Add(beatmap);
            return(true);
        }
        public void AddArray(T[] array, T currentValue)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            CheckThrowObjectDisposedException();

            _addMode        = AddMode.Array;
            _availableArray = array;
            _currentValue   = currentValue;

            _comboBoxClearDatas();

            if (Equals(currentValue, default(T)))
            {
                if (_availableArray.Length != 0)
                {
                    _currentValue  = _availableArray[0];
                    _comboBox.Text = _createDataByFormatText(_currentValue);
                }
                else
                {
                    _comboBox.Text = _emptyText;
                }
            }
            else
            {
                _comboBox.Text = _createDataByFormatText(currentValue);
            }

            if (_availableArray.Length != 0)
            {
                _subscribeComboBoxGotFocusEvents(true);
            }
        }
        public void AddCollection(BaseFastCollection <T> collection, T currentValue)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            CheckThrowObjectDisposedException();

            _addMode = AddMode.FastCollection;
            _availableFastCollection = collection;
            _currentValue            = currentValue;

            _comboBoxClearDatas();

            if (Equals(currentValue, default(T)))
            {
                if (_availableFastCollection.Count != 0)
                {
                    _currentValue  = _availableFastCollection[0];
                    _comboBox.Text = _createDataByFormatText(_currentValue);
                }
                else
                {
                    _comboBoxTextEmptyValue();
                }
            }
            else
            {
                _comboBox.Text = _createDataByFormatText(currentValue);
            }

            if (_availableFastCollection.Count != 0)
            {
                _subscribeComboBoxGotFocusEvents(true);
            }
        }
示例#24
0
        public override void ChangeData(object data)
        {
            var info = data as ReserveData;

            if (info == null)
            {
                return;
            }

            if (reserveInfo != info)
            {
                addMode     = AddMode.Change;
                reserveInfo = info.DeepClone();
            }
            recSettingView.SetViewMode(!reserveInfo.IsManual);
            recSettingView.SetDefSetting(reserveInfo.RecSetting);
            checkBox_releaseAutoAdd.IsChecked = false;
            checkBox_releaseAutoAdd.IsEnabled = reserveInfo.IsAutoAdded;

            SetAddMode(addMode);
            SetResModeProgram(reserveInfo.IsManual);
            SetReserveTimeInfo(reserveInfo);

            //番組詳細タブを初期化
            richTextBox_descInfo.Document = CommonManager.ConvertDisplayText(null, null);
            eventInfoNow   = null;
            resInfoDisplay = null;

            tabControl.SelectedIndex = -1;
            tabControl.SelectedIndex = selectedTab;

            //エラー状況の表示など
            CheckMultiReserve();
            UpdateErrStatus();
            UpdateViewSelection(0);
            SetReserveTabHeader(false);
        }
示例#25
0
 public void AddChunkAtPoints(TerrainPoint[] points, TerrainChunk chunk, AddMode mode = AddMode.Add) {
   for (int i = 0; i < points.Length; i++) {
     int x = points[i].x;
     int y = points[i].y;
     this.AddChunk(chunk, x - chunk.GetWidth() / 2, y - chunk.GetHeight() / 2, mode);
   }
 }
示例#26
0
 static Int64[] GetAddInstruction(AddMode addMode, Int64 registerNumber, Int64 target)
 {
     Int64[] instruction=new Int64[4];
     instruction[0]=1;
     instruction[1]=(Int64)addMode;
     instruction[2]=registerNumber;
     instruction[3]=target;
     return instruction;
 }
示例#27
0
 public void AddPath(SKPath other, AddMode mode)
 {
     AddPath(other, (SKPathAddMode)mode);
 }
示例#28
0
 /// <summary>
 /// Byte数可変のコンストラクタ
 /// </summary>
 /// <param name="bytes"></param>
 public FetchByte(int bytes, AddMode mode)
 {
     this.Bytes = bytes;
     this.Mode  = mode;
 }
示例#29
0
 public void AddPath(SKPath other, ref SKMatrix matrix, AddMode mode)
 {
     AddPath(other, ref matrix, (SKPathAddMode)mode);
 }
示例#30
0
        private static void Build(AddMode mode, string tableName, string csvFilePath, int maximumCount, string columns, string settingsJsonPath = null)
        {
            Stopwatch w = Stopwatch.StartNew();

            Console.WriteLine("{0} Arriba table '{1}' from '{2}'...", mode, tableName, csvFilePath);

            IList <string> columnNames = null;

            if (!String.IsNullOrEmpty(columns))
            {
                columnNames = SplitAndTrim(columns);
            }

            // Build or load table
            Table table;

            if (mode == AddMode.Build)
            {
                table = new Table(tableName, maximumCount);
            }
            else
            {
                table = new Table();
                table.Load(tableName);
            }

            // Configure table
            if (!String.IsNullOrEmpty(settingsJsonPath))
            {
                SetSettings(table, LoadSettings(settingsJsonPath));
            }

            // Always add missing columns. Add rows only when not in 'decorate' mode
            AddOrUpdateOptions options = new AddOrUpdateOptions();

            options.AddMissingColumns = true;
            options.Mode = (mode == AddMode.Decorate ? AddOrUpdateMode.UpdateAndIgnoreAdds: AddOrUpdateMode.AddOrUpdate);

            using (CsvReader reader = new CsvReader(csvFilePath))
            {
                long rowsImported = 0;

                foreach (DataBlock block in reader.ReadAsDataBlockBatch(BatchSize))
                {
                    DataBlock toInsert = block;
                    if (columnNames != null)
                    {
                        toInsert = toInsert.StripToColumns(columnNames);
                    }

                    table.AddOrUpdate(toInsert, options);

                    rowsImported += toInsert.RowCount;
                    Console.Write(".");
                }

                Console.WriteLine();
                Console.WriteLine("Added {0:n0} rows. Saving...", rowsImported);
            }

            table.Save();
            w.Stop();
            Console.WriteLine("Done in {0}.", w.Elapsed.ToFriendlyString());
        }
示例#31
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (addMode == AddMode.Add || reserveInfo == null)
            {
                addMode = AddMode.Add;
                reserveInfo = null;
                ReserveMode = UIReserveMode.Program;
                CanSelectAutoAdd = false;

                if (comboBox_service.Items.Count > 0)
                {
                    comboBox_service.SelectedIndex = 0;
                }

                SetAddMode(AddMode.Add);
                SetReserveTime(DateTime.Now.AddMinutes(1), DateTime.Now.AddMinutes(31));
                reserveInfo = new ReserveData();
            }
            else
            {
                ReserveMode = GetReserveModeFromInfo();
                CanSelectAutoAdd = (ReserveMode == UIReserveMode.EPGAuto);

                SetReserveTimeInfo(reserveInfo);
            }

            ResetProgramContent();                  //番組詳細を初期表示
            tabControl.SelectedIndex = openMode;

            initialized = true;
        }
示例#32
0
		public void AddPath (SKPath other, AddMode mode = AddMode.Append)
		{
			if (other == null)
				throw new ArgumentNullException (nameof (other));
			
			SkiaApi.sk_path_add_path (Handle, other.Handle, mode);
		}
示例#33
0
        public XlfTransUnit AddTransUnit(string id, string source, string target, AddMode addMode, XlfDialect dialect)
        {
            if (addMode != AddMode.DontCheckExisting && TryGetTransUnit(id, dialect, out XlfTransUnit resultUnit))
            {
                switch (addMode)
                {
                case AddMode.FailIfExists:
                    throw new InvalidOperationException($"There is already a trans-unit with id={id}");

                case AddMode.SkipExisting:
                    return(resultUnit);

                default:
                case AddMode.UpdateExisting:
                    resultUnit.Source = source;

                    // only update target value if there is already a target element present
                    if (resultUnit.Target != null)
                    {
                        resultUnit.Target = target;
                    }

                    return(resultUnit);
                }
            }

            var n = new XElement(this.ns + ElementTransUnit);

            n.SetAttributeValue("id", id);
            n.SetAttributeValue("translate", "yes");
            n.SetAttributeValue(XNamespace.Xml + "space", "preserve");
            var transUnits = this.node.Descendants(this.ns + ElementTransUnit).ToList();

            if (transUnits.Any())
            {
                transUnits.Last().AddAfterSelf(n);
            }
            else
            {
                var bodyElements = this.node.Descendants(this.ns + ElementBody).ToList();

                XElement body;

                if (bodyElements.Any())
                {
                    body = bodyElements.First();
                }
                else
                {
                    body = new XElement(this.ns + ElementBody);
                    this.node.Add(body);
                }

                body.Add(n);
            }

            if (dialect == XlfDialect.RCWinTrans11)
            {
                var unit = new XlfTransUnit(n, this.ns, IdNone, source, target)
                {
                    TargetState = "new"
                };
                unit.Optional.Resname = id;
                return(unit);
            }
            else
            {
                return(new XlfTransUnit(n, this.ns, id, source, target)
                {
                    TargetState = "new"
                });
            }
        }
示例#34
0
 public void SetAddReserveMode()
 {
     addMode = AddMode.Add;
 }
示例#35
0
    public void AddChunk(TerrainChunk chunk, int start_x, int start_y, AddMode mode = AddMode.Add) {
      int minWidth = Mathf.Min(chunk.data.GetLength(0), this.data.GetLength(0) - start_x);
      int minHeight = Mathf.Min(chunk.data.GetLength(1), this.data.GetLength(1) - start_y);
      float centerValue = this.data[start_x + chunk.GetWidth() / 2, start_y + chunk.GetHeight() / 2];
      for (int x = 0; x < minWidth; x++) {
        for (int y = 0; y < minHeight; y++) {
          int xc = start_x + x;
          int yc = start_y + y;
          if (xc < 0 || yc < 0) {
            continue;
          }

          switch (mode) {
            case AddMode.Add:
              this.data[xc, yc] = this.data[xc, yc] + chunk.data[x, y];

              if (chunk.data[x, y] != 0) {
                for (int layer = 0; layer < TEXTURE_COUNT; layer++) {
                  this.textureData[xc, yc, layer] = this.textureData[xc, yc, layer] + chunk.textureData[x, y, layer] * 4;
                }
              }
            break;
            case AddMode.Max:
              if (chunk.data[x, y] != 0 && chunk.data[x, y] > this.data[xc, yc]) {
                for (int layer = 0; layer < TEXTURE_COUNT; layer++) {
                  this.textureData[xc, yc, layer] = chunk.textureData[x, y, layer];
                }
              }

              this.data[xc, yc] = Mathf.Max(this.data[xc, yc], chunk.data[x, y]);
            break;
            case AddMode.Min:
              this.data[xc, yc] = Mathf.Min(this.data[xc, yc], chunk.data[x, y]);
            break;
            case AddMode.RelaMin:
              this.data[xc, yc] = Mathf.Min(this.data[xc, yc], centerValue - chunk.data[x, y]);
            break;
          }
        }
      }
    }
        // MODIFIED AddSystemToPlayerLoopList from Unity.Entities.ScriptBehaviourUpdateOrder (ECS)
        //
        // => adds an update function to the Unity internal update type.
        // => Unity has different update loops:
        //    https://medium.com/@thebeardphantom/unity-2018-and-playerloop-5c46a12a677
        //      EarlyUpdate
        //      FixedUpdate
        //      PreUpdate
        //      Update
        //      PreLateUpdate
        //      PostLateUpdate
        //
        // function: the custom update function to add
        //           IMPORTANT: according to a comment in Unity.Entities.ScriptBehaviourUpdateOrder,
        //                      the UpdateFunction can not be virtual because
        //                      Mono 4.6 has problems invoking virtual methods
        //                      as delegates from native!
        // ownerType: the .type to fill in so it's obvious who the new function
        //            belongs to. seems to be mostly for debugging. pass any.
        // addMode: prepend or append to update list
        internal static bool AddToPlayerLoop(PlayerLoopSystem.UpdateFunction function, Type ownerType, ref PlayerLoopSystem playerLoop, Type playerLoopSystemType, AddMode addMode)
        {
            // did we find the type? e.g. EarlyUpdate/PreLateUpdate/etc.
            if (playerLoop.type == playerLoopSystemType)
            {
                // debugging
                //Debug.Log($"Found playerLoop of type {playerLoop.type} with {playerLoop.subSystemList.Length} Functions:");
                //foreach (PlayerLoopSystem sys in playerLoop.subSystemList)
                //    Debug.Log($"  ->{sys.type}");

                // resize & expand subSystemList to fit one more entry
                int oldListLength = (playerLoop.subSystemList != null) ? playerLoop.subSystemList.Length : 0;
                Array.Resize(ref playerLoop.subSystemList, oldListLength + 1);

                // IMPORTANT: always insert a FRESH PlayerLoopSystem!
                // We CAN NOT resize and then OVERWRITE an entry's type/loop.
                // => PlayerLoopSystem has native IntPtr loop members
                // => forgetting to clear those would cause undefined behaviour!
                // see also: https://github.com/vis2k/Mirror/pull/2652
                PlayerLoopSystem system = new PlayerLoopSystem {
                    type           = ownerType,
                    updateDelegate = function
                };

                // prepend our custom loop to the beginning
                if (addMode == AddMode.Beginning)
                {
                    // shift to the right, write into first array element
                    Array.Copy(playerLoop.subSystemList, 0, playerLoop.subSystemList, 1, playerLoop.subSystemList.Length - 1);
                    playerLoop.subSystemList[0] = system;
                }
                // append our custom loop to the end
                else if (addMode == AddMode.End)
                {
                    // simply write into last array element
                    playerLoop.subSystemList[oldListLength] = system;
                }

                // debugging
                //Debug.Log($"New playerLoop of type {playerLoop.type} with {playerLoop.subSystemList.Length} Functions:");
                //foreach (PlayerLoopSystem sys in playerLoop.subSystemList)
                //    Debug.Log($"  ->{sys.type}");

                return(true);
            }

            // recursively keep looking
            if (playerLoop.subSystemList != null)
            {
                for (int i = 0; i < playerLoop.subSystemList.Length; ++i)
                {
                    if (AddToPlayerLoop(function, ownerType, ref playerLoop.subSystemList[i], playerLoopSystemType, addMode))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#37
0
 private void SetAddMode(AddMode mode)
 {
     addMode = mode;
     switch (mode)
     {
         case AddMode.Add:
             this.Title = "予約登録";
             button_chg_reserve.Content = "予約";
             mBinds.SetCommandToButton(button_chg_reserve, EpgCmds.AddInDialog);
             button_del_reserve.Visibility = Visibility.Hidden;
             break;
         case AddMode.Re_Add:
             button_chg_reserve.Content = "再予約";
             mBinds.SetCommandToButton(button_chg_reserve, EpgCmds.AddInDialog);
             //なお、削除ボタンはCanExeの判定でグレーアウトする。
             break;
     }
 }