Example #1
0
 void RemoveFromFilteredAndGroup(object item)
 {
     if (RemoveFromFiltered(item) || true)
     {
         RootGroup.RemoveInSubtree(item);
     }
 }
Example #2
0
        /// <summary>
        /// Find a list of entries with a defined property, such as OTP Url
        /// The customized properties are stored in CustomData per PxDefs, such as PxCustomDataOtpUrl
        /// </summary>
        /// <param name="name">The property name. Must not be <c>null</c>.</param>
        /// <returns>a list of entries</returns>
        public IEnumerable <PwEntry> GetEntryListByProperty(string name)
        {
            if (name == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("name");
            }

            List <PwEntry> resultsList = new List <PwEntry>();

            LinkedList <PwGroup> flatGroupList = RootGroup.GetFlatGroupList();

            foreach (PwEntry entry in RootGroup.Entries)
            {
                if (entry.CustomData != null && entry.CustomData.Exists(name))
                {
                    if (!string.IsNullOrWhiteSpace(entry.CustomData.Get(name)))
                    {
                        resultsList.Add(entry);
                    }
                }
            }

            foreach (PwEntry entry in PwGroup.GetFlatEntryList(flatGroupList))
            {
                if (entry.CustomData != null && entry.CustomData.Exists(name))
                {
                    if (!string.IsNullOrWhiteSpace(entry.CustomData.Get(name)))
                    {
                        resultsList.Add(entry);
                    }
                }
            }
            return(resultsList);
        }
Example #3
0
        void HandleSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            // Firstly if we are copying the source collection into our filtered list, update
            // the copy with the new changes and compute the actual index of our item in the
            // sorted/grouped/filtered list.
            int  actualOldIndex = -1;
            int  actualNewIndex = -1;
            bool originalList   = ActiveList == SourceCollection;

            if (!originalList)
            {
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    foreach (object o in e.NewItems)
                    {
                        AddToFilteredAndGroupSorted(o);
                    }
                    break;

                case NotifyCollectionChangedAction.Remove:
                    actualOldIndex = IndexOf(e.OldItems [0]);
                    foreach (object o in e.OldItems)
                    {
                        RemoveFromFilteredAndGroup(o);
                    }
                    break;

                case NotifyCollectionChangedAction.Replace:
                    foreach (object o in e.OldItems)
                    {
                        RemoveFromFilteredAndGroup(o);
                    }
                    foreach (object o in e.NewItems)
                    {
                        AddToFilteredAndGroupSorted(o);
                    }
                    break;

                case NotifyCollectionChangedAction.Reset:
                    filteredList.Clear();
                    RootGroup.ClearSubtree();
                    foreach (var o in SourceCollection)
                    {
                        AddToFilteredAndGroup(o);
                    }
                    break;
                }
            }
            else
            {
                // Raise the collection changed event
                RaiseCollectionChanged(e);
            }

            IsEmpty              = ActiveList.Count == 0;
            IsCurrentAfterLast   = CurrentPosition == ActiveList.Count || ActiveList.Count == 0;
            IsCurrentBeforeFirst = CurrentPosition == -1 || ActiveList.Count == 0;
        }
Example #4
0
        public override string ToString()
        {
            StringBuilder RetVal = new StringBuilder();

            RetVal.AppendFormat("ConfigDocument {0}", Name);
            RootGroup.ToString().Split('\n').ToList().ForEach(l => RetVal.AppendFormat("  {0}\n", l));
            return(RetVal.ToString());
        }
Example #5
0
        public XElement ToXml()
        {
            XElement RetVal = new XElement("config");

            RetVal.SetAttributeValue("name", Name);
            RetVal.SetAttributeValue("datafolderpath", DataFolderPath);
            RetVal.Add(RootGroup.ToXml());
            return(RetVal);
        }
Example #6
0
 void AddToFilteredAndGroupSorted(object item)
 {
     // If we're adding an item because of a call to the 'AddNew' method, we
     //
     if (AddToFiltered(item, true) && Grouping && CurrentAddItem == null)
     {
         RootGroup.AddInSubtree(item, Culture, GroupDescriptions);
     }
 }
