System.Collections.Generic.ICollection.Add(string)

Here are the examples of the csharp api System.Collections.Generic.ICollection.Add(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

990 Examples 7

19 Source : InfoPostProcessing.cs
with GNU Affero General Public License v3.0
from blockbasenetwork

public IList<IList<string>> DecryptRows(SimpleSelectStatement simpleSelectStatement, IList<IList<string>> allResults, string databaseName, out IList<TableAndColumnName> columnNames)
        {
            var databaseInfoRecord = _encryptor.FindInfoRecord(new estring(databaseName), null);

            var selectCoreStatement = simpleSelectStatement.SelectCoreStatement;

            var decryptedResults = new List<IList<string>>();
            foreach (var row in allResults) decryptedResults.Add(new List<string>());

            columnNames = new List<TableAndColumnName>();

            for (int i = 0; i < selectCoreStatement.ResultColumns.Count; i++)
            {
                var resultColumn = selectCoreStatement.ResultColumns[i];

                var tableInfoRecord = _encryptor.FindInfoRecord(resultColumn.TableName, databaseInfoRecord.IV);

                var decryptedTableName = tableInfoRecord.KeyName != null ? new estring(_encryptor.DecryptName(tableInfoRecord), true) : new estring(tableInfoRecord.Name, false);

                var columnInfoRecord = _encryptor.FindInfoRecord(resultColumn.ColumnName, tableInfoRecord.IV);

                if (columnInfoRecord != null)
                {
                    var decryptedColumnName = columnInfoRecord.KeyName != null ? _encryptor.DecryptName(columnInfoRecord) : columnInfoRecord.Name;

                    columnNames.Add(new TableAndColumnName(decryptedTableName, new estring(decryptedColumnName, true)));
                }

                else columnNames.Add(new TableAndColumnName(decryptedTableName, resultColumn.ColumnName));

                for (int j = 0; j < allResults.Count; j++)
                {
                    var row = allResults[j];

                    if (columnInfoRecord != null)
                    {
                        if(row[i] == null){
                            decryptedResults[j].Add(null);
                            continue;
                        }
                        var dataType = columnInfoRecord.LData.DataType;

                        if (dataType.DataTypeName == DataTypeEnum.ENCRYPTED)
                        {
                            var decryptedValue = "";
                            if (columnInfoRecord.LData.EncryptedIVColumnName != null)
                            {
                                var ivColumn = selectCoreStatement.ResultColumns.Where(r => r.ColumnName.Value == columnInfoRecord.LData.EncryptedIVColumnName).SingleOrDefault();
                                var columnIVIndex = selectCoreStatement.ResultColumns.IndexOf(ivColumn);
                                if(selectCoreStatement.CaseExpressions.Count != 0) 
                                {
                                    decryptedValue = _encryptor.DecryptUniqueValue(row[i], columnInfoRecord);
                                }
                                else {
                                    decryptedValue = _encryptor.DecryptNormalValue(row[i], columnInfoRecord, row[columnIVIndex]);
                                }
                                
                            }
                            else decryptedValue = _encryptor.DecryptUniqueValue(row[i], columnInfoRecord);
                            decryptedResults[j].Add(decryptedValue);
                            continue;
                        }
                    }
                    decryptedResults[j].Add(row[i]);
                }
            }

            return decryptedResults;
        }

19 Source : InfoPostProcessing.cs
with GNU Affero General Public License v3.0
from blockbasenetwork

private IList<IList<string>> FilterSelectColumns(IList<ResultColumn> resultColumns, IList<IList<string>> decryptedResults, IList<TableAndColumnName> columnNames, string databaseName, out IList<string> columnsToMantain)
        {
            var databaseInfoRecord = _encryptor.FindInfoRecord(new estring(databaseName), null);

            columnsToMantain = new List<string>();

            foreach (var resultColumn in resultColumns)
            {
                if (!resultColumn.AllColumnsfFlag) columnsToMantain.Add(resultColumn.TableName.Value + "." + resultColumn.ColumnName.Value);
                else
                {
                    var tableInfoRecord = _encryptor.FindInfoRecord(resultColumn.TableName, databaseInfoRecord.IV);

                    foreach (var columnInfoRecord in _encryptor.FindChildren(tableInfoRecord.IV))
                    {
                        var decryptedColumnName = columnInfoRecord.KeyName != null ? _encryptor.DecryptName(columnInfoRecord) : columnInfoRecord.Name;
                        columnsToMantain.Add(resultColumn.TableName.Value + "." + decryptedColumnName);
                    }
                }
            }

            var columnsToRemove = columnNames.Select(s => s.ToString()).Except(columnsToMantain).ToList();
            var indexesOfColumnsToRemove = columnsToRemove.Select(c => columnNames.Select(s => s.ToString()).ToList().IndexOf(c)).OrderByDescending(x => x).ToList();

            foreach (var row in decryptedResults)
                foreach (var index in indexesOfColumnsToRemove)
                    row.RemoveAt(index);


            return decryptedResults;
        }

19 Source : RemoveReservedSeatsCommand.cs
with GNU Affero General Public License v3.0
from blockbasenetwork

protected override CommandParseResult ParseCommand(string[] commandData)
        {
            _reservedSeatsToRemove = new List<string>();
            if (commandData.Length > 4) 
            {
                for (var i = 4; i < commandData.Length; i++)
                {
                    _reservedSeatsToRemove.Add(commandData[i]);
                }
                return new CommandParseResult(true, true);
            }

            return new CommandParseResult(true, CommandUsage);
        }

19 Source : ClientSession.cs
with GNU General Public License v3.0
from BlowaXD

private bool WaitForPackets(string packetstring, IReadOnlyList<string> packetsplit)
        {
            _waitForPacketList.Add(packetstring);
            string[] packetssplit = packetstring.Split(' ');
            if (packetssplit.Length > 3 && packetsplit[1] == "DAC")
            {
                _waitForPacketList.Add("0 CrossServerAuthenticate");
            }

            if (_waitForPacketList.Count != _waitForPacketsAmount)
            {
                return true;
            }

            _waitForPacketsAmount = null;
            string queuedPackets = string.Join(" ", _waitForPacketList.ToArray());
            string header = queuedPackets.Split(' ', '^')[1];
            TriggerHandler(header, queuedPackets, true);
            _waitForPacketList.Clear();
            return false;
        }

19 Source : ClientSession.cs
with GNU General Public License v3.0
from BlowaXD

private void TriggerHandler(string packetHeader, string packet, bool force)
        {
            if (Player != null)
            {
                GameHandler(packetHeader, packet);
                return;
            }

            Type packetType = PacketPipeline.PacketTypeByHeader(packetHeader);
            if (packetType == null)
            {
#if DEBUG
                Log.Warn($"[{Ip}][HANDLER_NOT_FOUND] {packetHeader}");
#endif
                return;
            }

            if (force)
            {
                CharacterHandler(packet, packetType);
                return;
            }

            // hardcoded for entrypoint since entwell sucks
            var headerAttribute = packetType.GetCustomAttribute<PacketHeaderAttribute>();
            if (headerAttribute != null && headerAttribute.Amount > 1 && !_waitForPacketsAmount.HasValue)
            {
                _waitForPacketsAmount = headerAttribute.Amount;
                _waitForPacketList.Add(packet != string.Empty ? packet : $"1 {packetHeader} ");
                return;
            }

            CharacterHandler(packet, packetType);
        }

19 Source : Subscription.cs
with GNU General Public License v3.0
from bonarr

private bool AddEventCore(string key)
        {
            lock (EventKeys)
            {
                if (EventKeys.Contains(key))
                {
                    return false;
                }

                EventKeys.Add(key);
                return true;
            }
        }

19 Source : PackageBuilderDialog.cs
with MIT License
from bonsai-rx

public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
                    {
                        var result = base.ConvertFrom(context, culture, value);
                        var set = result as ISet<string>;
                        if (set != null)
                        {
                            set.Add(Constants.BonsaiDirectory);
                            set.Add(Constants.GalleryDirectory);
                        }

                        return result;
                    }

19 Source : ProcessControlEndpoint.cs
with MIT License
from bryanhitc

private async Task RestartAsync(int delaySeconds, ICollection<string> queryParameters)
        {
            queryParameters.Add($"delaySeconds={delaySeconds}");
            await RequestHandler.GetJsonResponseAsync(HttpMethod.Post, $"{BaseUrl}restart", queryParameters).ConfigureAwait(false);
        }

19 Source : TabularRow.cs
with Apache License 2.0
from BuffettCode

public TabularRow Add(string value)
        {
            values.Add(value);
            return this;
        }

19 Source : Parser.cs
with MIT License
from Butjok

public virtual IList<string> GetRuleInvocationStack(RuleContext p)
        {
            string[] ruleNames = RuleNames;
            IList<string> stack = new List<string>();
            while (p != null)
            {
                // compute what follows who invoked us
                int ruleIndex = p.RuleIndex;
                if (ruleIndex < 0)
                {
                    stack.Add("n/a");
                }
                else
                {
                    stack.Add(ruleNames[ruleIndex]);
                }
                p = p.Parent;
            }
            return stack;
        }

19 Source : Parser.cs
with MIT License
from Butjok

public virtual IList<string> GetDFAStrings()
        {
            IList<string> s = new List<string>();
            for (int d = 0; d < Interpreter.atn.decisionToDFA.Length; d++)
            {
				DFA dfa = Interpreter.atn.decisionToDFA[d];
                s.Add(dfa.ToString(Vocabulary));
            }
            return s;
        }

19 Source : GlobalLogger.cs
with MIT License
from canhorn

public static void Success(string message)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            message = $"Success : {message}";
            Console.WriteLine(
                message
            );
            Console.ResetColor();
            Messages.Add(
                message
            );
        }

