private void ChangesNotificationMethod(Changes option)
 {
     if (this.PropertyChanged != null)
     {
         this.PropertyChanged(this, new PropertyChangedEventArgs(option.ToString()));
     }
 }
        public TokenStream(TreeData treeData, OptionSet optionSet, TextSpan spanToFormat, AbstractTriviaDataFactory factory)
        {
            using (Logger.LogBlock(FunctionId.Formatting_TokenStreamConstruction, CancellationToken.None))
            {
                // initialize basic info
                this.factory = factory;
                this.treeData = treeData;
                this.optionSet = optionSet;

                // use some heuristics to get initial size of list rather than blindly start from default size == 4
                int sizeOfList = spanToFormat.Length / MagicTextLengthToTokensRatio;
                this.tokens = new List<SyntaxToken>(sizeOfList);
                this.tokens.AddRange(this.treeData.GetApplicableTokens(spanToFormat));

                Contract.Requires(this.TokenCount > 0);

                // initialize trivia related info
                this.changes = new Changes();
                this.cachedOriginalTriviaInfo = new TriviaData[this.TokenCount - 1];

                this.tokenToIndexMap = new Dictionary<SyntaxToken, int>(this.TokenCount);
                for (int i = 0; i < this.TokenCount; i++)
                {
                    this.tokenToIndexMap.Add(this.tokens[i], i);
                }

                // Func Cache
                this.getTriviaData = this.GetTriviaData;
                this.getOriginalTriviaData = this.GetOriginalTriviaData;
            }

            DebugCheckTokenOrder();
        }
 /// <summary>
 /// Constructor of FileData class
 /// </summary>
 public FileData(string rootPath, string fileName, string relativePath, Changes changeType, bool isFolder)
 {
     this.rootPath = rootPath;
     this.fileName = fileName;
     this.relativePath = relativePath;
     this.fileType = Path.GetExtension(fileName);
     this.changeType = changeType;
     this.isFolder = isFolder;
 }
Пример #4
0
        public async Task <Changes> GetChanges(string projectKey, string repositorySlug, string untilCommit, string sinceCommit = null, RequestOptions requestOptions = null)
        {
            string requestUrl = "";

            if (string.IsNullOrWhiteSpace(sinceCommit))
            {
                requestUrl = UrlBuilder.FormatRestApiUrl(CHANGES_UNTIL, requestOptions, projectKey, repositorySlug, untilCommit);
            }
            else
            {
                requestUrl = UrlBuilder.FormatRestApiUrl(CHANGES_UNTIL_AND_SINCE, requestOptions, projectKey, repositorySlug, untilCommit, sinceCommit);
            }

            Changes response = await _httpWorker.GetAsync <Changes>(requestUrl).ConfigureAwait(false);

            return(response);
        }
Пример #5
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is BatchChangeInventoryRequest other &&
                   ((IdempotencyKey == null && other.IdempotencyKey == null) || (IdempotencyKey?.Equals(other.IdempotencyKey) == true)) &&
                   ((Changes == null && other.Changes == null) || (Changes?.Equals(other.Changes) == true)) &&
                   ((IgnoreUnchangedCounts == null && other.IgnoreUnchangedCounts == null) || (IgnoreUnchangedCounts?.Equals(other.IgnoreUnchangedCounts) == true)));
        }
        protected override float CalculateValue(IStateNode previous, bool newTurnOn)
        {
            if (_turnOnCount > 0)
            {
                return(float.MinValue);  // our task is to turn off server not turn on
            }

            float val = previous.Value;

            val += GetTargetServerResourcesChange().GetValue();

            var change = Changes.Last();

            val += CalculateDiffForUpdatedMachineCase(change.Target.Resources + change.MigrationRequirment);

            return(val);
        }
Пример #7
0
        public async Task RemoveWhere(Predicate <T> predicate)
        {
            var oldVals       = _items.ToArray();
            var itemsToRemove = _items
                                .Select((v, i) => (index: i, value: v))
                                .Where(pair => predicate(pair.value))
                                .OrderByDescending(pair => pair.index)
                                .Select(pair => Changes.Remove(pair.index, pair.value))
                                .ToList();

            foreach (var pair in itemsToRemove)
            {
                _items.RemoveAt(pair.Index);
            }

            await Changed.Invoke(itemsToRemove.Collect(oldVals, _items));
        }
Пример #8
0
        internal WorkItemWrapper(EngineContext context, WorkItem item, bool isReadOnly)
        // we cannot reuse the code, because tracking is different
        //: this(context, item)
        {
            _context = context;

            Id = new PermanentWorkItemId(item.Id.Value);
            Changes.Add(new JsonPatchOperation()
            {
                Operation = Operation.Test,
                Path      = "/rev",
                Value     = item.Rev
            });
            _isReadOnly         = isReadOnly;
            _item               = item;
            _relationCollection = new WorkItemRelationWrapperCollection(this, _item.Relations);
            _context.Tracker.TrackRevision(this);
        }