Example #7
0
        public override void Refresh()
        {
            if (IsAddingNew || IsEditingItem)
            {
                throw new InvalidOperationException("Cannot refresh while adding or editing an item");
            }

            if (DeferLevel != 0)
            {
                return;
            }

            Groups = null;
            RootGroup.ClearItems();

            if (ActiveList != SourceCollection)
            {
                try {
                    IgnoreFilteredListChanges = true;
                    filteredList.Clear();
                    foreach (var item in SourceCollection)
                    {
                        AddToFiltered(item, false);
                    }

                    if (SortDescriptions.Count > 0)
                    {
                        filteredList.Sort(new PropertyComparer(SortDescriptions));
                    }
                } finally {
                    IgnoreFilteredListChanges = false;
                }
                if (GroupDescriptions.Count > 0 && filteredList.Count > 0)
                {
                    foreach (var item in filteredList)
                    {
                        RootGroup.AddInSubtree(item, Culture, GroupDescriptions, false);
                    }
                    Groups = RootGroup.Items;
                }
            }

            IsEmpty              = ActiveList.Count == 0;
            IsCurrentAfterLast   = CurrentPosition == ActiveList.Count || ActiveList.Count == 0;
            IsCurrentBeforeFirst = CurrentPosition == -1 || ActiveList.Count == 0;
            int index = IndexOf(CurrentItem);

            if (index < 0 && CurrentPosition != -1 && !IsEmpty)
            {
                index = 0;
            }

            RaiseCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset), false);
            MoveCurrentTo(index, true, false);
        }
Example #8
0
        /// <summary>
        /// Delete an entry.
        /// </summary>
        /// <param name="pe">The entry to be deleted. Must not be <c>null</c>.</param>
        /// <param name="permanent">Permanent delete or move to recycle bin</param>
        public void DeleteEntry(PwEntry pe, bool permanent = false)
        {
            if (pe == null)
            {
                throw new ArgumentNullException("pe");
            }

            PwGroup pgRecycleBin = RootGroup.FindGroup(RecycleBinUuid, true);

            PwGroup pgParent = pe.ParentGroup;

            if (pgParent == null)
            {
                return;                               // Can't remove
            }
            pgParent.Entries.Remove(pe);

            bool bPermanent = false;

            if (RecycleBinEnabled == false)
            {
                bPermanent = true;
            }
            else if (permanent)
            {
                bPermanent = true;
            }
            else if (pgRecycleBin == null)
            {
            }                                              // if we cannot find it, we will create it later
            else if (pgParent == pgRecycleBin)
            {
                bPermanent = true;
            }
            else if (pgParent.IsContainedIn(pgRecycleBin))
            {
                bPermanent = true;
            }

            DateTime dtNow = DateTime.UtcNow;

            if (bPermanent)
            {
                PwDeletedObject pdo = new PwDeletedObject(pe.Uuid, dtNow);
                DeletedObjects.Add(pdo);
            }
            else             // Recycle
            {
                EnsureRecycleBin(ref pgRecycleBin);

                pgRecycleBin.AddEntry(pe, true, true);
                pe.Touch(false);
            }
        }
Example #9
0
        public void TestHashCode()
        {
            var item = new RootGroup {
                ID = 1, Name = "1"
            };
            var item2 = new RootGroup {
                ID = 1, Name = "1"
            };

            Assert.Equal(item.GetHashCode(), item2.GetHashCode());
        }
Example #10
0
 int IndexOf(object item)
 {
     if (Grouping)
     {
         return(RootGroup.IndexOfSubtree(item));
     }
     else
     {
         return(ActiveList.IndexOf(item));
     }
 }
Example #11
0
    public void CreateDownLoad(string path, Action callback)
    {
        Action <WWW, int> load = (www, udata) =>
        {
            if (www.error != null || www.text == null)
            {
                Log_Debug.LogError("www download error");
                return;
            }
            string   info    = www.text;
            string[] splited = info.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (splited.Length <= 1)//数据错误
            {
                DownLoadManager.Instance.ShowLoadingErrTips("服务器下载数据错误");
                return;
            }
            for (int i = 0; i < splited.Length; i++)
            {
                if (i == 0)
                {
                    string[] first     = splited[0].Split(new string[] { "ver:", "|FileCount:" }, StringSplitOptions.RemoveEmptyEntries);
                    int      ver       = int.Parse(first[0]);
                    int      filecount = int.Parse(first[1]);
                    string   hash      = Convert.ToBase64String(DownLoadManager.Instance.sha1.ComputeHash(www.bytes));
                    if (RemoteVersion.Version != ver)
                    {
                        RemoteVersion.Version = ver;
                    }
                    if (this.filecount != filecount)
                    {
                        this.filecount = filecount;
                    }
                    if (this.hash != hash)
                    {
                        this.hash = hash;
                    }
                }
                else
                {
                    string[]  first = splited[i].Split(new string[] { "|", "@" }, StringSplitOptions.RemoveEmptyEntries);
                    RootGroup root  = new RootGroup(first[0], first[1], int.Parse(first[2]));
                    rootlist[first[0]] = root;
                }
            }

            if (callback != null)
            {
                callback();
            }
        };

        DownLoadManager.Instance.AddDownLoadTask(path, load);
    }
 public bool Equals(RootGroup other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Name, Name));
 }
Example #13
0
        public void Unload()
        {
            RootGroup.Unload();

            foreach (var bound in RootBoundingBoxes)
            {
                UnityEngine.Object.Destroy(bound.gameObject);
            }

            GlobalVariableDataStore.Instance.Unload();

            RootBoundingBoxes.Clear();
        }