19 Source : GlobalLogger.cs
with MIT License
from canhorn

public static void Error(string message)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            message = $"Error : {message}";
            Console.WriteLine(
                message
            );
            Console.ResetColor();
            Messages.Add(
                message
            );
        }

19 Source : UsedClassNamesIdentifier.cs
with MIT License
from canhorn

public static IList<string> Identify(
            TypeStatement type,
            IList<string> list = null
        )
        {
            if (list == null)
            {
                list = new List<string>();
            }
            if (!type.IsAction
                && !type.IsArray
                && !type.IsLiteral
                && !type.IsModifier
                && !type.IsNullable
                && !type.IsTypeAlias
            )
            {
                // Using The Type get
                switch (type.Name)
                {
                    case GenerationIdentifiedTypes.Array:
                    case GenerationIdentifiedTypes.Unknown:
                    case GenerationIdentifiedTypes.Action:
                    case GenerationIdentifiedTypes.Void:
                    case GenerationIdentifiedTypes.Task:
                    case GenerationIdentifiedTypes.Setter:
                    case GenerationIdentifiedTypes.Getter:
                    case GenerationIdentifiedTypes.String:
                    case GenerationIdentifiedTypes.Bool:
                    case GenerationIdentifiedTypes.Number:
                    case GenerationIdentifiedTypes.Literal:
                    case GenerationIdentifiedTypes.Int:
                    case GenerationIdentifiedTypes.Float:
                    case GenerationIdentifiedTypes.CachedEnreplacedy:
                    case GenerationIdentifiedTypes.Object:
                        break;
                    default:
                        list.Add(type.Name);
                        break;
                }
            }
            foreach (var genericType in type.GenericTypes)
            {
                Identify(
                    genericType,
                    list
                );
            }
            if (type.IsTypeAlias)
            {
                Identify(
                    type.AliasType,
                    list
                );
            }

            return list;
        }

19 Source : GlobalLogger.cs
with MIT License
from canhorn

public static void Warning(string message)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            message = $"Warning : {message}";
            Console.WriteLine(
                message
            );
            Console.ResetColor();
            Messages.Add(
                message
            );
        }

19 Source : GlobalLogger.cs
with MIT License
from canhorn

public static void Info(string message)
        {
            message = $"Info : {message}";
            Console.WriteLine(
                message
            );
            Messages.Add(
                message
            );
        }

19 Source : TagSelect.razor.cs
with MIT License
from caopengfei