Пример #9
0
        private void DecrementCounter(string emoteId, bool isUnicode)
        {
            if (isUnicode)
            {
                var bytes = Encoding.Unicode.GetBytes(emoteId);
                emoteId = Convert.ToBase64String(bytes);
            }

            var value = GetValue(emoteId);

            if (value == null || value.Count == 0)
            {
                return;
            }

            value.Decrement();
            Changes.Add(emoteId);
        }
Пример #10
0
        public WorkItemWrapper(EngineContext context, WorkItemWrapper template, string type)
        {
            _context = context.Track(this);

            Id = new TemporaryWorkItemId();

            _item = new WorkItem();
            _item.Fields[CoreFieldRefNames.TeamProject]  = template.TeamProject;
            _item.Fields[CoreFieldRefNames.WorkItemType] = type;
            _item.Fields[CoreFieldRefNames.Id]           = Id.Value;

            Changes.Add(new JsonPatchOperation()
            {
                Operation = Operation.Test,
                Path      = "/id",
                Value     = Id
            });
        }
Пример #11
0
        public T Value(DateTime at)
        {
            if (Changes.ContainsKey(at))
            {
                return(Changes[at]);
            }

            try
            {
                return(Changes.Where(pair => pair.Key < at).OrderBy(
                           pair => at - pair.Key
                           ).First().Value);
            }
            catch (InvalidOperationException e)
            {
                throw new ArgumentException("Unable to find a value in the history.", nameof(at), e);
            }
        }
Пример #12
0
        /// <summary>
        /// Clear all <see cref="EMiscFlag"/>s on the device/feature.
        /// </summary>
        public void ClearMiscFlags()
        {
            if (Changes.ContainsKey(EProperty.Misc))
            {
                Changes[EProperty.Misc] = (uint)0;
            }
            else
            {
                Changes.Add(EProperty.Misc, (uint)0);
            }

            if (_cacheChanges)
            {
                return;
            }

            _misc = 0;
        }
Пример #13
0
 internal Variation(int id, string name, Changes changes, double weight, bool IsFeatureEnabled, List <Dictionary <string, dynamic> > Variables = null, Dictionary <string, dynamic> segments = null)
 {
     this.Id               = id;
     this.Name             = name;
     this.Changes          = changes;
     this.Weight           = weight;
     this.IsFeatureEnabled = IsFeatureEnabled;
     if (this.Variables == null)
     {
         this.Variables = new List <Dictionary <string, dynamic> >();
     }
     this.Variables = Variables;
     if (segments == null)
     {
         segments = new Dictionary <string, dynamic>();
     }
     this.Segments = segments;
 }
Пример #14
0
        public ServiceCollectionField(IEnumerable <T> values = null)
        {
            if (values != null)
            {
                _items = new List <T>(values);
            }
            else
            {
                _items = new List <T>();
            }

            Changed = new AsyncEvent <CollectionChanges <T> >(Changes.Init(_items))
                      // instead of returning the latest change, on subscribe, we return a reset to the entire list
                      .OnSubscribe(async cb =>
            {
                await cb.Invoke(Changes.Init(_items));
            });
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is BatchRetrieveInventoryChangesResponse other &&
                   ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) &&
                   ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true)) &&
                   ((Changes == null && other.Changes == null) || (Changes?.Equals(other.Changes) == true)) &&
                   ((Cursor == null && other.Cursor == null) || (Cursor?.Equals(other.Cursor) == true)));
        }
Пример #16
0
        private void ClearViewModel()
        {
            if (CommitsCollection != null && CommitsCollection.Any())
            {
                CommitsCollection.Clear();
            }
            if (ChangesCollection != null && ChangesCollection.Any())
            {
                ChangesCollection.Clear();
            }
            if (ChangePatchCollection != null && ChangePatchCollection.Any())
            {
                ChangePatchCollection.Clear();
            }

            CommitSelectedItem = new KeyValuePair <int, string>();
            ChangeSelectedItem = new Changes();
        }
Пример #17
0
 /// <summary>
 /// Main Entry Point for WPF
 /// </summary>
 public MainWindow()
 {
     // Check command line arguments
     if (!GetCommandLineArguments())
     {
         MessageBox.Show("This application is intended to be opened by its parent program.", "Updater", MessageBoxButton.OK, MessageBoxImage.Exclamation);
         Close();
     }
     // Try grab and open the window, if we fail, exit
     try
     {
         // Query Github Releases
         var client        = new GitHubClient(new ProductHeaderValue(ApplicationName));
         var releases      = client.Repository.Release.GetAll(GithubUserName, GithubRepoName);
         var latestRelease = releases.Result[0];
         // Query File Version
         var fileInfo = FileVersionInfo.GetVersionInfo(AssemblyName);
         // Convert to Version Objects for comparison
         var currentVersion = new Version(fileInfo.FileVersion);
         var remoteVersion  = new Version(latestRelease.TagName);
         // Set Latest Release Asset
         LatestReleaseAsset = latestRelease.Assets[0];
         // Check current Version against Remote
         if (currentVersion < remoteVersion)
         {
             InitializeComponent();
             // Set Version
             LatestVersion.Content = String.Format("Update {0}", remoteVersion);
             // Set Titles
             Title = ApplicationName + " Update";
             TitleLabel.Content = ApplicationName + " Update";
             // Append change log
             Changes.AppendText(latestRelease.Body);
         }
         else
         {
             Close();
         }
     }
     catch
     {
         Close();
     }
 }