Example #14
0
        public void TestEqualWithSelfAndWithNull()
        {
            var item = new RootGroup {
                ID = 1, Name = "1"
            };
            var item2 = new RootGroup {
                ID = 1, Name = "1"
            };

            Assert.True(item.Equals(item));
            Assert.False(item.Equals(null));
            Assert.True(item.Equals(item2));
        }
Example #15
0
        public override void CommitNew()
        {
            if (IsEditingItem)
            {
                throw new InvalidOperationException("Cannot CommitNew while editing an item");
            }
            if (IsAddingNew)
            {
                if (CurrentAddItem is IEditableObject)
                {
                    ((IEditableObject)CurrentAddItem).EndEdit();
                }

                RootGroup.RemoveInSubtree(CurrentAddItem);
                if (Filter != null && !Filter(CurrentAddItem))
                {
                    RemoveFromSourceCollection(SourceCollection.IndexOf(CurrentAddItem));
                }
                else
                {
                    // When adding a new item, we initially put it in the root group. Once it's committed
                    // we need to place it in the correct subtree group.
                    if (Grouping)
                    {
                        RootGroup.AddInSubtree(CurrentAddItem, Culture, GroupDescriptions);
                    }

                    // The item was not filtered out of the tree. Do we need to resort it?
                    if (SortDescriptions.Count > 0)
                    {
                        // The newly added item is at the end of the array. If we're sorting, we may have to move it.
                        // Use a binary search to figure out where the item should be in the list and put it in there.
                        int actualIndex = filteredList.IndexOf(CurrentAddItem);
                        int sortedIndex = filteredList.BinarySearch(0, filteredList.Count - 1, CurrentAddItem, new PropertyComparer(SortDescriptions));
                        if (sortedIndex < 0)
                        {
                            sortedIndex = ~sortedIndex;
                        }

                        if (actualIndex != sortedIndex)
                        {
                            MoveAndSelectFromSorted(actualIndex, sortedIndex, CurrentItem);
                        }
                    }
                }
                CurrentAddItem = null;
                IsAddingNew    = false;
                UpdateCanAddNewAndRemove();
            }
        }
        public void CreateParentChildGroups()
        {
            var connection      = new ConnectionSettingProvider();
            var metadataElastic = new ElasticClient(
                connection.Get()
                .DefaultIndex("es.info.metadata"));

            var attachmentProcessor = new AttachmentProcessor();

            var metadataRepo = new MetadataRepository(metadataElastic);
            var metadataInfo = new InformationRepository(metadataElastic, attachmentProcessor, new ItemMetadataProvider(metadataRepo));


            var childGroup1 = new ChildGroup
            {
                SortOrder = 1,
                Title     = "child 1"
            };

            var childGroup2 = new ChildGroup
            {
                SortOrder = 2,
                Title     = "child 2"
            };

            var grandChild = new ChildGroup
            {
                SortOrder = 1,
                Title     = "grandchild"
            };

            var rootGroup = new RootGroup
            {
                Title = "root"
            };

            attachmentProcessor.Attach(childGroup1, rootGroup);
            attachmentProcessor.Attach(childGroup2, rootGroup);
            attachmentProcessor.Attach(grandChild, childGroup1);

            attachmentProcessor.Attach(grandChild, rootGroup);
            attachmentProcessor.Attach(childGroup1, rootGroup);
            attachmentProcessor.Attach(childGroup2, rootGroup);

            metadataInfo.Save(rootGroup);
            metadataInfo.Save(childGroup1);
            metadataInfo.Save(childGroup2);
            metadataInfo.Save(grandChild);
        }
Example #17
0
        public void TestEqualWithObject()
        {
            var item = new RootGroup {
                ID = 1, Name = "1"
            };
            var item2 = new RootGroup {
                ID = 1, Name = "1"
            };
            var itemGroup = new ItemGroup();

            Assert.False(item.Equals((object)null));
            Assert.True(item.Equals((object)item));
            Assert.False(item.Equals((object)itemGroup));
            Assert.True(item.Equals(item2));
        }
Example #18
0
        public override object AddNew()
        {
            ThrowIfDeferred();

            if (ItemConstructor == null)
            {
                throw new InvalidOperationException("The underlying collection does not support adding new items");
            }

            if (SourceCollection.IsFixedSize)
            {
                throw new InvalidOperationException("The source collection is of fixed size");
            }

            // If there's an existing AddNew or Edit, we commit it. Commit the edit first because
            // we're not allowed CommitNew if we're in the middle of an edit.
            if (IsEditingItem)
            {
                CommitEdit();
            }
            if (IsAddingNew)
            {
                CommitNew();
            }

            var newObject = ItemConstructor.Invoke(null);

            // FIXME: I need to check the ordering on the events when the source is INCC
            CurrentAddItem = newObject;
            IsAddingNew    = true;
            if (Grouping)
            {
                RootGroup.AddItem(newObject, false, SourceCollection);
                HandleRootGroupCollectionChanged(RootGroup, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newObject, RootGroup.IndexOfSubtree(newObject)));
            }
            AddToSourceCollection(newObject);
            MoveCurrentTo(newObject);

            if (newObject is IEditableObject)
            {
                ((IEditableObject)newObject).BeginEdit();
            }

            UpdateCanAddNewAndRemove();
            return(newObject);
        }