public void Selecreplacedem(string value)
        {
            Value?.Add(value);
        }

19 Source : GenerateSource.cs
with MIT License
from canhorn

private static IList<ClreplacedStatement> GenerateClreplacedFromList(
            AbstractSyntaxTree ast,
            string projectreplacedembly,
            IList<string> generationList,
            IList<string> notGeneratedClreplacedNames,
            IDictionary<string, string> typeOverrideMap,
            IList<ClreplacedStatement> generatedStatements
        )
        {
            var stopwatch = Stopwatch.StartNew();
            foreach (var clreplacedIdentifier in generationList)
            {
                if (generatedStatements.Any(a => a.Name == clreplacedIdentifier)
                    || notGeneratedClreplacedNames.Contains(clreplacedIdentifier))
                {
                    continue;
                }
                stopwatch.Restart();
                var generated = GenerateInteropClreplacedStatement.Generate(
                    projectreplacedembly,
                    clreplacedIdentifier,
                    ast,
                    typeOverrideMap
                );
                stopwatch.Stop();
                GlobalLogger.Info(
                    $"Took {stopwatch.ElapsedMilliseconds}ms to generate {clreplacedIdentifier}"
                );
                if (generated == null)
                {
                    if (!notGeneratedClreplacedNames.Contains(clreplacedIdentifier))
                    {
                        GlobalLogger.Warning(
                            $"Was not found in AST. Adding to Shim Generation List. clreplacedIdentifier: {clreplacedIdentifier}"
                        );
                        notGeneratedClreplacedNames.Add(
                            clreplacedIdentifier
                        );
                    }
                    continue;
                }
                generatedStatements.Add(generated);
                // Add Used Clreplacedes and add Generated List
                var usesClreplacedes = GetAllUsedClreplacedes(generated);
                var toGenerateList = new List<string>();
                foreach (var clreplacedName in usesClreplacedes)
                {
                    if (!generatedStatements.Any(a => a.Name == clreplacedName))
                    {
                        toGenerateList.Add(clreplacedName);
                    }
                }
                generatedStatements = GenerateClreplacedFromList(
                    ast,
                    projectreplacedembly,
                    toGenerateList,
                    notGeneratedClreplacedNames,
                    typeOverrideMap,
                    generatedStatements
                );
            }

            return generatedStatements;
        }

19 Source : BrokerageFactory.cs
with Apache License 2.0
from Capnode

protected static T Read<T>(IReadOnlyDictionary<string, string> brokerageData, string key, ICollection<string> errors)
            where T : IConvertible
        {
            string value;
            if (!brokerageData.TryGetValue(key, out value))
            {
                errors.Add("BrokerageFactory.CreateBrokerage(): Missing key: " + key);
                return default(T);
            }

            try
            {
                return value.ConvertTo<T>();
            }
            catch (Exception err)
            {
                errors.Add($"BrokerageFactory.CreateBrokerage(): Error converting key '{key}' with value '{value}'. {err.Message}");
                return default(T);
            }
        }

19 Source : LogProfiles.cs
with MIT License
from carina-studio

public static async Task InitializeAsync(IULogViewerApplication app)
		{
			// check state
			app.VerifyAccess();
			if (LogProfiles.app != null && LogProfiles.app != app)
				throw new InvalidOperationException();

			// attach to application
			LogProfiles.app = app;
			app.StringsUpdated += OnApplicationStringsUpdated;

			// create logger
			logger = app.LoggerFactory.CreateLogger(nameof(LogProfiles));

			// load more built-in profiles in debug mode
			if (app.IsDebugMode)
			{
				builtInProfileIDs.Add("ULogViewerLog");
				builtInProfileIDs.Add("ULogViewerMemoryLog");
			}

			// create scheduled action
			saveProfilesAction = new ScheduledAction(async () =>
			{
				if (pendingSavingProfiles.IsEmpty())
					return;
				var profiles = pendingSavingProfiles.ToArray().Also(_ => pendingSavingProfiles.Clear());
				logger?.LogDebug($"Start saving {profiles.Length} profile(s)");
				foreach (var profile in profiles)
				{
					var fileName = profile.FileName;
					try
					{
						if (fileName == null)
							fileName = await profile.FindValidFileNameAsync(profilesDirectoryPath);
						_ = profile.SaveAsync(fileName);
					}
					catch (Exception ex)
					{
						logger?.LogError(ex, $"Unable to save profile '{profile.Name}' to '{fileName}'");
					}
				}
				logger?.LogDebug($"Complete saving {profiles.Length} profile(s)");
			});

			// create empty profile
			emptyProfile = LogProfile.CreateEmptyBuiltInProfile(app);

			// load build-in profiles
			logger.LogDebug("Start loading built-in profiles");
			var profileCount = 0;
			foreach (var id in builtInProfileIDs)
			{
				logger.LogDebug($"Load '{id}'");
				AttachToProfile(await LogProfile.LoadBuiltInProfileAsync(app, id));
				++profileCount;
			}
			logger.LogDebug($"Complete loading {profileCount} built-in profile(s)");

			// load profiles
			profilesDirectoryPath = Path.Combine(app.RootPrivateDirectoryPath, "Profiles");
			profileCount = 0;
			logger.LogDebug("Start loading profiles");
			var fileNames = await Task.Run(() =>
			{
				try
				{
					if (!Directory.Exists(profilesDirectoryPath))
						return new string[0];
					return Directory.GetFiles(profilesDirectoryPath, "*.json");
				}
				catch (Exception ex)
				{
					logger.LogError(ex, $"Unable to check profiles in directory '{profilesDirectoryPath}'");
					return new string[0];
				}
			});
			foreach (var fileName in fileNames)
			{
				try
				{
					AttachToProfile(await LogProfile.LoadProfileAsync(app, fileName));
					++profileCount;
				}
				catch (Exception ex)
				{
					logger.LogError(ex, $"Unable to load profile from '{fileName}'");
				}
			}
			logger.LogDebug($"Complete loading {profileCount} profile(s)");
		}

19 Source : CasbinPolicyCreator.cs
with Apache License 2.0
from casbin-net

