Ejemplo n.º 1
0
        public void Reset()
        {
            Ignores.Clear();
            UpdateRules();

            Set(Ignores);
        }
Ejemplo n.º 2
0
        public void IgnoreByPath(string path)
        {
            Ignores.Add(path);
            UpdateRules();

            Set(Ignores);
        }
            /// <inheritdoc/>
            ITransformationMap <TCollection, TElement> ITransformationMap <TCollection, TElement> .Ignore(params string[] memberSelectors)
            {
                if (memberSelectors is null)
                {
                    throw new ArgumentNullException(nameof(memberSelectors));
                }

                Ignores.AddRange(memberSelectors);
                return(this);
            }
Ejemplo n.º 4
0
 /// <inheritdoc/>
 ITransformationMap <TCollection, TElement> ITransformationMap <TCollection, TElement> .Ignore(
     string memberSelector1,
     string memberSelector2,
     string memberSelector3)
 {
     Ignores.Add(memberSelector1);
     Ignores.Add(memberSelector2);
     Ignores.Add(memberSelector3);
     return(this);
 }
Ejemplo n.º 5
0
        public IgnoresVM(Ignores ignores, bool isReadOnly)
        {
            _ignores = ignores;
            if (_ignores == null)
            {
                _ignores = new Ignores();
            }

            IsReadOnly = isReadOnly;
        }
            /// <inheritdoc/>
            ITransformationMap <TCollection, TElement> ITransformationMap <TCollection, TElement> .Ignore(string memberSelector1)
            {
                if (memberSelector1 is null)
                {
                    throw new ArgumentNullException(nameof(memberSelector1));
                }

                Ignores.Add(memberSelector1);
                return(this);
            }
Ejemplo n.º 7
0
        //-----------------------------------------------------
        //true则忽略不显示
        public bool IsIgnoreField(string columnName)
        {
            string[] ignores = Ignores.Split(',');
            if (ignores.Length < 1)
            {
                return(false);
            }
            string result = ignores.FirstOrDefault(p => p.ToLower().Equals(columnName.ToLower()));

            return(!string.IsNullOrEmpty(result));
        }
        private async Task <Ignores> FetchFolderIgnoresAsync(string folderId, CancellationToken cancellationToken)
        {
            // Until startup is complete, these can return a 500.
            // There's no sensible way to determine when startup *is* complete, so we just have to keep trying...

            // Again, there's the possibility that we've just abort the API...
            ISyncThingApiClient apiClient;

            lock (this.apiClient.LockObject)
            {
                cancellationToken.ThrowIfCancellationRequested();
                apiClient = this.apiClient.UnsynchronizedValue;
                if (apiClient == null)
                {
                    throw new InvalidOperationException("ApiClient must not be null");
                }
            }

            Ignores ignores = null;
            // We used to time out after an absolute time here. However, there's the possiblity of going to sleep
            // halfway through polling, which throws things off. Therefore use a number of iterations
            var numRetries = this.ignoresFetchTimeout.TotalSeconds; // Each iteration is a second

            for (var retriesCount = 0; retriesCount < numRetries; retriesCount++)
            {
                try
                {
                    ignores = await apiClient.FetchIgnoresAsync(folderId);

                    // No need to log: ApiClient did that for us
                    break;
                }
                catch (ApiException e)
                {
                    logger.Debug("Attempting to fetch folder {0}, but received status {1}", folderId, e.StatusCode);
                    if (e.StatusCode != HttpStatusCode.InternalServerError)
                    {
                        throw;
                    }
                }

                await Task.Delay(1000, cancellationToken);

                cancellationToken.ThrowIfCancellationRequested();
            }

            if (ignores == null)
            {
                throw new SyncThingDidNotStartCorrectlyException($"Unable to fetch ignores for folder {folderId}. Syncthing returned 500 after {this.ignoresFetchTimeout}");
            }

            return(ignores);
        }
        public bool Parse(string[] args)
        {
            if (args == null || args.Length == 0)
            {
                return(false);
            }

            Path = args[0];

            for (int i = 1; i < args.Length; i++)
            {
                Ignores.Add(args[i]);
            }

            return(true);
        }