Example #19
0
        public void Write(Stream stream)
        {
            EnsureState();

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("package");

            PackageItem.AddAttribute(root, "id", Id);
            PackageItem.AddAttribute(root, "name", Name);
            if (Condition != null)
            {
                PackageItem.AddAttribute(root, "condition", Condition.ToString());
            }
            PackageItem.AddAttribute(root, "version", Version.ToString());
            PackageItem.AddAttribute(root, "attribution", Attribution);
            if (Website != null)
            {
                PackageItem.AddAttribute(root, "website", Website.ToString());
            }
            if (UpdateUri != null)
            {
                PackageItem.AddAttribute(root, "updateUri", UpdateUri.ToString());
            }
            if (FeedbackUri != null)
            {
                PackageItem.AddAttribute(root, "feedbackUri", FeedbackUri.ToString());
            }

            doc.AppendChild(root);

            RootGroup.Write(root);

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.ConformanceLevel = ConformanceLevel.Document;
            settings.Encoding         = Encoding.UTF8;
            settings.Indent           = true;
            settings.IndentChars      = "\t";

            XmlWriter wtr = XmlWriter.Create(stream, settings);

            doc.WriteTo(wtr);

            wtr.Flush();
        }
Example #20
0
 void DownloadOk(RootGroup g)
 {
     lock (NeedDownLoadFiles)
     {
         NeedDownLoadFiles.Remove(g);
         if (NeedDownLoadFiles.Count == 0)
         {
             LocalVersion.SaveGroupToLocal("allver.ver.txt");
             SetSliderProgress(1.0f);
             ResManager.AssetBundleInit();
             ResManager.LoadAssetBundleInMemory((str) =>
             {
                 if (str.Equals("Root/config.assetbundle"))//解析配置文件
                 {
                     ConfigManager.Instance.Parse(ParseConfigOver);
                 }
             });
         }
     }
 }
Example #21
0
        public override void CancelNew()
        {
            if (IsEditingItem)
            {
                throw new InvalidOperationException("Cannot CancelNew while editing an item");
            }

            if (IsAddingNew)
            {
                if (CurrentAddItem is IEditableObject)
                {
                    ((IEditableObject)CurrentAddItem).CancelEdit();
                }
                if (Grouping)
                {
                    RootGroup.RemoveItem(CurrentAddItem);
                }
                RemoveFromSourceCollection(SourceCollection.IndexOf(CurrentAddItem));
                CurrentAddItem = null;
                IsAddingNew    = false;
                UpdateCanAddNewAndRemove();
            }
        }
Example #22
0
 async void Search(object sender, EventArgs e)
 {
     CardDataStore.CardsQuery query = RootGroup.GetQuery();
     await Navigation.PushAsync(new CardsListPage(query.ToDataStore()));
 }
Example #23
0
        /// <summary>
        /// Delete a group.
        /// </summary>
        /// <param name="pg">Group to be added. Must not be <c>null</c>.</param>
        /// <param name="permanent">Permanent delete or move to recycle bin</param>
        public void DeleteGroup(PwGroup pg, bool permanent = false)
        {
            if (pg == null)
            {
                throw new ArgumentNullException("pg");
            }

            PwGroup pgParent = pg.ParentGroup;

            if (pgParent == null)
            {
                throw new ArgumentNullException("pgParent");                                // Can't remove virtual or root group
            }
            PwGroup pgRecycleBin = RootGroup.FindGroup(RecycleBinUuid, true);

            bool bPermanent = false;

            if (RecycleBinEnabled == false)
            {
                bPermanent = true;
            }
            else if (permanent)
            {
                bPermanent = true;
            }
            else if (pgRecycleBin == null)
            {
            }                                              // if we cannot find it, we will create it later
            else if (pg == pgRecycleBin)
            {
                bPermanent = true;
            }
            else if (pg.IsContainedIn(pgRecycleBin))
            {
                bPermanent = true;
            }
            else if (pgRecycleBin.IsContainedIn(pg))
            {
                bPermanent = true;
            }

            pgParent.Groups.Remove(pg);

            if (bPermanent)
            {
                pg.DeleteAllObjects(this);

                PwDeletedObject pdo = new PwDeletedObject(pg.Uuid, DateTime.UtcNow);
                DeletedObjects.Add(pdo);
            }
            else             // Recycle
            {
                EnsureRecycleBin(ref pgRecycleBin);

                try { pgRecycleBin.AddGroup(pg, true, true); }
                catch (Exception)
                {
                    if (pgRecycleBin.Groups.IndexOf(pg) < 0)
                    {
                        pgParent.AddGroup(pg, true, true);                         // Undo removal
                    }
                }

                pg.Touch(false);
            }
        }