private static void AddAuthenticationSchemes(ICollection<string> authenticationSchemes,
            string authenticationSchemesString)
        {
            string[] authTypesSplit = authenticationSchemesString.Split(',');
            if (authTypesSplit.Length == 0)
            {
                return;
            }

            foreach (var authType in authTypesSplit)
            {
                if (string.IsNullOrWhiteSpace(authType) is false)
                {
                    authenticationSchemes.Add(authType.Trim());
                }
            }
        }

19 Source : FcTechFabricatorService.cs
with MIT License
from ccgould

public void AddCraftNode(Craftable item, string parentTabId)
        {
            if (!knownItems.Contains(item.ClreplacedID))
            {
                fcTechFabricator.AddCraftNode(item, parentTabId);
                knownItems.Add(item.ClreplacedID);
            }
        }

19 Source : Option.cs
with GNU General Public License v3.0
from chaincase-app

private static void AddSeparators(string name, int end, ICollection<string> seps)
		{
			int start = -1;
			for (int i = end + 1; i < name.Length; ++i)
			{
				switch (name[i])
				{
					case '{':
						if (start != -1)
						{
							throw new ArgumentException(
								$"Ill-formed name/value separator found in \"{name}\".",
								nameof(Prototype));
						}

						start = i + 1;
						break;

					case '}':
						if (start == -1)
						{
							throw new ArgumentException(
								$"Ill-formed name/value separator found in \"{name}\".",
								nameof(Prototype));
						}

						seps.Add(name[start..i]);
						start = -1;
						break;

					default:
						if (start == -1)
						{
							seps.Add(name[i].ToString());
						}

						break;
				}
			}
			if (start != -1)
			{
				throw new ArgumentException(
					$"Ill-formed name/value separator found in \"{name}\".",
					nameof(Prototype));
			}
		}

19 Source : Option.cs
with GNU General Public License v3.0
from chaincase-app

private static void AddSeparators(string name, int end, ICollection<string> seps)
		{
			int start = -1;
			for (int i = end + 1; i < name.Length; ++i)
			{
				switch (name[i])
				{
					case '{':
						if (start != -1)
						{
							throw new ArgumentException(
								$"Ill-formed name/value separator found in \"{name}\".",
								nameof(Prototype));
						}

						start = i + 1;
						break;

					case '}':
						if (start == -1)
						{
							throw new ArgumentException(
								$"Ill-formed name/value separator found in \"{name}\".",
								nameof(Prototype));
						}

						seps.Add(name[start..i]);
						start = -1;
						break;

					default:
						if (start == -1)
						{
							seps.Add(name[i].ToString());
						}

						break;
				}
			}
			if (start != -1)
			{
				throw new ArgumentException(
					$"Ill-formed name/value separator found in \"{name}\".",
					nameof(Prototype));
			}
		}

19 Source : OptionSet.cs
with GNU General Public License v3.0
from chaincase-app

private static bool Unprocessed(ICollection<string> extra, Option def, OptionContext c, string argument)
		{
			if (def is null)
			{
				extra.Add(argument);
				return false;
			}
			c.OptionValues.Add(argument);
			c.Option = def;
			c.Option.Invoke(c);
			return false;
		}

19 Source : ArgumentCheckAttribute.cs
with MIT License
from chengderen

public override void OnActionExecuting(ActionExecutingContext actionContext)
        {
            if (!actionContext.ModelState.IsValid)
            {
                IList<string> errors = new List<string>();
                foreach (string key in actionContext.ModelState.Keys)
                {
                    if (actionContext.ModelState.TryGetValue(key, out ModelStateEntry modelError))
                    {
                        foreach (ModelError error in modelError.Errors)
                        {
                            errors.Add(error.ErrorMessage);
                        }
                    }
                }

                var data = new ResultData
                {
                    Code = 999,
                    Data = "参数不合法"
                };
                if (errors.Count > 0)
                {
                    string errorMessage = errors.Count > 0 && !String.IsNullOrEmpty(string.Join("", errors)) ? string.Join("", errors) : data.Data.ToString();
                    data.Data = string.Format("{0}", errorMessage);
                }
                actionContext.Result = new JsonResult(data);
            }

            base.OnActionExecuting(actionContext);
        }

19 Source : Package.cs
with GNU General Public License v3.0
from chi-rei-den

public void AddFile(IFile file)
        {
            if (file == null)
            {
                return;
            }

            if (!FileList.Contains(file.GetType().Name))
            {
                FileList.Add(file.GetType().Name);
            }

            Files.Add(file);
        }

19 Source : ObjectField.cs
with MIT License
from ChilliCream

private void AddExecutableDirectives(
        ISet<string> processed,
        IEnumerable<IDirective> directives)
    {
        List<IDirective>? executableDirectives = null;
        foreach (IDirective directive in directives.Where(t => t.Type.HasMiddleware))
        {
            executableDirectives ??= new List<IDirective>(_executableDirectives);
            if (!processed.Add(directive.Name) && !directive.Type.IsRepeatable)
            {
                IDirective remove = executableDirectives
                    .First(t => t.Name.Equals(directive.Name));
                executableDirectives.Remove(remove);
            }
            executableDirectives.Add(directive);
        }

        if (executableDirectives is not null)
        {
            _executableDirectives = executableDirectives.ToArray();
        }
    }

19 Source : DirectiveCollection.cs
with MIT License
from ChilliCream

private bool TryCompleteDirective(
        ITypeCompletionContext context,
        DirectiveDefinition definition,
        ISet<string> processed,
        [NotNullWhen(true)] out Directive? directive)
    {
        if (!context.TryGetDirectiveType(
            definition.Reference,
            out DirectiveType? directiveType))
        {
            directive = null;
            return false;
        }

        if (!processed.Add(directiveType.Name) && !directiveType.IsRepeatable)
        {
            context.ReportError(
                DirectiveCollection_DirectiveIsUnique(
                    directiveType,
                    context.Type,
                    definition.ParsedDirective,
                    _source));
            directive = null;
            return false;
        }

        if (directiveType.Locations.Contains(_location))
        {
            directive = Directive.FromDescription(directiveType, definition, _source);
            return true;
        }

        context.ReportError(
            DirectiveCollection_LocationNotAllowed(
                directiveType,
                _location,
                context.Type,
                definition.ParsedDirective,
                _source));
        directive = null;
        return false;
    }