Ejemplo n.º 10
0
        private void monitor(XmlDocument doc)
        {
            XmlNodeList monitor_check  = doc.DocumentElement.SelectNodes("/config/monitor/check");
            XmlNodeList monitor_ignore = doc.DocumentElement.SelectNodes("/config/monitor/ignore");

            for (int i = 0; i < monitor_check.Count; i++)
            {
                string txt_check = monitor_check.Item(i).InnerText;
                Checks.Add(txt_check);
                console_write("check >> " + txt_check);
            }

            for (int i = 0; i < monitor_ignore.Count; i++)
            {
                string txt_ignore = monitor_ignore.Item(i).InnerText;
                Ignores.Add(txt_ignore);
                console_write("ignore > " + txt_ignore);
            }
        }
Ejemplo n.º 11
0
        protected virtual void ProcessProperty(SerializedProperty property)
        {
            if (Ignores.Contains(property))
            {
                return;
            }

            if (Overrides.Contains(property))
            {
                Overrides.Draw(property);
            }
            else if (Disabled.Contains(property))
            {
                DrawDisabled(property);
            }
            else
            {
                DrawDefault(property);
            }
        }
Ejemplo n.º 12
0
 public void ImportOld(string path)
 {
     if (File.Exists(path))
     {
         OldConfig oldConfig = new OldConfig(path);
         ParityDir    = oldConfig.ParityDir;
         TempDir      = oldConfig.TempDir;
         MaxTempRAM   = oldConfig.MaxTempRAM;
         IgnoreHidden = oldConfig.IgnoreHidden;
         for (int i = 0; i < oldConfig.BackupDirs.Length; i++)
         {
             Drives.Add(new Drive(oldConfig.BackupDirs[i], String.Format("files{0}.dat", i)));
         }
         foreach (string i in oldConfig.Ignores)
         {
             Ignores.Add(i);
         }
         UpdateIgnoresRegex();
         Save();
     }
 }
        protected virtual Stack <Rigidbody> ExtractHits(Collider[] colliders)
        {
            Stack <Rigidbody> rigidbodies = new Stack <Rigidbody>();

            Rigidbody rigidbody;

            for (int i = 0; i < colliders.Length; i++)
            {
                if (Ignores.Contains(colliders[i]))
                {
                    continue;
                }

                rigidbody = colliders[i].attachedRigidbody;

                if (rigidbody && !rigidbodies.Contains(rigidbody) && !Ignores.Contains(rigidbody))
                {
                    rigidbodies.Push(colliders[i].attachedRigidbody);
                }
            }

            return(rigidbodies);
        }
Ejemplo n.º 14
0
        public async Task Process(SetAccountRelation rel)
        {
            if (!IsLoggedIn)
            {
                return;
            }

            if (string.IsNullOrEmpty(rel.TargetName) && string.IsNullOrEmpty(rel.SteamID))
            {
                return;
            }

            using (var db = new ZkDataContext())
            {
                ulong steamId = 0;

                var srcAccount = db.Accounts.Find(User.AccountID);
                ulong.TryParse(rel.SteamID, out steamId);
                var trgtAccount = Account.AccountByName(db, rel.TargetName) ?? db.Accounts.FirstOrDefault(x => x.SteamID == steamId);
                if (trgtAccount == null)
                {
                    if (!string.IsNullOrEmpty(rel.TargetName))
                    {
                        await Respond("No such account found");                                        // only warn if name is set and not just steam id
                    }
                    return;
                }

                var friendAdded = false;

                var entry = srcAccount.RelalationsByOwner.FirstOrDefault(x => x.TargetAccountID == trgtAccount.AccountID);
                if ((rel.Relation == Relation.None) && (entry != null))
                {
                    db.AccountRelations.Remove(entry);
                }
                if (rel.Relation != Relation.None)
                {
                    if (entry == null)
                    {
                        if (rel.Relation == Relation.Friend)
                        {
                            friendAdded = true;
                        }
                        entry = new AccountRelation()
                        {
                            Owner = srcAccount, Target = trgtAccount, Relation = rel.Relation
                        };
                        srcAccount.RelalationsByOwner.Add(entry);
                    }
                    else
                    {
                        entry.Relation = rel.Relation;
                    }
                }
                db.SaveChanges();

                ConnectedUser targetConnectedUser;
                if (server.ConnectedUsers.TryGetValue(trgtAccount.Name, out targetConnectedUser))
                {
                    targetConnectedUser.LoadFriendsIgnores(); // update partner's mutual lists

                    if (friendAdded)                          // friend added, sync new friend to me (user, battle and channels)
                    {
                        await server.TwoWaySyncUsers(Name, new List <string>() { targetConnectedUser.Name });

                        foreach (var chan in
                                 server.Channels.Values.Where(
                                     x => (x != null) && x.Users.ContainsKey(Name) && x.Users.ContainsKey(targetConnectedUser.Name)))
                        {
                            await SendCommand(new ChannelUserAdded()
                            {
                                ChannelName = chan.Name, UserName = targetConnectedUser.Name
                            });
                        }
                    }
                }

                LoadFriendsIgnores();
                await SendCommand(new FriendList()
                {
                    Friends = FriendEntries.ToList()
                });
                await SendCommand(new IgnoreList()
                {
                    Ignores = Ignores.ToList()
                });
            }
        }