Example #24
0
        public void Execute(PackageExecutionSettings settings)
        {
            ///////////////////////////////////
            // Prepare

            EnsureState();

            if (IsBusy)
            {
                throw new InvalidOperationException("Cannot execute another package whilst executing a package.");
            }
            IsBusy = true;

            if (settings.LiteMode)
            {
                FactoryOptions.Populate();
                FactoryOptions.Instance[Anolis.Core.Data.DirectoryResourceDataFactory.IconSizeLimit] = 128;
            }

            ///////////////////////////////////
            // Create Backup Details

            Group backupGroup = null;

            if (settings.BackupDirectory != null)
            {
                if (settings.BackupDirectory.Exists)
                {
                    settings.BackupDirectory = new DirectoryInfo(PackageUtility.GetUnusedDirectoryName(settings.BackupDirectory.FullName));
                }

                settings.BackupDirectory.Create();
                settings.BackupDirectory.Refresh();

                Package backupPackage = new Package(settings.BackupDirectory);
                backupPackage.Version     = this.Version;
                backupPackage.Name        = this.Name + " Uninstallation Package";
                backupPackage.Attribution = "Anolis Installer";
                backupPackage.FeedbackUri = this.FeedbackUri;

                backupGroup = backupPackage.RootGroup;
            }

            ExecutionInfo = new PackageExecutionSettingsInfo(this, settings.ExecutionMode, settings.CreateSystemRestorePoint, settings.LiteMode, backupGroup, settings.I386Directory);

            ///////////////////////////////////
            // Flatten

            Log.Add(LogSeverity.Info, "Beginning package execution: " + this.Name + ", with mode " + ExecutionInfo.ExecutionMode.ToString());

            OnProgressEvent(new PackageProgressEventArgs(0, "Flattening Package Tree"));

            List <Operation> operations = new List <Operation>();

            RootGroup.Flatten(operations);

            List <Operation> obsoleteOperations = new List <Operation>();

            Dictionary <String, Operation> uniques = new Dictionary <String, Operation>();

            foreach (Operation op in operations)
            {
                if (!op.IsEnabled)
                {
                    obsoleteOperations.Add(op);
                    continue;
                }

                Operation originalOperation;
                if (uniques.TryGetValue(op.Key, out originalOperation))
                {
                    if (originalOperation.Merge(op))
                    {
                        obsoleteOperations.Add(op);
                    }
                }
                else
                {
                    uniques.Add(op.Key, op);
                }
            }

            operations.RemoveAll(op => obsoleteOperations.Contains(op));

            ///////////////////////////////////
            // Prepare

            if (ExecutionInfo.ExecutionMode == PackageExecutionMode.Regular)
            {
                PackageUtility.AllowProtectedRenames();
            }

            Int64 restorePointSequenceNumber = -2;

            ///////////////////////////////////
            // System Restore, Part 1
            if (ExecutionInfo.ExecutionMode == PackageExecutionMode.Regular && ExecutionInfo.CreateSystemRestorePoint)
            {
                if (SystemRestore.IsSystemRestoreAvailable())
                {
                    OnProgressEvent(new PackageProgressEventArgs(-1, "Creating System Restore Point"));

                    String pointName = "Installed Anolis Package \"" + this.Name + '"';

                    restorePointSequenceNumber = SystemRestore.CreateRestorePoint(pointName, SystemRestoreType.ApplicationInstall);

                    if (restorePointSequenceNumber < 0)
                    {
                        Log.Add(LogSeverity.Error, "Failed to create System Restore point");
                    }
                }
                else
                {
                    Log.Add(LogSeverity.Error, "System Restore not supported");
                }
            }

            ///////////////////////////////////
            // Install (Backup and Execute; backups are the responisiblity of each Operation)

            try {
                float i = 0, cnt = operations.Count;

                foreach (Operation op in operations)
                {
                    OnProgressEvent(new PackageProgressEventArgs((int)(100 * i++ / cnt), op.ToString()));

                    if (!op.SupportsCDImage && ExecutionInfo.ExecutionMode == PackageExecutionMode.CDImage)
                    {
                        continue;
                    }

                    try {
                        if (op.CustomEvaluation)
                        {
                            op.Execute();
                        }
                        else
                        {
                            EvaluationResult result = op.Evaluate();

                            switch (result)
                            {
                            case EvaluationResult.False:
                                Log.Add(LogSeverity.Info, "Evaluation False - " + op.Key);
                                break;

                            case EvaluationResult.FalseParent:
                                Log.Add(LogSeverity.Info, "Evaluation ParentFalse - " + op.Key);
                                break;

                            case EvaluationResult.Error:
                                Log.Add(LogSeverity.Error, "Evaluation Error - " + op.Key);
                                break;

                            case EvaluationResult.True:
                                op.Execute();
                                break;
                            }
                        }
                    } catch (Exception ex) {
                        Log.Add(new LogItem(LogSeverity.Error, ex, op.Name + " failed: \"" + ex.Message + "\""));
                        continue;
                    }

#if !DEBUG
                    // don't add "Info - Done {op}" in debug mode because it's too verbose and clutters up the logfile
                    PathOperation pathOp = op as PathOperation;
                    if (pathOp != null)
                    {
                        Log.Add(LogSeverity.Info, "Done " + op.Name + ": " + pathOp.Path);
                    }
                    else
                    {
                        Log.Add(LogSeverity.Info, "Done " + op.Name);
                    }
#endif
                }                //foreach

                OnProgressEvent(new PackageProgressEventArgs(100, "Complete"));
            } finally {
                ///////////////////////////////////
                // System Restore, Part 2
                if (restorePointSequenceNumber >= 0)
                {
                    OnProgressEvent(new PackageProgressEventArgs(-1, "Finishing System Restore Point"));

                    SystemRestore.EndRestorePoint(restorePointSequenceNumber);
                }

                ///////////////////////////////////
                // Backup, Part 2

                if (ExecutionInfo.BackupGroup != null)
                {
                    String backupFileName = Path.Combine(ExecutionInfo.BackupDirectory.FullName, "Package.xml");

                    ExecutionInfo.BackupPackage.Write(backupFileName);
                }

                ///////////////////////////////////
                // Dump the log to disk

                Log.Save(Path.Combine(this.RootDirectory.FullName, "Anolis.Installer.log"));

                IsBusy = false;
            }            //try/finally
        }