19 Source : InputObjectConstructorResolver.cs
with MIT License
from ChilliCream

private static void CollectReadOnlyProperties(
        IReadOnlyDictionary<string, InputField> fields,
        ISet<string> required)
    {
        required.Clear();

        foreach (KeyValuePair<string, InputField> item in fields)
        {
            if (!item.Value.Property!.CanWrite)
            {
                required.Add(item.Value.Name);
            }
        }
    }

19 Source : CollectUsedVariableVisitor.cs
with MIT License
from ChilliCream

protected override void VisitVariable(
            VariableNode node, ISet<string> context)
        {
            context.Add(node.Name.Value);
        }

19 Source : RootTypeMergeHandler.cs
with MIT License
from ChilliCream

private static void IntegrateFields(
            ObjectTypeDefinitionNode rootType,
            ITypeInfo typeInfo,
            ISet<string> names,
            ICollection<FieldDefinitionNode> fields)
        {
            string schemaName = typeInfo.Schema.Name;

            foreach (FieldDefinitionNode field in rootType.Fields)
            {
                FieldDefinitionNode current = field;

                if (names.Add(current.Name.Value))
                {
                    current = current.AddDelegationPath(schemaName);
                }
                else
                {
                    var path = new SelectionPathComponent(
                        field.Name,
                        field.Arguments.Select(t => new ArgumentNode(
                            t.Name,
                            new ScopedVariableNode(
                                null,
                                new NameNode(ScopeNames.Arguments),
                                t.Name))).ToList());

                    var newName = new NameNode(
                        typeInfo.CreateUniqueName(current));

                    current = current.WithName(newName)
                        .AddDelegationPath(schemaName, path);
                }

                fields.Add(current);
            }
        }

19 Source : InputObjectTypeMergeHandler.cs
with MIT License
from ChilliCream

private static bool HreplacedameType(
            ITypeNode left,
            ITypeNode right,
            ICollection<string> typesToreplacedyze)
        {
            if (left is NonNullTypeNode lnntn
                && right is NonNullTypeNode rnntn)
            {
                return HreplacedameType(lnntn.Type, rnntn.Type, typesToreplacedyze);
            }

            if (left is ListTypeNode lltn
                && right is ListTypeNode rltn)
            {
                return HreplacedameType(lltn.Type, rltn.Type, typesToreplacedyze);
            }

            if (left is NamedTypeNode lntn
                && right is NamedTypeNode rntn)
            {

                if (lntn.Name.Value.Equals(
                    rntn.Name.Value,
                    StringComparison.Ordinal))
                {
                    typesToreplacedyze.Add(rntn.Name.Value);
                    return true;
                }
                return false;
            }

            throw new NotSupportedException();
        }

19 Source : FragmentHelper.cs
with MIT License
from ChilliCream

private static IReadOnlyList<OutputFieldModel> CreateFields(
            FragmentNode fragmentNode,
            ISet<string> implementedFields,
            Path path)
        {
            // the fragment type is a complex type we will generate a interface with fields.
            if (fragmentNode.Fragment.TypeCondition is INamedOutputType type && 
                type.IsCompositeType())
            {
                var fieldMap = new OrderedDictionary<string, FieldSelection>();
                CollectFields(fragmentNode, type, fieldMap, path);

                if (fieldMap.Count > 0)
                {
                    foreach (var fieldName in fieldMap.Keys.ToArray())
                    {
                        // if we already have implemented this field in a lower level
                        // interface we will just skip it and remove it from the map.
                        if (!implementedFields.Add(fieldName))
                        {
                            fieldMap.Remove(fieldName);
                        }
                    }
                }

                return fieldMap.Values
                    .Select(
                        t => new OutputFieldModel(
                            GetPropertyName(t.ResponseName),
                            t.ResponseName,
                            t.Field.Description,
                            t.Field,
                            t.Field.Type,
                            t.SyntaxNode,
                            t.Path))
                    .ToList();
            }

            return Array.Empty<OutputFieldModel>();
        }

19 Source : FragmentHelper.cs
with MIT License
from ChilliCream

private static void AddImplementedFields(
            OutputTypeModel @interface,
            ISet<string> implementedFields)
        {
            foreach (var field in @interface.Fields)
            {
                implementedFields.Add(
                    field.SyntaxNode.Alias?.Value ??
                    field.SyntaxNode.Name.Value);
            }
        }

19 Source : FileManagerTests.cs
with MIT License
from chinhdo

private string GetTempPathName(string extension = "")
        {
            string tempFile = _target.CreateTempFileName(extension);
            _tempPaths.Add(tempFile);
            return tempFile;
        }

19 Source : Macro.cs
with MIT License
from Citavi