Пример #18
0
        public async Task RequestingCodeActionWithFixableDiagnosticsShouldProduceQuickFixes(DataSet dataSet)
        {
            // ensure all files (e.g. modules) are present locally
            string basePath   = dataSet.SaveFilesToTestDirectory(this.TestContext);
            var    entryPoint = Path.Combine(basePath, "main.bicep");
            var    uri        = DocumentUri.FromFileSystemPath(entryPoint);

            // start language server
            var client = await IntegrationTestHelper.StartServerWithTextAsync(this.TestContext, dataSet.Bicep, uri, fileResolver : new FileResolver());

            // construct a parallel compilation
            var compilation = dataSet.CopyFilesAndCreateCompilation(TestContext, out _);
            var lineStarts  = compilation.SyntaxTreeGrouping.EntryPoint.LineStarts;
            var fixables    = compilation.GetEntrypointSemanticModel().GetAllDiagnostics().OfType <IFixable>();

            foreach (IFixable fixable in fixables)
            {
                foreach (var span in GetOverlappingSpans(fixable.Span))
                {
                    CommandOrCodeActionContainer?quickFixes = await client.RequestCodeAction(new CodeActionParams
                    {
                        TextDocument = new TextDocumentIdentifier(uri),
                        Range        = span.ToRange(lineStarts)
                    });

                    // Assert.
                    quickFixes.Should().NotBeNull();

                    var quickFixList = quickFixes.ToList();
                    var bicepFixList = fixable.Fixes.ToList();

                    quickFixList.Should().HaveSameCount(bicepFixList);

                    for (int i = 0; i < quickFixList.Count; i++)
                    {
                        var quickFix = quickFixList[i];
                        var bicepFix = bicepFixList[i];

                        quickFix.IsCodeAction.Should().BeTrue();
                        quickFix.CodeAction !.Kind.Should().Be(CodeActionKind.QuickFix);
                        quickFix.CodeAction.Title.Should().Be(bicepFix.Description);
                        quickFix.CodeAction.Edit !.Changes.Should().ContainKey(uri);

                        var textEditList    = quickFix.CodeAction.Edit.Changes ![uri].ToList();
Пример #19
0
        public async Task RequestingCodeActionWithFixableDiagnosticsShouldProduceQuickFixes(DataSet dataSet)
        {
            var(compilation, _, fileUri) = await dataSet.SetupPrerequisitesAndCreateCompilation(this.TestContext);

            var uri = DocumentUri.From(fileUri);

            // start language server
            using var helper = await LanguageServerHelper.StartServerWithTextAsync(this.TestContext, dataSet.Bicep, uri, creationOptions : new LanguageServer.Server.CreationOptions(FileResolver: new FileResolver()));

            var client = helper.Client;

            // construct a parallel compilation
            var lineStarts = compilation.SourceFileGrouping.EntryPoint.LineStarts;
            var fixables   = compilation.GetEntrypointSemanticModel().GetAllDiagnostics().OfType <IFixable>();

            foreach (IFixable fixable in fixables)
            {
                foreach (var span in GetOverlappingSpans(fixable.Span))
                {
                    CommandOrCodeActionContainer?quickFixes = await client.RequestCodeAction(new CodeActionParams
                    {
                        TextDocument = new TextDocumentIdentifier(uri),
                        Range        = span.ToRange(lineStarts)
                    });

                    // Assert.
                    quickFixes.Should().NotBeNull();

                    var quickFixList = quickFixes.Where(x => x.CodeAction?.Kind == CodeActionKind.QuickFix).ToList();
                    var bicepFixList = fixable.Fixes.ToList();

                    quickFixList.Should().HaveSameCount(bicepFixList);

                    for (int i = 0; i < quickFixList.Count; i++)
                    {
                        var quickFix = quickFixList[i];
                        var bicepFix = bicepFixList[i];

                        quickFix.IsCodeAction.Should().BeTrue();
                        quickFix.CodeAction !.Kind.Should().Be(CodeActionKind.QuickFix);
                        quickFix.CodeAction.Title.Should().Be(bicepFix.Description);
                        quickFix.CodeAction.Edit !.Changes.Should().ContainKey(uri);

                        var textEditList    = quickFix.CodeAction.Edit.Changes ![uri].ToList();
Пример #20
0
        protected void ApplyChanges <T>(T changeEvent) where T : class
        {
            var id = IdFrom(changeEvent);

            if (id == Guid.Empty)
            {
                try { id = Id; }
                catch (NullReferenceException)
                {
                    throw new ArgumentException(
                              "Unable to find a valid Id for Aggregate. Ensure the Event or Aggregate contains an Id.");
                }
            }

            Changes.Add(new AggregateEventBag <T>(id)
            {
                EventData = changeEvent
            });
        }
Пример #21
0
        private void IncrementCounter(string emoteId, bool isUnicode, SocketGuild guild)
        {
            if (isUnicode)
            {
                var bytes = Encoding.Unicode.GetBytes(emoteId);
                emoteId = Convert.ToBase64String(bytes);
            }

            if (!Counter.ContainsKey(emoteId))
            {
                Counter.Add(emoteId, new EmoteStat(emoteId, isUnicode, guild.Id));
            }
            else
            {
                GetValue(emoteId).IncrementAndUpdate();
            }

            Changes.Add(emoteId);
        }
Пример #22
0
 /// <summary> Tracks the changed value. </summary>
 /// <exception cref="ArgumentException">
 ///  Thrown when one or more arguments have unsupported or illegal values. </exception>
 /// <param name="value"> The value. </param>
 /// <param name="propertyName">
 ///  (Optional)
 ///  Name of the property.
 ///  </param>
 public void TrackChange(object value, [CallerMemberName] string propertyName = null)
 {
     if (string.IsNullOrWhiteSpace(propertyName))
     {
         return;
     }
     if (Changes.ContainsKey(propertyName))
     {
         LogChange(value, propertyName);
     }
     else
     {
         if (!Changes.TryAdd(propertyName, GetPropertyValue(propertyName)))
         {
             throw new ArgumentException("Unable to add specified property to the changed data dictionary.");
         }
         RaiseOnModified(propertyName);
     }
 }
Пример #23
0
        public void Record(string city, double temperature, DateTime timestamp)
        {
            if (MessagesOfType <TemperatureRecorded>().Any())
            {
                var lastRecord = MessagesOfType <TemperatureRecorded>().Last();

                if (UnexpectedTempertureDifference(lastRecord.Temperature, temperature))
                {
                    throw new UnexpectedTemperatureDifference();
                }
            }

            Changes.Add(new TemperatureRecorded {
                Id          = this.Id,
                City        = city,
                Temperature = temperature,
                TimeStamp   = timestamp
            });
        }
Пример #24
0
        internal Changes GetChangesInternal(string date)
        {
            Changes  changes = new Changes();
            DateTime latest  = Convert.ToDateTime(date);

            // Check if we have pages publised after the given date. If so return the sitemap
            if (Models.Page.GetScalar("SELECT COUNT(page_id) FROM page WHERE page_published > @0", latest) > 0)
            {
                changes.Sitemap = new SitemapServices().Get();
            }

            // Get all pages last published after the given date.
            Models.Page.GetFields("page_id", "page_last_published > @0 AND page_draft = 0", latest).ForEach(p =>
                                                                                                            changes.Pages.Add(new PageService().GetInternal(p.Id.ToString())));

            // Get all categories updated after the given date.
            new CategoryService().Get().Where(c => Convert.ToDateTime(c.Updated) > latest).
            Each((i, c) => changes.Categories.Add(c));

            // Get all content updated after the given date.
            Models.Content.GetFields("content_id", "content_updated > @0 AND content_folder = 0", latest).ForEach(c =>
                                                                                                                  changes.Content.Add(new ContentService().Get(c.Id.ToString())));

            // Get all deleted content
            string query = "syslog_parent_type = @0 AND syslog_action = @1 AND syslog_created > @2";

            changes.Deleted.Pages = Piranha.Models.SysLog.Get(query, "PAGE", "DEPUBLISH", latest).
                                    Select(l => new DeletedItem()
            {
                Id = l.ParentId, Deleted = l.Created.ToString()
            }).ToList();
            changes.Deleted.Content = Piranha.Models.SysLog.Get(query, "CONTENT", "DELETE", latest).
                                      Select(l => new DeletedItem()
            {
                Id = l.ParentId, Deleted = l.Created.ToString()
            }).ToList();
            changes.Deleted.Categories = Piranha.Models.SysLog.Get(query, "CATEGORY", "DELETE", latest).
                                         Select(l => new DeletedItem()
            {
                Id = l.ParentId, Deleted = l.Created.ToString()
            }).ToList();
            return(changes);
        }
Пример #25
0
        private void OnNodeChanged(object sender, ObjectTouchedEventArgs args)
        {
            if (!IsPluginActive() || !m_keeShare.IsInitialized())
            {
                return;
            }
            PwDatabase database = m_keeShare.FindDatabaseFor(sender);

            if (!m_keeShare.Observes(database))
            {
                // KeePass checks the structure at some points (ie. after Save) using a deep copy of the database
                // which we don't want to update or modify
                return;
            }
            PwDatabase database2 = m_keeShare.FindDatabaseFor(sender);
            Changes    changes   = m_keeShare.EnsureValidTree(database);

            UpdateUI(database.RootGroup, changes, true);
        }
        public override async void FillChartData()
        {
            base.FillChartData();

            await Task.Run(() =>
            {
                this.IsLoading = true;
                Parallel.ForEach(this.SelectedFilePaths, (selectedFilePath) =>
                {
                    using (var session = DbService.Instance.SessionFactory.OpenSession())
                    {
                        Changes changes = null;
                        var query       =
                            FilteringHelper.Instance.GenerateQuery(session)
                            .JoinAlias(c => c.Changes, () => changes, JoinType.InnerJoin)
                            .Where(() => changes.Path == selectedFilePath);
                        var itemSource = new List <ChartData>();
                        for (int i = 0; i < 23; i++)
                        {
                            var commitsCount =
                                query.Clone()
                                .Where((commit) => commit.Date.Hour == i)
                                .Select(Projections.CountDistinct <Commit>(x => x.Revision)).FutureValue <int>().Value;
                            itemSource.Add(new ChartData()
                            {
                                RepositoryValue = Path.GetFileName(selectedFilePath),
                                ChartKey        = TimeSpan.FromHours(i).ToString("hh':'mm"),
                                ChartValue      = commitsCount
                            });
                        }
                        Application.Current.Dispatcher.Invoke((() =>
                        {
                            this.AddSeriesToChartInstance(Path.GetFileName(selectedFilePath), itemSource);
                        }));
                    }
                });
            });

            this.DrawChart();
            this.FillDataCollection();
            this.IsLoading = false;
        }
Пример #27
0
        private void HandleChanges(Changes changes)
        {
            if (m_SuspendEvents || null == m_CurrentWorkspace)
            {
                return;
            }

            if (changes.ChangedEntitiesWithSetComponent <WorkspaceScenes>().Any() ||
                changes.ChangedEntitiesWithSetComponent <ActiveScene>().Any())
            {
                m_CurrentWorkspace.ClearScenes();
                for (var i = 0; i < m_SceneManager.LoadedSceneCount; ++i)
                {
                    m_CurrentWorkspace.AddScene(m_SceneManager.GetLoadedSceneAtIndex(i));
                }

                m_CurrentWorkspace.SetActiveScene(m_SceneManager.GetActiveScene());
                SaveWorkspace();
            }
        }
Пример #28
0
        internal WorkItemWrapper(EngineContext context, WorkItem item, bool isReadOnly)
        // we cannot reuse the code, because tracking is different
        //: this(context, item)
        {
            _context  = context;
            _item     = item;
            Relations = new WorkItemRelationWrapperCollection(this, _item.Relations);

            Id = new PermanentWorkItemId(item.Id.Value);
            Changes.Add(new JsonPatchOperation()
            {
                Operation = Operation.Test,
                Path      = "/rev",
                Value     = item.Rev
            });
            IsDeleted = item.Url?.EndsWith($"/recyclebin/{item.Id}", StringComparison.OrdinalIgnoreCase) ?? false;

            IsReadOnly = isReadOnly;
            _context.Tracker.TrackRevision(this);
        }
Пример #29
0
        private void changesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form f = new Form();

            f.Text          = "Build History";
            f.StartPosition = FormStartPosition.CenterScreen;
            f.Width         = this.Width - (this.Width / 3);
            f.Height        = this.Height - (this.Height / 5);
            TextBox t = new TextBox();

            f.Controls.Add(t);
            t.Dock       = DockStyle.Fill;
            t.Multiline  = true;
            t.Text       = Changes.Replace("\n", "\r\n");
            t.ScrollBars = ScrollBars.Both;
            t.ReadOnly   = true;
            f.Show();

            t.SelectionLength = 0;
        }
        public void Undo(BlockCommandContext context)
        {
            // Since we're making chanegs to the list, we need a write lock.
            ProjectBlockCollection blocks = context.Blocks;

            using (blocks.AcquireLock(RequestLock.Write))
            {
                // Go through all the blocks in the project.
                foreach (Block block in blocks)
                {
                    if (Changes.ContainsKey(block.BlockKey))
                    {
                        // Revert the type of this block.
                        BlockType blockType = previousBlockTypes[block.BlockKey];

                        block.SetBlockType(blockType);
                    }
                }
            }
        }
Пример #31
0
        /// <summary>
        /// Finds and removes duplicate proxy entry in a PwGroup. (ca happen if the user shares
        /// a folder more than once)
        /// </summary>
        /// <returns>True if made changes.</returns>
        private Changes RemoveDuplicateProxies()
        {
            PwObjectList <PwEntry> allProxies = m_database.GetAllProxyNodes();

            allProxies.Sort(new PwProxyComparer());
            PwEntry lastEntry  = null;
            Changes changeFlag = Changes.None;

            foreach (PwEntry proxy in allProxies)
            {
                //we only have to compare the last and the actual pwEntry because they are sorted alphabetically
                if (AreEqualProxies(proxy, lastEntry))
                {
                    proxy.DeleteFrom(proxy.ParentGroup);
                    changeFlag |= Changes.EntryDeleted;
                }
                lastEntry = proxy;
            }
            return(changeFlag);
        }
Пример #32
0
        /// <summary>
        /// Updates the relevant references! This function should be called after every change we made
        /// to the database from the outside! Otherwise we could not ensure a consistent database
        /// </summary>
        /// <param name="database">The database where you made changes.</param>
        /// <returns>True if the function has made any changes to the actual database.</returns>
        public Changes CorrectStructure()
        {
            Changes changes = Changes.None;

            //set active database
            Debug.Assert(m_database != null);
            if (m_database == null)
            {
                return(changes);
            }
            //run all necessary tests - keep order!
            changes |= RemoveDuplicateProxies();
            changes |= FixSharingNodesForAllUsers();
            changes |= RemoveBrokenProxies();
            changes |= FixHomeFolders();
            changes |= EnsureUsersProxiesInUsersGroup();
            changes |= ConvertCopiedPasswordsToPasswordProxies();
            changes |= CheckReferences();
            return(changes);
        }
Пример #33
0
        public WorkItemWrapper(EngineContext context, WorkItemWrapper template, string type)
        {
            _context = context;

            Id = new TemporaryWorkItemId(_context.Tracker);

            _item = new WorkItem();
            _item.Fields[CoreFieldRefNames.TeamProject]  = template.TeamProject;
            _item.Fields[CoreFieldRefNames.WorkItemType] = type;
            _item.Fields[CoreFieldRefNames.Id]           = Id.Value;
            _relationCollection = new WorkItemRelationWrapperCollection(this, _item.Relations);

            Changes.Add(new JsonPatchOperation()
            {
                Operation = Operation.Add,
                Path      = "/id",
                Value     = Id.Value
            });
            _context.Tracker.TrackNew(this);
        }
Пример #34
0
 public Object clone()
 {
     Changes changes = new Changes ();
       changes.copy (this);
       return changes;
 }
Пример #35
0
 // opcode 12 - configure window
 /**
    * This request will be aggregated.
    *
    * @see <a href="XConfigureWindow.html">XConfigureWindow</a>
    * @see Request.Aggregate aggregation
    */
 public void configure(Changes changes)
 {
     display.send_request (new Request.ValueList (
       display, 12, 3, id, changes));
 }
Пример #36
0
 public void method_18()
 {
     foreach (Control control in this.panel1.Controls)
     {
         control.Dispose();
     }
     this.panel1.Controls.Clear();
     Changes changes = new Changes {
         TopLevel = false,
         FormBorderStyle = FormBorderStyle.None,
         Visible = true
     };
     this.panel1.Controls.Add(changes);
 }
Пример #37
0
    private void EndTileStroke()
    {
        tileDragging = false;

        if (tileChanges != null)
        {
            Do(tileChanges);
            tileChanges = null;
        }
    }
Пример #38
0
    private void EndStroke()
    {
        background = false;
        dragging_ = false;
        targetActor = null;
        stippleOffset = 0;

        if (changes != null)
        {
            Do(changes);
            changes = null;
        }
    }
Пример #39
0
 /**
    * @see #configure(Window.Changes)
    */
 public void raise()
 {
     Changes changes = new Changes ();
     changes.stack_mode (Changes.ABOVE);
     configure (changes);
 }
Пример #40
0
 void IChange.Undo(Changes changes)
 {
     main.EditPalette(index, prev);
 }
Пример #41
0
        /**
           * @see <a href="XResizeWindow.html">XResizeWindow</a>
           * @see #configure(Window.Changes)
           */
        public void resize()
        {
            Changes changes = new Changes ();

            // width/height == 0 causes BAD_VALUE Error
            if (width != 0) changes.width (width);
            if (height != 0) changes.height (height);
            if (changes.bitmask != 0) configure (changes);
        }
Пример #42
0
 /**
    * @see <a href="XLowerWindow.html">XLowerWindow</a>
    * @see #configure(Window.Changes)
    */
 public void lower()
 {
     Changes changes = new Changes ();
     changes.stack_mode (Changes.BELOW);
     configure (changes);
 }
Пример #43
0
    private void UpdatePaintInput()
    {
        if (input.cancel.WasPressed)
        {
            if (drawHUD.expanded)
            {
                drawHUD.expanded = false;
                return;
            }

            //hud.mode = HUD.Mode.Switch;
            return;
        }

        brushRenderer.sprite = brushSpriteD.uSprite;
        brushRenderer.transform.position = next;

        Actor actor;

        var scene = editScene;

        if (scene.TryGetActor(next, out actor, 3))
        {
            brushRenderer.sortingLayerName = "World - Actors";
            brushRenderer.sortingOrder = 1;
        }
        else if (scene.tilemap.GetTileAtPosition(next) != null)
        {
            brushRenderer.sortingLayerName = "World - Tiles";
            brushRenderer.sortingOrder = 1;
        }
        else
        {
            brushRenderer.sortingLayerName = "World - Background";
            brushRenderer.sortingOrder = 1;
        }

        brushRenderer.gameObject.SetActive(dragging_ || !mouseOverUI);

        bool mouseCounts = (dragging_ && mouseHold) || mousePress;

        if (mouseCounts)
        {
            if (!dragging_)
            {
                var instance = scene.tilemap.GetTileAtPosition(next);

                dragging_ = true;
                changes = new Changes();
                scene.TryGetActor(next, out targetActor, 3);
                background = scene.tilemap.GetTileAtPosition(next) == null;
                exclusiveTile = instance != null && lockToggle.isOn ? instance.tile : null;
            }
            else
            {
                int stipple = drawHUD.stamping
                            ? (int) stippleSlider.value
                            : 1;

                var line = TextureByte.Pooler.Instance.Sweep(brushSpriteD,
                                                prev,
                                                next,
                                                (canvas, brush) => brush == 0 ? canvas : brush,
                                                stipple,
                                                ref stippleOffset);

                byte value = (byte) drawHUD.selected;
                Blend<byte> blend_ = (canvas, brush) => brush == 0 ? canvas : value;

                if (targetActor != null)
                {
                    targetActor.Blend(changes, line, IntVector2.zero, blend_);
                }
                else if (background)
                {
                    scene.background.Blend(changes, line, IntVector2.zero, blend_);
                }
                else
                {
                    scene.tilemap.Blend(changes, line, IntVector2.zero, blend_, exclusive: exclusiveTile);
                }

                TextureByte.Pooler.Instance.FreeTexture(line.mTexture);
                TextureByte.Pooler.Instance.FreeSprite(line);

                changes.ApplyTextures();
            }
        }
        else
        {
            EndStroke();
        }

        RefreshBrushCursor();
    }
Пример #44
0
    private void UpdateCharacterInput()
    {
        IntVector2 cell = ((IntVector2) next).CellCoords(32);

        regCursor.gameObject.SetActive(true);
        regCursor.transform.localPosition = cell * 32 + IntVector2.one * 16;

        if (addCharacter.isOn)
        {
            cellCursor.gameObject.SetActive(true);

            cellCursor.transform.localPosition = cell * 32 + IntVector2.one * 16;

            cursorBlock = cursorBlock ?? new MaterialPropertyBlock();
            cellCursor.GetPropertyBlock(cursorBlock);

            cursorBlock.SetFloat("_Cycle", Time.timeSinceLevelLoad * 12);
            cellCursor.SetPropertyBlock(cursorBlock);
            cellCursor.sprite = defaultCostume.down.uSprite;
        }
        else
        {
            cellCursor.gameObject.SetActive(false);
        }

        if (input.cancel.WasPressed)
        {
            hud.mode = HUD.Mode.Draw;
            CleanupCharacter();
            return;
        }

        characterDialogue.interactable = possessedActor != null;

        if (possessedActor != null)
        {
            if (characterDialogue.isFocused)
            {
                possessedActor.dialogue = characterDialogue.text;
            }
            else
            {
                characterDialogue.text = possessedActor.dialogue;
            }
        }
        else
        {
            characterDialogue.text = "NO CHARACTER SELECTED";
        }

        Actor hoveredActor;

        var scene = editScene;

        scene.TryGetActor(next, out hoveredActor, 0);

        if (hoveredActor != null)
        {
            if (hoveredActor == possessedActor)
            {
                SetCursorSprite(exitActorCursor);
            }
            else
            {
                SetCursorSprite(enterActorCursor);
            }
        }

        if (mousePress && hoveredActor != null)
        {
            if (removeCharacter.isOn)
            {
                scene.actors.Remove(hoveredActor);

                if (possessedActor == hoveredActor)
                    possessedActor = null;

                var changes = new Changes();
                changes.GetChange(hoveredActor, () => new ActorRemovedChange { world = scene, actor = hoveredActor });
                Do(changes);

                removeCharacter.isOn = false;
            }
            else
            {
                if (possessedActor == hoveredActor)
                {
                    possessedActor = null;
                    cameraController.focusTarget = hoveredActor.position.current - Vector2.one * 16;
                }
                else
                {
                    possessedActor = hoveredActor;
                    characterDialogue.text = possessedActor.dialogue;
                }
            }
        }
        else if (mousePress && addCharacter.isOn)
        {
            var pos = ((IntVector2) next).CellCoords(32) * 32 + IntVector2.one * 16;

            var actor = new Actor
            {
                world = scene,
                costume = NewSimpleCostume(project),
                state = new State { fragment = "start", line = 0 },
                position = new Position
                {
                    prev = pos,
                    next = pos,
                    progress = 0,
                },
            };

            scene.actors.Add(actor);

            var changes = new Changes();
            changes.GetChange(actor, () => new ActorAddedChange { world = scene, actor = actor });
            Do(changes);

            characterPlaceSound.Play();
            addCharacter.isOn = false;
            possessedActor = actor;
        }
    }
Пример #45
0
    public void RecordPaletteHistory(int i, Color prev, Color next)
    {
        //undos.Push(() => EditPalette(i, prev));

        var changes = new Changes();
        changes.changes[this] = new PaletteChange { main = this, index = i, prev = prev, next = next };

        Do(changes);
    }
Пример #46
0
 /*
    * @see <a href="XMoveWindow.html">XMoveWindow</a>
    * @see #configure(Window.Changes)
    */
 public void move()
 {
     Changes changes = new Changes ();
     changes.x (x);
     changes.y (y);
     configure (changes);
 }
Пример #47
0
 private void Do(Changes change)
 {
     redos.Clear();
     undos.Push(change);
 }
Пример #48
0
    private void UpdateTileInput()
    {
        if (input.cancel.WasPressed)
        {
            if (tiles.expanded)
            {
                tiles.expanded = false;
                return;
            }
            else
            {
                hud.mode = HUD.Mode.Draw;
                CleanupTiles();
                return;
            }
        }

        IntVector2 prevCell = ((IntVector2) prev).CellCoords(32);
        IntVector2 nextCell = ((IntVector2) next).CellCoords(32);

        if (tiles.selected != null)
        {
            brushRenderer.sortingLayerName = "World - Tiles";
            brushRenderer.sortingOrder = 1;
            brushRenderer.gameObject.SetActive(true);
            brushRenderer.sprite = tiles.selected.thumbnail.uSprite;

            brushRenderer.transform.localPosition = nextCell * 32;

            brushRenderer.GetPropertyBlock(drawCursorBlock);
            drawCursorBlock.SetFloat("_Cycle", 0);
            brushRenderer.SetPropertyBlock(drawCursorBlock);
        }
        else
        {
            brushRenderer.gameObject.SetActive(false);
            regCursor.gameObject.SetActive(true);
            regCursor.sprite = eraserTileSprite;
            regCursor.transform.localPosition = (nextCell * 32) + (IntVector2) (Vector2.one * 16);
            // TODO: show eraser icon
        }

        bool mouseCounts = (tileDragging && mouseHold) || mousePress;

        if (mouseCounts)
        {
            if (!tileDragging)
            {
                tileDragging = true;
                tileChanges = new Changes();
            }
            else if (tiles.selected != null)
            {
                bool change = false;

                Bresenham.Line(prevCell.x, prevCell.y, nextCell.x, nextCell.y, (x, y) =>
                {
                    var coord = new IntVector2(x, y);
                    var tiles_ = editScene.tilemap.tiles;

                    change |= !tiles_.ContainsKey(coord) || tiles_[coord].tile != tiles.selected;
                    editor.ScenePlaceTile(editScene, coord, tiles.selected);
                });

                if (change) tileSound.Play();
            }
            else if (tiles.selected == null)
            {
                bool change = false;

                Bresenham.Line(prevCell.x, prevCell.y, nextCell.x, nextCell.y, (x, y) =>
                {
                    var coord = new IntVector2(x, y);
                    var tiles_ = editScene.tilemap.tiles;

                    change |= tiles_.ContainsKey(coord);
                    editor.ScenePlaceTile(editScene, coord, null);
                });

                if (change) tileSound.Play();
            }
        }
        else
        {
            EndTileStroke();
        }
    }
Пример #49
0
 /**
    * @see #configure(Window.Changes)
    */
 public void flip()
 {
     Changes changes = new Changes ();
     changes.stack_mode (Changes.OPPOSITE);
     configure (changes);
 }
Пример #50
0
 void IChange.Redo(Changes changes)
 {
     main.EditPalette(index, next);
 }
Пример #51
0
        private async Task ApplyChangesAsync(ZipArchive userArchive, string budgetPath, Changes changes)
        {
            if (changes.Reset)
            {
                this.ResetBudgetFolder(userArchive, budgetPath);
            }

            foreach (KeyValuePair<string, JObject> change in changes.Items)
            {
                bool delete = change.Value == null;
                string path = delete == false 
                    ? change.Value.Value<string>("path")
                    : change.Key;

                if (delete)
                {
                    this.ApplyDeleteChange(userArchive, path);
                }
                else
                {
                    bool isDirectory = change.Value.Value<bool>("is_dir");
                    if (isDirectory == false)
                    {
                        await this.ApplyFileChangeAsync(userArchive, path);
                    }
                }
            }
        }