Example #25
0
 public void AcceptChanges()
 {
     RootGroup.AcceptChanges();
 }
Example #26
0
        //called by Groups manager
        public IEnumerator CheckGroupLoadStates()
        {
            if (!mInitialized)
            {
                yield break;
            }

            if (RootGroup == null || RootGroup.IsDestroyed)
            {
                Debug.Log("ROOT GROUP was null or destroyed in unloader, we're finished");
                yield break;
            }
            //we may have to backtrack if new groups were added
            if (NotPreparedToUnload.Count > 0)
            {
                LoadState = WIGroupLoadState.Loaded;
            }
            else if (PreparingToUnload.Count > 0)
            {
                LoadState = WIGroupLoadState.PreparingToUnload;
            }
            else if (Unloading.Count > 0)
            {
                LoadState = WIGroupLoadState.Unloading;
            }

            switch (LoadState)
            {
            case WIGroupLoadState.Loaded:
                //tell everyone in the Loaded list to prepare to unload
                //then move them all into preparing to unload
                //---TRANSITION TO PREPARED TO UNLOAD---//
                for (int i = NotPreparedToUnload.LastIndex(); i >= 0; i--)
                {
                    if (NotPreparedToUnload [i].PrepareToUnload())
                    {
                        PreparingToUnload.Add(NotPreparedToUnload [i]);
                        NotPreparedToUnload.RemoveAt(i);
                    }
                    yield return(null);
                }
                if (NotPreparedToUnload.Count == 0 && RootGroup.PrepareToUnload())
                {
                    LoadState = WIGroupLoadState.PreparingToUnload;
                    //RootGroup.LoadState = WIGroupLoadState.PreparingToUnload;
                }
                yield return(null);

                break;

            case WIGroupLoadState.PreparingToUnload:
                //go through each child group and ask if it's ready to unload
                //this will force the group to ask each of its child items
                //if it's prepared we move it to the prepared to unload group
                for (int i = PreparingToUnload.LastIndex(); i >= 0; i--)
                {
                    WIGroup loadedGroup = PreparingToUnload [i];
                    if (loadedGroup.ReadyToUnload)
                    {
                        PreparingToUnload.RemoveAt(i);
                        ReadyToUnload.Add(loadedGroup);
                    }
                    yield return(null);
                    //yield return null;
                }
                //---TRANSITION TO UNLOADING---//
                //if all are ready to unload and there are no more not prepared to unload
                //then begin unload - there's no turning back at this point!
                if (PreparingToUnload.Count == 0 && RootGroup.ReadyToUnload)
                {
                    Unloading.AddRange(ReadyToUnload);
                    ReadyToUnload.Clear();
                    for (int i = 0; i < Unloading.Count; i++)
                    {
                        Unloading [i].BeginUnload();
                    }
                    RootGroup.BeginUnload();
                    LoadState = WIGroupLoadState.Unloading;
                    //RootGroup.LoadState = WIGroupLoadState.Unloading;
                }
                yield return(null);

                break;

            case WIGroupLoadState.Unloading:
                if (Unloading.Count > 0)
                {
                    for (int i = Unloading.LastIndex(); i >= 0; i--)
                    {
                        if (Unloading [i].FinishedUnloading)
                        {
                            FinishedUnloading.Add(Unloading [i]);
                            Unloading.RemoveAt(i);
                            //this generates a huge amount of garbage
                            yield break;
                        }
                                                #if UNITY_EDITOR
                        else
                        {
                            LastHoldout = Unloading [i].FileName + " " + Unloading [i].HoldoutChildItem;
                        }
                                                #endif
                        yield return(null);
                    }
                }
                else
                {
                    if (FinishedUnloading.Count > 0)
                    {
                        for (int i = FinishedUnloading.LastIndex(); i >= 0; i--)
                        {
                            if (FinishedUnloading [i] == null || FinishedUnloading [i].IsDestroyed)
                            {
                                FinishedUnloading.RemoveAt(i);
                            }
                            else
                            {
                                //we see if it's ready to actually be destroyed
                                //no groups greater than [x] depth that have not been destroyed
                                                                #if UNITY_EDITOR
                                LastHoldout = FinishedUnloading [i].FileName + " " + FinishedUnloading [i].HoldoutChildItem;
                                                                #endif
                                if (!FinishedUnloading [i].HasChildGroups)
                                {
                                    ReadyToDestroy.Add(FinishedUnloading [i]);
                                    FinishedUnloading.RemoveAt(i);
                                }
                            }
                            yield return(null);
                        }
                    }
                    else
                    {
                    }
                }

                yield return(null);

                //---TRANSITION TO UNLOADED---//
                //if we have more than just the root group then we wait until the root group is finished unloading to kill everything
                if (FinishedUnloading.Count == 0 && ReadyToDestroy.Count == 0)
                {
                    if (!RootGroup.FinishedUnloading)
                    {
                        //now it will be detsroyed by WIGroups
                                                #if UNITY_EDITOR
                        LastHoldout = RootGroup.FileName + " " + RootGroup.HoldoutChildItem;
                                                #endif
                        if (RootGroup.PrepareToUnload())
                        {
                            RootGroup.BeginUnload();
                        }
                    }
                    else
                    {
                        LoadState = WIGroupLoadState.Unloaded;
                    }
                }
                break;

            case WIGroupLoadState.Unloaded:
                //nothing left to do
                break;

            default:
                Debug.Log("Weird load state in WIGroupUnloader: " + LoadState.ToString());
                break;
            }

            yield break;
        }