Ejemplo n.º 15
0
 public Status(string path)
 {
     RootPath = path;
     ignores  = new Ignores(path, ".hgignore");
 }
Ejemplo n.º 16
0
 public Status(string path)
 {
     RootPath = path;
     ignores = new Ignores(path, ".hgignore");
 }
Ejemplo n.º 17
0
 /// <inheritdoc/>
 ITransformationMap <TCollection, TElement> ITransformationMap <TCollection, TElement> .Ignore(params string[] memberSelectors)
 {
     Ignores.AddRange(memberSelectors);
     return(this);
 }
Ejemplo n.º 18
0
        public CombinedOptions OverrideWith(IEnumerable <Attribute> attributes)
        {
            if (attributes == null)
            {
                return(this);
            }

            if (DisableOverrides)
            {
                Ignores.AddRange(attributes
                                 .Where(attr => attr is YamlIgnoreAttribute)
                                 .Select(attr => (YamlIgnoreAttribute)attr)
                                 .Where(attr => (attr.IfEquals == null) && (attr.IfEquals == null)));
                return(this);
            }

            foreach (var attr in attributes.Reverse())
            {
                var type = attr.GetType();
                if (type == typeof(YamlNameAttribute))
                {
                    Name = ((YamlNameAttribute)attr).Name;
                }
                else if (type == typeof(YamlIgnoreAttribute))
                {
                    Ignores.Add((YamlIgnoreAttribute)attr);
                }
                else if (type == typeof(YamlFormatAttribute))
                {
                    var fmt = (YamlFormatAttribute)attr;
                    if (fmt.Format != null)
                    {
                        Format = fmt.Format;
                    }
                    if (fmt.MaybeBlankLinesBefore.HasValue)
                    {
                        BlankLinesBefore = fmt.MaybeBlankLinesBefore.Value;
                    }
                    if (fmt.MaybeBlankLinesAfter.HasValue)
                    {
                        BlankLinesAfter = fmt.MaybeBlankLinesAfter.Value;
                    }
                    if (fmt.MaybeAlwaysNested.HasValue)
                    {
                        AlwaysNested = fmt.MaybeAlwaysNested.Value;
                    }
                    if (fmt.MaybeQuoted.HasValue)
                    {
                        Quoted = fmt.MaybeQuoted.Value;
                    }
                    if (fmt.MaybeDoubleQuoted.HasValue)
                    {
                        DoubleQuoted = fmt.MaybeDoubleQuoted.Value;
                    }
                    if (fmt.MaybeBlock.HasValue)
                    {
                        Block = fmt.MaybeBlock.Value;
                    }
                    if (fmt.MaybeIndentStep.HasValue)
                    {
                        IndentStep = fmt.MaybeIndentStep.Value;
                    }
                }
                else if (type == typeof(YamlCommentAttribute))
                {
                    Comments.Add((YamlCommentAttribute)attr);
                }
            }

            return(this);
        }