public static void Run(MainForm mainForm, string exportPath)
        {
            int changeCounter = 0;
            int errorCounter = 0;

            mainForm.Project.AllCategories.CreateCategoryPathes(exportPath).ForEach(path => CreateFolderStructure(path));

            foreach (var reference in mainForm.GetFilteredReferences())
            {
                var locations = reference.Locations.FilterBySupportedLocations();
                if (locations.Count == 0) continue;

                var categoryPathes = reference.Categories.CreateCategoryPathes(exportPath);
                if (categoryPathes.Count == 0)
                {
                    var tempPath = mainForm.Project.AllCategories.Count == 0 ? exportPath : exportPath + @"\" + Resources.NoCategoryFolder;
                    categoryPathes.Add(tempPath);
                }


                // create folders if necessary ...
                foreach (var categoryPath in categoryPathes)
                {
                    CreateFolderStructure(categoryPath);

                    foreach (var location in locations)
                    {
                        var sourcePath = location.Address.Resolve().GetLocalPathSafe();
                        var destinationPath = string.Empty;

                        if (location.Address.LinkedResourceType == LinkedResourceType.AttachmentRemote)
                        {
                            if (location.Address.LinkedResourceStatus != LinkedResourceStatus.Attached) continue;
                            if (location.Address.CachingStatus != CachingStatus.Available) continue;

                            destinationPath = categoryPath + @"\" + location.FullName;
                        }
                        else
                        {
                            destinationPath = categoryPath + @"\" + Path.GetFileName(sourcePath);
                        }

                        if (!File.Exists(sourcePath))
                        {
                            errorCounter++;
                            continue;
                        }

                        bool tryAgain = true;
                        while (tryAgain)
                        {
                            try
                            {
                                File.Copy(sourcePath, destinationPath, true);
                                changeCounter++;
                                tryAgain = false;
                            }
                            catch (Exception e)
                            {
                                tryAgain = false;
                                DialogResult directoryError = MessageBox.Show(Resources.Messages_CreatingFolderError + e.Message,
                                                            Resources.Messages_Error, MessageBoxButtons.AbortRetryIgnore,
                                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);

                                if (directoryError == DialogResult.Abort) return;
                                else if (directoryError == DialogResult.Retry) tryAgain = true;
                                else
                                {
                                    errorCounter++;
                                    break;
                                };
                            }
                        }
                    }
                }
            }

            MessageBox.Show(Resources.Messages_Completed.FormatString(System.Environment.NewLine + changeCounter, System.Environment.NewLine + errorCounter), mainForm.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

19 Source : ConsoleHandler.cs
with MIT License
from CityOfZion

public string ReadFromConsole(IAutoCompleteHandler autocomplete = null)
        {
            State = ConsoleReaderState.Reading;

            // Write prompt

            WritePrompt();

            // If have something loaded

            if (TryReadManualInput(out var manual))
            {
                State = ConsoleReaderState.ReadingDirty;

                // Print it
                WriteLine(manual, ConsoleOutputStyle.Input);

                // Use it
                State = ConsoleReaderState.None;

                return manual;
            }

            // Read from console

            var state = new ConsoleInputState(this)
            {
                Autocomplete = autocomplete
            };

            if (IsWindows)
            {
                // In Mac don't work

                Console.CursorSize = !state.InsertMode ? 100 : 25;
            }

            ConsoleKeyInfo i;

            do
            {
                i = Console.ReadKey(true);

                if (_keyHandle.TryGetValue(i.Key, out var action))
                {
                    action(i.Key, state);
                }
                else
                {
                    ReadFromConsole_Default(i, state);
                }

                State = state.Txt.Length > 0 ? ConsoleReaderState.ReadingDirty : ConsoleReaderState.Reading;
            }
            while (i.Key != ConsoleKey.Enter);

            // Process return

            var ret = state.Txt.ToString();

            // Append to history

            if (_history.LastOrDefault() != ret)
            {
                if (_history.Count > MaxHistorySize)
                {
                    _history.RemoveAt(0);
                }

                _history.Add(ret);
            }

            // return text

            State = ConsoleReaderState.None;

            return ret;
        }

19 Source : XlsxTemplateTestsBase.cs
with MIT License
from ClosedXML

protected bool WorksheetsAreEqual(IXLWorksheet expected, IXLWorksheet actual, out IList<string> messages)
        {
            messages = new List<string>();

            if (expected.Name != actual.Name)
                messages.Add("Worksheet names differ");

            if (expected.RangeUsed()?.RangeAddress?.ToString() != actual.RangeUsed()?.RangeAddress?.ToString())
                messages.Add("Used ranges differ");

            if (expected.Style.ToString() != actual.Style.ToString())
                messages.Add("Worksheet styles differ");

            if (!expected.PageSetup.RowBreaks.All(actual.PageSetup.RowBreaks.Contains)
                || expected.PageSetup.RowBreaks.Count != actual.PageSetup.RowBreaks.Count)
                messages.Add("PageBreaks differ");

            if (expected.PageSetup.PagesTall != actual.PageSetup.PagesTall)
                messages.Add("PagesTall differ");

            if (expected.PageSetup.PagesWide != actual.PageSetup.PagesWide)
                messages.Add("PagesWide differ");

            if (expected.PageSetup.PageOrientation != actual.PageSetup.PageOrientation)
                messages.Add("PageOrientation differ");

            if (expected.PageSetup.PageOrder != actual.PageSetup.PageOrder)
                messages.Add("PageOrder differ");

            var usedCells = expected.CellsUsed(XLCellsUsedOptions.All).Select(c => c.Address)
                .Concat(actual.CellsUsed(XLCellsUsedOptions.All).Select(c => c.Address))
                .Distinct();
            foreach (var address in usedCells)
            {
                var expectedCell = expected.Cell(address);
                var actualCell = actual.Cell(address);
                bool cellsAreEqual = true;

                if (!expectedCell.HasFormula && !actualCell.HasFormula && actualCell.GetInnerText() != expectedCell.GetInnerText())
                {
                    messages.Add($"Cell values are not equal starting from {address}");
                    cellsAreEqual = false;
                }

                if (!string.Equals(actualCell.FormulaA1, expectedCell.FormulaA1, StringComparison.InvariantCultureIgnoreCase))
                {
                    messages.Add($"Cell formulae are not equal starting from {address}");
                    cellsAreEqual = false;
                }

                if (!expectedCell.HasFormula && actualCell.DataType != expectedCell.DataType)
                {
                    messages.Add($"Cell data types are not equal starting from {address}");
                    cellsAreEqual = false;
                }

                if (expectedCell.HasComment != actualCell.HasComment
                    || (expectedCell.HasComment && !Equals(expectedCell.Comment, actualCell.Comment)))
                {
                    messages.Add($"Cell comments are not equal starting from {address}");
                    cellsAreEqual = false;
                }

                if (expectedCell.HasHyperlink != actualCell.HasHyperlink
                    || (expectedCell.HasHyperlink && !Equals(expectedCell.Hyperlink, actualCell.Hyperlink)))
                {
                    messages.Add($"Cell Hyperlink are not equal starting from {address}");
                    cellsAreEqual = false;
                }

                if (expectedCell.HasRichText != actualCell.HasRichText
                    || (expectedCell.HasRichText && !expectedCell.RichText.Equals(actualCell.RichText)))
                {
                    messages.Add($"Cell RichText are not equal starting from {address}");
                    cellsAreEqual = false;
                }

                if (expectedCell.HasDataValidation != actualCell.HasDataValidation
                    || (expectedCell.HasDataValidation && !Equals(expectedCell.DataValidation, actualCell.DataValidation)))
                {
                    messages.Add($"Cell DataValidation are not equal starting from {address}");
                    cellsAreEqual = false;
                }

                if (expectedCell.Style.ToString() != actualCell.Style.ToString())
                {
                    messages.Add($"Cell style are not equal starting from {address}");
                    cellsAreEqual = false;
                }

                if (!cellsAreEqual)
                    break; // we don't need thousands of messages
            }



            if (expected.MergedRanges.Count() != actual.MergedRanges.Count())
                messages.Add("Merged ranges counts differ");
            else
            {
                var expectedRanges = expected.MergedRanges
                    .OrderBy(r => r.RangeAddress.FirstAddress.ColumnNumber)
                    .ThenBy(r => r.RangeAddress.FirstAddress.RowNumber)
                    .ToList();
                var actualRanges = actual.MergedRanges
                    .OrderBy(r => r.RangeAddress.FirstAddress.ColumnNumber)
                    .ThenBy(r => r.RangeAddress.FirstAddress.RowNumber)
                    .ToList();
                for (int i = 0; i < expectedRanges.Count; i++)
                {
                    var expectedMr = expectedRanges.ElementAt(i);
                    var actualMr = actualRanges.ElementAt(i);
                    if (expectedMr.RangeAddress.ToString() != actualMr.RangeAddress.ToString())
                    {
                        messages.Add($"Merged ranges differ starting from {expectedMr.RangeAddress}");
                        break;
                    }
                }
            }

            if (expected.ConditionalFormats.Count() != actual.ConditionalFormats.Count())
                messages.Add("Conditional format counts differ");
            else
            {
                var expectedFormats = expected.ConditionalFormats
                    .OrderBy(r => r.Range.RangeAddress.FirstAddress.ColumnNumber)
                    .ThenBy(r => r.Range.RangeAddress.FirstAddress.RowNumber)
                    .ToList();
                var actualFormats = actual.ConditionalFormats
                    .OrderBy(r => r.Range.RangeAddress.FirstAddress.ColumnNumber)
                    .ThenBy(r => r.Range.RangeAddress.FirstAddress.RowNumber)
                    .ToList();

                for (int i = 0; i < expectedFormats.Count; i++)
                {
                    var expectedCf = expectedFormats.ElementAt(i);
                    var actualCf = actualFormats.ElementAt(i);

                    if (expectedCf.Range.RangeAddress.ToString() != actualCf.Range.RangeAddress.ToString())
                        messages.Add($"Conditional formats actual {actualCf.Range.RangeAddress}, but expected {expectedCf.Range.RangeAddress}.");

                    if (expectedCf.Style.ToString() != actualCf.Style.ToString())
                        messages.Add($"Conditional formats at {actualCf.Range.RangeAddress} have different styles");

                    if (expectedCf.Values.Count != actualCf.Values.Count)
                        messages.Add($"Conditional formats at {actualCf.Range.RangeAddress} counts differ");

                    for (int j = 1; j <= expectedCf.Values.Count; j++)
                    {
                        if (expectedCf.Values[j].Value != actualCf.Values[j].Value)
                        {
                            messages.Add($"Conditional formats at {actualCf.Range.RangeAddress} have different values");
                            break;
                        }
                    }
                }
            }

            return !messages.Any();
        }

19 Source : EnumHelper.cs
with MIT License
from cloudnative-netcore

public static (IEnumerable<TKey>, IEnumerable<string>) GetMetadata<TEnum, TKey>()
        {
            var keyArray = (TKey[])Enum.GetValues(typeof(TEnum));
            var nameArray = Enum.GetNames(typeof(TEnum));

            IList<TKey> keys = new List<TKey>();
            foreach (var item in keyArray) keys.Add(item);

            IList<string> names = new List<string>();
            foreach (var item in nameArray) names.Add(item);

            return (keys, names);
        }

19 Source : ConstantPool.cs
with GNU General Public License v3.0
from Cm-lang

public static int AllocateStringConstant(string value, int len)
		{
			var index = StringConstants.IndexOf(value);
			if (-1 != index) return index;
			StringConstants.Add(value);
			StringConstantLengths.Add(len);
			return StringConstants.Count - 1;
		}

19 Source : Error.cs
with GNU General Public License v3.0
from Cm-lang

public static void Add(string s)
		{
			ErrList.Add(s);
			if (Pragma.AbortAtFirst) throw new CompilerException("aborted.");
		}

19 Source : WildcardCorsService.cs
with MIT License
from cocosip

private void EvaluateOriginForWildcard(IList<string> origins, string origin)
        {
            //只在没有匹配的origin的情况下进行操作
            if (!origins.Contains(origin))
            {
                //查询所有以星号开头的origin
                var wildcardDomains = origins.Where(o => o.StartsWith("*"));
                if (wildcardDomains.Any())
                {
                    //遍历以星号开头的origin
                    foreach (var wildcardDomain in wildcardDomains)
                    {
                        //如果以.cnblogs.com结尾
                        if (origin.EndsWith(wildcardDomain.Substring(1))
                            //或者以//cnblogs.com结尾,针对http://cnblogs.com
                            || origin.EndsWith("//" + wildcardDomain.Substring(2)) || origin == "*")
                        {
                            origins.Add(origin);
                            break;
                        }
                    }
                }
            }
        }

19 Source : CfgDocument.cs
with MIT License
from codewitch-honey-crisis

public IList<string> FillNonTerminals(IList<string> result = null)
		{
			if (null == result)
				result = new List<string>();
			var ic = Rules.Count;
			for (var i = 0; i < ic; ++i)
			{
				var s = Rules[i].Left;
				if (!result.Contains(s))
					result.Add(s);
			}
			return result;
		}

19 Source : CfgDocument.cs
with MIT License
from codewitch-honey-crisis

public IList<string> FillSymbols(IList<string> result = null)
		{
			if (null == result)
				result = new List<string>();
			var seen = new HashSet<string>();
			var ic = Rules.Count;
			for (var i = 0; i < ic; ++i)
			{
				var s = Rules[i].Left;
				if (seen.Add(s))
					if (!result.Contains(s))
						result.Add(s);
			}
			for (var i = 0; i < ic; ++i)
			{
				var right = Rules[i].Right;
				for (int jc = right.Count, j = 0; j < jc; ++j)
				{
					var s = right[j];
					if (seen.Add(s))
						if (!result.Contains(s))
							result.Add(s);
				}
			}
			foreach (var attrs in AttributeSets)
				if (seen.Add(attrs.Key))
					if (!result.Contains(attrs.Key))
						result.Add(attrs.Key);

			if (!result.Contains("#EOS"))
				result.Add("#EOS");
			if (!result.Contains("#ERROR"))
				result.Add("#ERROR");
			return result;
		}

19 Source : CfgDocument.cs
with MIT License
from codewitch-honey-crisis

public IList<string> FillSymbols(IList<string> result = null)
		{
			if (null == result)
				result = new List<string>();
			var seen = new HashSet<string>();
			var ic = Rules.Count;
			for (var i = 0; i < ic; ++i)
			{
				var s = Rules[i].Left;
				if (seen.Add(s))
					if (!result.Contains(s))
						result.Add(s);
			}
			for (var i = 0; i < ic; ++i)
			{
				var right = Rules[i].Right;
				for (int jc = right.Count, j = 0; j < jc; ++j)
				{
					var s = right[j];
					if (seen.Add(s))
						if (!result.Contains(s))
							result.Add(s);
				}
			}
			foreach (var attrs in AttributeSets)
				if (seen.Add(attrs.Key))
					if (!result.Contains(attrs.Key))
						result.Add(attrs.Key);

			if (!result.Contains("#EOS"))
				result.Add("#EOS");
			if (!result.Contains("#ERROR"))
				result.Add("#ERROR");
			return result;
		}

19 Source : CfgDocument.cs
with MIT License
from codewitch-honey-crisis

public IList<string> FillTerminals(IList<string> result = null)
		{
			if (null == result)
				result = new List<string>();
			var seen = new HashSet<string>();
			var ic = Rules.Count;
			for (var i = 0; i < ic; ++i)
				seen.Add(Rules[i].Left);
			for (var i = 0; i < ic; ++i)
			{
				var right = Rules[i].Right;
				for (int jc = right.Count, j = 0; j < jc; ++j)
				{
					var s = right[j];
					if (seen.Add(s))
						if (!result.Contains(s))
							result.Add(s);
				}
			}
			foreach (var attrs in AttributeSets)
				if (seen.Add(attrs.Key))
					if (!result.Contains(attrs.Key))
						result.Add(attrs.Key);

			if (!result.Contains("#EOS"))
				result.Add("#EOS");
			if (!result.Contains("#ERROR"))
				result.Add("#ERROR");
			return result;
		}

19 Source : CfgDocument.cs
with MIT License
from codewitch-honey-crisis

public IList<string> FillTerminals(IList<string> result = null)
		{
			if (null == result)
				result = new List<string>();
			var seen = new HashSet<string>();
			var ic = Rules.Count;
			for (var i = 0; i < ic; ++i)
				seen.Add(Rules[i].Left);
			for (var i = 0; i < ic; ++i)
			{
				var right = Rules[i].Right;
				for (int jc = right.Count, j = 0; j < jc; ++j)
				{
					var s = right[j];
					if (seen.Add(s))
						if (!result.Contains(s))
							result.Add(s);
				}
			}
			foreach (var attrs in AttributeSets)
				if (seen.Add(attrs.Key))
					if (!result.Contains(attrs.Key))
						result.Add(attrs.Key);

			if (!result.Contains("#EOS"))
				result.Add("#EOS");
			if (!result.Contains("#ERROR"))
				result.Add("#ERROR");
			return result;
		}

19 Source : CfgDocument.cs
with MIT License
from codewitch-honey-crisis

IDictionary<string, ICollection<string>> _FillFirstsNT(IDictionary<string, ICollection<string>> result = null)
		{
			if (null == result)
				result = new Dictionary<string, ICollection<string>>();
			// first add the terminals to the result
			foreach (var t in EnumTerminals())
			{
				var l = new List<string>();
				l.Add(t);
				result.Add(t, l);
			}
			// now for each rule, find every first right hand side and add it to the rule's left non-terminal result
			for (int ic = Rules.Count, i = 0; i < ic; ++i)
			{
				var rule = Rules[i];
				ICollection<string> col;
				if (!result.TryGetValue(rule.Left, out col))
				{
					col = new HashSet<string>();
					result.Add(rule.Left, col);
				}
				if (!rule.IsNil)
				{
					var e = rule.Right[0];
					if (!col.Contains(e))
						col.Add(e);
				}
				else
				{
					// when it's nil, we represent that with a null
					if (!col.Contains(null))
						col.Add(null);
				}
			}

			return result;
		}

19 Source : CfgDocument.cs
with MIT License
from codewitch-honey-crisis

IDictionary<string, ICollection<string>> _FillFirstsNT(IDictionary<string, ICollection<string>> result = null)
		{
			if (null == result)
				result = new Dictionary<string, ICollection<string>>();
			// first add the terminals to the result
			foreach (var t in EnumTerminals())
			{
				var l = new List<string>();
				l.Add(t);
				result.Add(t, l);
			}
			// now for each rule, find every first right hand side and add it to the rule's left non-terminal result
			for (int ic = Rules.Count, i = 0; i < ic; ++i)
			{
				var rule = Rules[i];
				ICollection<string> col;
				if (!result.TryGetValue(rule.Left, out col))
				{
					col = new HashSet<string>();
					result.Add(rule.Left, col);
				}
				if (!rule.IsNil)
				{
					var e = rule.Right[0];
					if (!col.Contains(e))
						col.Add(e);
				}
				else
				{
					// when it's nil, we represent that with a null
					if (!col.Contains(null))
						col.Add(null);
				}
			}

			return result;
		}

See More Examples