Example #27
0
 public override string ToStringWithoutDelim()
 {
     return(RootGroup.ToStringWithoutDelim());
 }
Example #28
0
        public override void CommitEdit()
        {
            if (IsAddingNew)
            {
                throw new InvalidOperationException("Cannot cancel edit while adding new");
            }

            if (IsEditingItem)
            {
                var editItem = CurrentEditItem;

                CurrentEditItem = null;
                IsEditingItem   = false;

                if (CanCancelEdit)
                {
                    ((IEditableObject)editItem).EndEdit();
                    CanCancelEdit = false;
                }

                UpdateCanAddNewAndRemove();

                int originalIndex = IndexOf(editItem);
                int newIndex;

                // If we're filtering the item out just nuke it
                if (Filter != null && !Filter(editItem))
                {
                    RemoveFromFilteredAndGroup(editItem);
                    if (CurrentItem == editItem)
                    {
                        MoveCurrentTo(CurrentPosition);
                    }
                    return;
                }

                // We could also have changed the property which sorts it
                if (SortDescriptions.Count > 0)
                {
                    // We can't just remove the item and binary search for the correct place as that will change the
                    // order of elements which compare as equal and breaks more tests than it fixes. We need to first
                    // check to see if the editItem is >= than the previous one and <= the next one. If that is true
                    // we need to do nothing. Otherwise we need to binary search either the upper or lower half and
                    // find the new index where the editItem should be placed.
                    if (originalIndex > 0 && Comparer.Compare(filteredList [originalIndex - 1], editItem) > 0)
                    {
                        newIndex = filteredList.BinarySearch(0, originalIndex, editItem, Comparer);
                    }
                    else if (originalIndex < (filteredList.Count - 1) && Comparer.Compare(filteredList [originalIndex + 1], editItem) < 0)
                    {
                        newIndex = filteredList.BinarySearch(originalIndex + 1, filteredList.Count - (originalIndex + 1), editItem, Comparer);
                    }
                    else
                    {
                        // We're already in the right place.
                        newIndex = originalIndex;
                    }
                }
                else
                {
                    // No sorting == no index change
                    newIndex = originalIndex;
                }

                var currentSelection = CurrentItem;
                if (newIndex != originalIndex)
                {
                    if (newIndex < 0)
                    {
                        newIndex = ~newIndex;
                    }

                    // When we remove the element from the original index, our newIndex will be off by 1 as everything
                    // gets shuffled down so decrement it here.
                    if (newIndex > originalIndex)
                    {
                        newIndex--;
                    }

                    DeferCurrentChanged = true;
                    filteredList.RemoveAt(originalIndex);
                    filteredList.Insert(newIndex, editItem);
                    DeferCurrentChanged = false;
                }

                // We may have edited the property which controls which group the item is in
                // so re-seat it
                if (Grouping)
                {
                    DeferCurrentChanged = true;
                    RootGroup.RemoveInSubtree(editItem);
                    RootGroup.AddInSubtree(editItem, Culture, GroupDescriptions);
                    DeferCurrentChanged = false;
                    MoveCurrentTo(IndexOf(currentSelection) + 1);
                }
                else if (originalIndex != newIndex)
                {
                    MoveCurrentTo(IndexOf(currentSelection));
                }
            }
        }