Ejemplo n.º 19
0
 public void Load()
 {
     if (!File.Exists(filename))
     {
         return;
     }
     using (XmlReader reader = XmlReader.Create(new StreamReader(filename))) {
         for (; ;)
         {
             reader.Read();
             if (reader.EOF)
             {
                 break;
             }
             if (reader.NodeType == XmlNodeType.Whitespace)
             {
                 continue;
             }
             if (reader.Name == "Options" && reader.IsStartElement())
             {
                 for (; ;)
                 {
                     if (!reader.Read() || reader.EOF)
                     {
                         break;
                     }
                     if (reader.NodeType == XmlNodeType.Whitespace)
                     {
                         continue;
                     }
                     else if (reader.NodeType == XmlNodeType.EndElement)
                     {
                         break;
                     }
                     if (reader.Name == "TempDir")
                     {
                         reader.Read();
                         TempDir = reader.Value;
                         reader.Read();
                     }
                     else if (reader.Name == "MaxTempRAM")
                     {
                         reader.Read();
                         MaxTempRAM = Convert.ToUInt32(reader.Value);
                         reader.Read();
                     }
                     else if (reader.Name == "IgnoreHidden")
                     {
                         reader.Read();
                         IgnoreHidden = (reader.Value == "true") ? true : false;
                         reader.Read();
                     }
                     else if (reader.Name == "MonitorDrives")
                     {
                         reader.Read();
                         MonitorDrives = (reader.Value == "true") ? true : false;
                         reader.Read();
                     }
                     else if (reader.Name == "UpdateDelay")
                     {
                         reader.Read();
                         UpdateDelay = Convert.ToUInt32(reader.Value);
                         reader.Read();
                     }
                     else if (reader.Name == "UpdateMode")
                     {
                         reader.Read();
                         int mode = Convert.ToInt32(reader.Value);
                         reader.Read();
                         if (mode == 1)
                         {
                             UpdateMode = UpdateMode.NoAction;
                         }
                         else if (mode == 2)
                         {
                             UpdateMode = UpdateMode.ScanOnly;
                         }
                         else if (mode == 3)
                         {
                             UpdateMode = UpdateMode.ScanAndUpdate;
                         }
                     }
                     else if (reader.Name == "Ignores")
                     {
                         for (; ;)
                         {
                             if (!reader.Read() || reader.EOF)
                             {
                                 break;
                             }
                             if (reader.NodeType == XmlNodeType.Whitespace)
                             {
                                 continue;
                             }
                             else if (reader.NodeType == XmlNodeType.EndElement)
                             {
                                 break;
                             }
                             if (reader.Name == "Ignore" && reader.IsStartElement())
                             {
                                 reader.Read();
                                 Ignores.Add(reader.Value);
                                 reader.Read(); // skip end element
                             }
                         }
                     }
                 }
             }
             else if (reader.Name == "Parity")
             {
                 ParityDir = reader.GetAttribute("Path");
             }
             else if (reader.Name == "Layout" && reader.IsStartElement())
             {
                 for (; ;)
                 {
                     if (!reader.Read() || reader.EOF)
                     {
                         break;
                     }
                     if (reader.NodeType == XmlNodeType.Whitespace)
                     {
                         continue;
                     }
                     else if (reader.NodeType == XmlNodeType.EndElement)
                     {
                         break;
                     }
                     else if (reader.Name == "MainWindowX")
                     {
                         reader.Read();
                         MainWindowX = Convert.ToInt32(reader.Value);
                         reader.Read();
                     }
                     else if (reader.Name == "MainWindowY")
                     {
                         reader.Read();
                         MainWindowY = Convert.ToInt32(reader.Value);
                         reader.Read();
                     }
                     else if (reader.Name == "MainWindowWidth")
                     {
                         reader.Read();
                         MainWindowWidth = Convert.ToInt32(reader.Value);
                         reader.Read();
                     }
                     else if (reader.Name == "MainWindowHeight")
                     {
                         reader.Read();
                         MainWindowHeight = Convert.ToInt32(reader.Value);
                         reader.Read();
                     }
                 }
             }
             else if (reader.Name == "Drives" && reader.IsStartElement())
             {
                 for (; ;)
                 {
                     if (!reader.Read() || reader.EOF)
                     {
                         break;
                     }
                     if (reader.NodeType == XmlNodeType.Whitespace)
                     {
                         continue;
                     }
                     else if (reader.NodeType == XmlNodeType.EndElement)
                     {
                         break;
                     }
                     if (reader.Name == "Drive")
                     {
                         Drives.Add(new Drive(reader.GetAttribute("Path"), reader.GetAttribute("Meta")));
                     }
                 }
             }
         }
     }
     UpdateIgnoresRegex();
 }
 public void IgnoreByPath(string path)
 {
     Ignores.Add(path);
     Set(Ignores);
 }
 public void Reset()
 {
     Ignores.Clear();
     Set(Ignores);
 }
 public bool IsIgnored(string path)
 {
     return(Ignores.Contains(path, StringComparer.OrdinalIgnoreCase));
 }