Example #29
0
 public override string ToStringTree()
 {
     return(RootGroup.ToStringTree());
 }
Example #30
0
    public void BeginDownLoad(string path, Action callback)
    {
        Action CompareDiff = () =>
        {
            foreach (KeyValuePair <string, VerGroup> index in RemoteVersion.RemoteVerGroup)
            {
                if (LocalVersion.LocalVerGroup.ContainsKey(index.Key))//比较hash,size
                {
                    VerGroup local = LocalVersion.LocalVerGroup[index.Key];
                    //if (local.hash != index.Value.hash || local.filecount != index.Value.filecount)
                    //{
                    //    LocalVersion.LocalVerGroup[index.Key] = index.Value;
                    //}
                    foreach (KeyValuePair <string, RootGroup> KV in index.Value.rootlist)
                    {
                        if (local.rootlist.ContainsKey(KV.Key))
                        {
                            RootGroup group = local.rootlist[KV.Key];
                            if (group.hash != KV.Value.hash || group.filesize != KV.Value.filesize)
                            {
                                local.rootlist[KV.Key] = KV.Value;
                                local.rootlist[KV.Key].needdownload = true;
                            }
                        }
                        else
                        {
                            RootGroup g = new RootGroup(KV.Value.FileName, KV.Value.hash, KV.Value.filesize);
                            g.needdownload         = true;
                            local.rootlist[KV.Key] = g;
                        }
                    }
                }
                else
                {
                    VerGroup newgroup = new VerGroup(index.Value.RootName, index.Value.hash, index.Value.filecount);
                    index.Value.SetAllFilesNeedDownLoad();
                    newgroup.rootlist = index.Value.rootlist;
                    LocalVersion.LocalVerGroup[index.Key] = newgroup;
                }
            }
            //LocalVersion.SaveGroupToLocal("allver.ver.txt");
            //TODO::与本地解析比较,找出需要下载的
            if (callback != null)
            {
                callback();
            }
        };
        Action <WWW, int> AllVerCallBack = (www, udata) =>
        {
            if (www.error != null || www.text == null)
            {
                Log_Debug.LogError("www download error");
                return;
            }
            string   info    = www.text;
            string[] splited = info.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (splited.Length <= 1)//数据错误
            {
                ShowLoadingErrTips("服务器下载数据错误");
                return;
            }
            for (int i = 0; i < splited.Length; i++)
            {
                if (i == 0)
                {
                    string[] first = splited[0].Split(new string[] { ":" }, StringSplitOptions.None);
                    int.TryParse(first[1], out RemoteVersion.Version);
                }
                else
                {
                    string[] first = splited[i].Split(new string[] { "|" }, StringSplitOptions.None);
                    VerGroup ver   = new VerGroup(first[0], first[1], int.Parse(first[2]));
                    RemoteVersion.RemoteVerGroup[first[0]] = ver;
                }
            }
            Debug.Log(RootHashDiff());
            if (RemoteVersion.Version > LocalVersion.Version || RootHashDiff())//
            {
                LocalVersion.Version = RemoteVersion.Version;
                foreach (KeyValuePair <string, VerGroup> group in RemoteVersion.RemoteVerGroup)
                {
                    StringBuilder str = new StringBuilder();
                    str.Append(RemoteVersion.remoteurl).Append("/" + group.Key + ".ver.txt");
                    group.Value.CreateDownLoad(str.ToString(), CompareDiff);
                }
            }
            else
            {
                if (callback != null)
                {
                    callback();
                }
            }
        };
        Action MergeLocal = () =>
        {
            RemoteVersion.AddDownLoadTask(path, AllVerCallBack);
        };

        if (DataManager.Instance.IsFirstEnterGame)//首次进入游戏
        {
            LocalVersion.ClearLocalCache();
            RemoteVersion.AddDownLoadTask(path, AllVerCallBack);
        }
        else
        {
            LocalVersion.ReadLocalAllVer(path, MergeLocal);
        }
    }
 public bool Equals(RootGroup other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Name, Name);
 }