System.Collections.Generic.Dictionary.ContainsKey(System.Guid)

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

585 Examples 7

19 Source : CoHandlers.cs
with MIT License
from 3F

public bool Contains(Guid id)
        {
            return has.ContainsKey(id) && has[id];
        }

19 Source : ExampleSearchProvider.cs
with MIT License
from ABTSoftware

private IEnumerable<Guid> RankDoreplacedents(string[] terms, IEnumerable<Guid> examplePageIds, IDictionary<string, Posting> invertedIndex)
        {
            var queryVector = new double[terms.Length];
            var docVectors = new Dictionary<Guid, double[]>();
            var docScores = new Dictionary<Guid, double>();

            for (int i = 0; i < terms.Length; i++)
            {
                string term = terms[i];
                if (!invertedIndex.ContainsKey(term))
                {
                    continue;
                }

                var posting = invertedIndex[term];
                queryVector[i] = (posting.InvertedDoreplacedentFrequency);

                foreach (var termInfo in posting.TermInfos)
                {
                    var examplePageId = termInfo.ExamplePageId;
                    if (examplePageIds.Contains(examplePageId))
                    {
                        if (!docVectors.ContainsKey(examplePageId))
                        {
                            docVectors[examplePageId] = new double[terms.Length];
                        }
                        docVectors[examplePageId][i] = termInfo.TermFrequency;
                    }
                }
            }

            foreach (var docVector in docVectors)
            {
                var dotProduct = DotProduct(docVector.Value, queryVector);
                docScores.Add(docVector.Key, dotProduct);
            }

            return docScores.OrderByDescending(pair => pair.Value).Select(pair => pair.Key);
        }

19 Source : DataBuilder.cs
with MIT License
from abvogel

private void AppendM2MData(List<Enreplacedy> queryResponse, String FirstLinkEnreplacedyName)
        {
            var SourceEnreplacedy = queryResponse.FirstOrDefault().LogicalName;

            Dictionary<Guid, List<Guid>> relationshipPairs = new Dictionary<Guid, List<Guid>>();
            String relationshipName = queryResponse.FirstOrDefault().Attributes.Where(x => x.Value is AliasedValue).Select(x => ((AliasedValue)x.Value).EnreplacedyLogicalName).First();

            if (RelationshipIsReflexive(queryResponse.FirstOrDefault().LogicalName, relationshipName))
            {
                relationshipName = FirstLinkEnreplacedyName;
            }

            foreach (var record in queryResponse)
            {
                Guid relatedId = ((Guid)record.Attributes.Where(x => x.Value is AliasedValue).Select(x => ((AliasedValue)x.Value).Value).First());

                if (!relationshipPairs.ContainsKey(record.Id))
                {
                    relationshipPairs[record.Id] = new List<Guid>();
                }
                
                relationshipPairs[record.Id].Add(relatedId);
            }

            this.VerifyEnreplacedyExists(SourceEnreplacedy);
            foreach (var relationshipPair in relationshipPairs)
            {
                this._Enreplacedies[SourceEnreplacedy].AppendEnreplacedy(new Enreplacedy(SourceEnreplacedy, relationshipPair.Key));
            }
            this._Enreplacedies[SourceEnreplacedy].AppendM2MDataToEnreplacedy(relationshipName, relationshipPairs);
        }

19 Source : BuilderEntityMetadata.cs
with MIT License
from abvogel

public void RemoveRelationshipsWhereIdentical(String relationshipName, Dictionary<Guid, List<Guid>> relatedEnreplacedies)
        {
            if (!RelatedEnreplacedies.ContainsKey(relationshipName))
                return;

            foreach (var id in relatedEnreplacedies.Keys)
            {
                if (!RelatedEnreplacedies[relationshipName].ContainsKey(id))
                    return;

                var newRelatedIds = this.RelatedEnreplacedies[relationshipName][id].Except(relatedEnreplacedies[id]);
                if (newRelatedIds.Count() == 0)
                {
                    this.RelatedEnreplacedies[relationshipName].Remove(id);
                    if (this.RelatedEnreplacedies[relationshipName].Count == 0)
                        this.RelatedEnreplacedies.Remove(relationshipName);
                } else
                {
                    this.RelatedEnreplacedies[relationshipName][id] = newRelatedIds.ToList();
                }
            }
        }

19 Source : BuilderEntityMetadata.cs
with MIT License
from abvogel

public void AppendM2MDataToEnreplacedy(String relationshipName, Dictionary<Guid, List<Guid>> relatedEnreplacedies)
        {
            if (!RelatedEnreplacedies.ContainsKey(relationshipName))
                this.RelatedEnreplacedies[relationshipName] = new Dictionary<Guid, List<Guid>>();

            foreach (var id in relatedEnreplacedies.Keys)
            {
                if (!RelatedEnreplacedies[relationshipName].ContainsKey(id))
                    this.RelatedEnreplacedies[relationshipName][id] = new List<Guid>();

                this.RelatedEnreplacedies[relationshipName][id].AddRange(relatedEnreplacedies[id]);
                this.RelatedEnreplacedies[relationshipName][id] = RelatedEnreplacedies[relationshipName][id].Distinct().ToList();
            }
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

private Feature GetOrAddFeatureFromDefinitions(Guid featureId, SPFeatureScope scope)
        {
            Feature feature = null;
            if (!_AllFeatureDefinitions.ContainsKey(featureId))
            {
                // Not sure if this can happen (an undefined feature is activated)
                // but in case, manufacture an empty definition for it in our list
                feature = new Feature(featureId, scope);
                _AllFeatureDefinitions.Add(featureId, feature);
            }
            else
            {
                feature = _AllFeatureDefinitions[featureId];
            }
            return feature;
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

private void AddToFeatureLocations(Feature feature, Location location)
        {
            if (!_FeatureLocations.ContainsKey(feature.Id))
            {
                _FeatureLocations.Add(feature.Id, new List<Location>());
            }
            List<Location> locations = _FeatureLocations[feature.Id];
            if (!locations.Contains(location))
            {
                locations.Add(location);
                UpdateFeatureLocationCount(feature.Id);
            }
        }

19 Source : ActivationFinder.cs
with Microsoft Public License
from achimismaili

private void ReportFeature(object obj, bool faulty, SPFeatureScope scope, Guid featureId, string url, string name)
        {
            OnFoundFeature(featureId, url, name);
            Location location = LocationManager.GetLocation(obj);
            List<Location> locs = null;
            if (featureLocations.ContainsKey(featureId))
            {
                locs = featureLocations[featureId];
            }
            else
            {
                locs = new List<Location>();
            }
            locs.Add(location);
            featureLocations[featureId] = locs;
            if (faulty)
            {
                int faults = 0;
                if (faultyFeatures.ContainsKey(featureId))
                {
                    faults = faultyFeatures[featureId];
                }
                ++faults;
                faultyFeatures[featureId] = faults;
            }
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

public List<Location> GetLocationsOfFeature(Guid featureId)
        {
            if (_FeatureLocations.ContainsKey(featureId))
            {
                return _FeatureLocations[featureId];
            }
            else
            {
                return new List<Location>();
            }
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

public void MarkFaulty(List<Guid> featureIds)
        {
            foreach (Guid featureId in featureIds)
            {
                Feature feature = null;
                if (_AllFeatureDefinitions.ContainsKey(featureId))
                {
                    feature = _AllFeatureDefinitions[featureId];
                }
                else
                {
                    feature = new Feature(featureId);
                }
                feature.IsFaulty = true;
                _AllFeatureDefinitions[featureId] = feature;
            }
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

private void UpdateFeatureLocationCount(Guid featureId)
        {
            Feature feature = _AllFeatureDefinitions[featureId];
            int count = 0;
            if (_FeatureLocations.ContainsKey(featureId))
            {
                count = _FeatureLocations[featureId].Count;
            }
            feature.Activations = count;
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

private void RemoveFromFeatureLocations(Feature feature, Location location)
        {
            if (_FeatureLocations.ContainsKey(feature.Id))
            {
                List<Location> locations = _FeatureLocations[feature.Id];
                if (locations.Contains(location))
                {
                    locations.Remove(location);
                }
                UpdateFeatureLocationCount(feature.Id);
            }
        }

19 Source : TaskManagerActor.cs
with Microsoft Public License
from achimismaili

public void Handle([NotNull] Confirmation message)
        {
            if (taskActors.ContainsKey(message.TaskId))
            {
                taskActors[message.TaskId].Tell(message);
            }
            else
            {
                eventAggregator.PublishOnUIThread(
                    new Messages.LogMessage(Core.Models.Enums.LogLevel.Error,
                    string.Format("Internal error. Confirmed task with task id {0} was not found anymore!", message.TaskId)
                    ));
            }
        }

19 Source : ActivationFinder.cs
with Microsoft Public License
from achimismaili

private void ReportFeature(SPFeatureScope scope, Guid featureId, string url, string name)
        {
            OnFoundFeature(featureId, url, name);
            Location location = new Location();
            location.Scope = scope;
            location.FeatureId = featureId;
            location.Url = url;
            location.Name = name;
            List<Location> locs = null;
            if (featureLocations.ContainsKey(featureId))
            {
                locs = featureLocations[featureId];
            }
            else
            {
                locs = new List<Location>();
            }
            locs.Add(location);
            featureLocations[featureId] = locs;
        }

19 Source : ActivationFinder.cs
with Microsoft Public License
from achimismaili

private void ReportFeature(object obj, bool faulty, SPFeatureScope scope, Guid featureId, string url, string name)
        {
            OnFoundFeature(featureId, url, name);
            FeatureParent location = LocationManager.GetLocation(obj);
            List<FeatureParent> locs = null;
            if (featureLocations.ContainsKey(featureId))
            {
                locs = featureLocations[featureId];
            }
            else
            {
                locs = new List<FeatureParent>();
            }
            locs.Add(location);
            featureLocations[featureId] = locs;
            if (faulty)
            {
                int faults = 0;
                if (faultyFeatures.ContainsKey(featureId))
                {
                    faults = faultyFeatures[featureId];
                }
                ++faults;
                faultyFeatures[featureId] = faults;
            }
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

public List<FeatureParent> GetLocationsOfFeature(Guid featureId)
        {
            if (_FeatureLocations.ContainsKey(featureId))
            {
                return _FeatureLocations[featureId];
            }
            else
            {
                return new List<FeatureParent>();
            }
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

private void AddToFeatureLocations(Feature feature, FeatureParent location)
        {
            if (!_FeatureLocations.ContainsKey(feature.Id))
            {
                _FeatureLocations.Add(feature.Id, new List<FeatureParent>());
            }
            List<FeatureParent> locations = _FeatureLocations[feature.Id];
            if (!locations.Contains(location))
            {
                locations.Add(location);
                UpdateFeatureLocationCount(feature.Id);
            }
        }

19 Source : FeatureDatabase.cs
with Microsoft Public License
from achimismaili

private void RemoveFromFeatureLocations(Feature feature, FeatureParent location)
        {
            if (_FeatureLocations.ContainsKey(feature.Id))
            {
                List<FeatureParent> locations = _FeatureLocations[feature.Id];
                if (locations.Contains(location))
                {
                    locations.Remove(location);
                }
                UpdateFeatureLocationCount(feature.Id);
            }
        }

19 Source : JobServerQueue.cs
with MIT License
from actions

private async Task ProcessTimelinesUpdateQueueAsync(bool runOnce = false)
        {
            while (!_jobCompletionSource.Task.IsCompleted || runOnce)
            {
                List<PendingTimelineRecord> pendingUpdates = new List<PendingTimelineRecord>();
                foreach (var timeline in _allTimelines)
                {
                    ConcurrentQueue<TimelineRecord> recordQueue;
                    if (_timelineUpdateQueue.TryGetValue(timeline, out recordQueue))
                    {
                        List<TimelineRecord> records = new List<TimelineRecord>();
                        TimelineRecord record;
                        while (recordQueue.TryDequeue(out record))
                        {
                            records.Add(record);
                            // process at most 25 timeline records update for each timeline.
                            if (!runOnce && records.Count > 25)
                            {
                                break;
                            }
                        }

                        if (records.Count > 0)
                        {
                            pendingUpdates.Add(new PendingTimelineRecord() { TimelineId = timeline, PendingRecords = records.ToList() });
                        }
                    }
                }

                // we need track whether we have new sub-timeline been created on the last run.
                // if so, we need continue update timeline record even we on the last run.
                bool pendingSubtimelineUpdate = false;
                List<Exception> mainTimelineRecordsUpdateErrors = new List<Exception>();
                if (pendingUpdates.Count > 0)
                {
                    foreach (var update in pendingUpdates)
                    {
                        List<TimelineRecord> bufferedRecords;
                        if (_bufferedRetryRecords.TryGetValue(update.TimelineId, out bufferedRecords))
                        {
                            update.PendingRecords.InsertRange(0, bufferedRecords);
                        }

                        update.PendingRecords = MergeTimelineRecords(update.PendingRecords);

                        foreach (var detailTimeline in update.PendingRecords.Where(r => r.Details != null))
                        {
                            if (!_allTimelines.Contains(detailTimeline.Details.Id))
                            {
                                try
                                {
                                    Timeline newTimeline = await _jobServer.CreateTimelineAsync(_scopeIdentifier, _hubName, _planId, detailTimeline.Details.Id, default(CancellationToken));
                                    _allTimelines.Add(newTimeline.Id);
                                    pendingSubtimelineUpdate = true;
                                }
                                catch (TimelineExistsException)
                                {
                                    Trace.Info("Catch TimelineExistsException during timeline creation. Ignore the error since server already had this timeline.");
                                    _allTimelines.Add(detailTimeline.Details.Id);
                                }
                                catch (Exception ex)
                                {
                                    Trace.Error(ex);
                                }
                            }
                        }

                        try
                        {
                            await _jobServer.UpdateTimelineRecordsAsync(_scopeIdentifier, _hubName, _planId, update.TimelineId, update.PendingRecords, default(CancellationToken));
                            if (_bufferedRetryRecords.Remove(update.TimelineId))
                            {
                                Trace.Verbose("Cleanup buffered timeline record for timeline: {0}.", update.TimelineId);
                            }

                            if (!_jobRecordUpdated.Task.IsCompleted &&
                                update.PendingRecords.Any(x => x.Id == _jobTimelineRecordId && x.State != null))
                            {
                                // We have changed the state of the job
                                Trace.Info("Job timeline record has been updated for the first time.");
                                _jobRecordUpdated.TrySetResult(0);
                            }
                        }
                        catch (Exception ex)
                        {
                            Trace.Info("Catch exception during update timeline records, try to update these timeline records next time.");
                            Trace.Error(ex);
                            _bufferedRetryRecords[update.TimelineId] = update.PendingRecords.ToList();
                            if (update.TimelineId == _jobTimelineId)
                            {
                                mainTimelineRecordsUpdateErrors.Add(ex);
                            }
                        }
                    }
                }

                if (runOnce)
                {
                    // continue process timeline records update, 
                    // we might have more records need update, 
                    // since we just create a new sub-timeline
                    if (pendingSubtimelineUpdate)
                    {
                        continue;
                    }
                    else
                    {
                        if (mainTimelineRecordsUpdateErrors.Count > 0 &&
                            _bufferedRetryRecords.ContainsKey(_jobTimelineId) &&
                            _bufferedRetryRecords[_jobTimelineId] != null &&
                            _bufferedRetryRecords[_jobTimelineId].Any(r => r.Variables.Count > 0))
                        {
                            Trace.Info("Fail to update timeline records with output variables. Throw exception to fail the job since output variables are critical to downstream jobs.");
                            throw new AggregateException("Failed to publish output variables.", mainTimelineRecordsUpdateErrors);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    await Task.Delay(_delayForTimelineUpdateDequeue);
                }
            }
        }

19 Source : JobServerQueue.cs
with MIT License
from actions

private async Task ProcessWebConsoleLinesQueueAsync(bool runOnce = false)
        {
            while (!_jobCompletionSource.Task.IsCompleted || runOnce)
            {
                if (_webConsoleLineAggressiveDequeue && ++_webConsoleLineAggressiveDequeueCount > _webConsoleLineAggressiveDequeueLimit)
                {
                    Trace.Info("Stop aggressive process web console line queue.");
                    _webConsoleLineAggressiveDequeue = false;
                }

                // Group consolelines by timeline record of each step
                Dictionary<Guid, List<TimelineRecordLogLine>> stepsConsoleLines = new Dictionary<Guid, List<TimelineRecordLogLine>>();
                List<Guid> stepRecordIds = new List<Guid>(); // We need to keep lines in order
                int linesCounter = 0;
                ConsoleLineInfo lineInfo;
                while (_webConsoleLineQueue.TryDequeue(out lineInfo))
                {
                    if (!stepsConsoleLines.ContainsKey(lineInfo.StepRecordId))
                    {
                        stepsConsoleLines[lineInfo.StepRecordId] = new List<TimelineRecordLogLine>();
                        stepRecordIds.Add(lineInfo.StepRecordId);
                    }

                    if (!string.IsNullOrEmpty(lineInfo.Line) && lineInfo.Line.Length > 1024)
                    {
                        Trace.Verbose("Web console line is more than 1024 chars, truncate to first 1024 chars");
                        lineInfo.Line = $"{lineInfo.Line.Substring(0, 1024)}...";
                    }

                    stepsConsoleLines[lineInfo.StepRecordId].Add(new TimelineRecordLogLine(lineInfo.Line, lineInfo.LineNumber));
                    linesCounter++;

                    // process at most about 500 lines of web console line during regular timer dequeue task.
                    if (!runOnce && linesCounter > 500)
                    {
                        break;
                    }
                }

                // Batch post consolelines for each step timeline record
                foreach (var stepRecordId in stepRecordIds)
                {
                    // Split consolelines into batch, each batch will container at most 100 lines.
                    int batchCounter = 0;
                    List<List<TimelineRecordLogLine>> batchedLines = new List<List<TimelineRecordLogLine>>();
                    foreach (var line in stepsConsoleLines[stepRecordId])
                    {
                        var currentBatch = batchedLines.ElementAtOrDefault(batchCounter);
                        if (currentBatch == null)
                        {
                            batchedLines.Add(new List<TimelineRecordLogLine>());
                            currentBatch = batchedLines.ElementAt(batchCounter);
                        }

                        currentBatch.Add(line);

                        if (currentBatch.Count >= 100)
                        {
                            batchCounter++;
                        }
                    }

                    if (batchedLines.Count > 0)
                    {
                        // When job finish, web console lines becomes less interesting to customer
                        // We batch and produce 500 lines of web console output every 500ms
                        // If customer's task produce mreplacedive of outputs, then the last queue drain run might take forever.
                        // So we will only upload the last 200 lines of each step from all buffered web console lines.
                        if (runOnce && batchedLines.Count > 2)
                        {
                            Trace.Info($"Skip {batchedLines.Count - 2} batches web console lines for last run");
                            batchedLines = batchedLines.TakeLast(2).ToList();
                        }

                        int errorCount = 0;
                        foreach (var batch in batchedLines)
                        {
                            try
                            {
                                // we will not requeue failed batch, since the web console lines are time sensitive.
                                if (batch[0].LineNumber.HasValue)
                                {
                                    await _jobServer.AppendTimelineRecordFeedAsync(_scopeIdentifier, _hubName, _planId, _jobTimelineId, _jobTimelineRecordId, stepRecordId, batch.Select(logLine => logLine.Line).ToList(), batch[0].LineNumber.Value, default(CancellationToken));
                                }
                                else
                                {
                                    await _jobServer.AppendTimelineRecordFeedAsync(_scopeIdentifier, _hubName, _planId, _jobTimelineId, _jobTimelineRecordId, stepRecordId, batch.Select(logLine => logLine.Line).ToList(), default(CancellationToken));
                                }

                                if (_firstConsoleOutputs)
                                {
                                    HostContext.WritePerfCounter($"WorkerJobServerQueueAppendFirstConsoleOutput_{_planId.ToString()}");
                                    _firstConsoleOutputs = false;
                                }
                            }
                            catch (Exception ex)
                            {
                                Trace.Info("Catch exception during append web console line, keep going since the process is best effort.");
                                Trace.Error(ex);
                                errorCount++;
                            }
                        }

                        Trace.Info("Try to append {0} batches web console lines for record '{2}', success rate: {1}/{0}.", batchedLines.Count, batchedLines.Count - errorCount, stepRecordId);
                    }
                }

                if (runOnce)
                {
                    break;
                }
                else
                {
                    await Task.Delay(_webConsoleLineAggressiveDequeue ? _aggressiveDelayForWebConsoleLineDequeue : _delayForWebConsoleLineDequeue);
                }
            }
        }

19 Source : ExecutionContext.cs
with MIT License
from actions

public void RegisterPostJobStep(IStep step)
        {
            string siblingScopeName = null;
            if (this.IsEmbedded)
            {
                if (step is IActionRunner actionRunner)
                {
                    if (Root.EmbeddedStepsWithPostRegistered.ContainsKey(actionRunner.Action.Id))
                    {
                        Trace.Info($"'post' of '{actionRunner.DisplayName}' already push to child post step stack.");
                    }
                    else 
                    {
                        Root.EmbeddedStepsWithPostRegistered[actionRunner.Action.Id] = actionRunner.Condition;    
                    }
                    return;
                }
            }
            else if (step is IActionRunner actionRunner && !Root.StepsWithPostRegistered.Add(actionRunner.Action.Id))
            {
                Trace.Info($"'post' of '{actionRunner.DisplayName}' already push to post step stack.");
                return;
            }
            if (step is IActionRunner runner)
            {
                siblingScopeName = runner.Action.ContextName;
            }

            step.ExecutionContext = Root.CreatePostChild(step.DisplayName, IntraActionState, siblingScopeName);
            Root.PostJobSteps.Push(step);
        }

19 Source : ContentMapProvider.cs
with MIT License
from Adoxio

private static void Refresh(CrmDbContext context, ContentMap map, List<EnreplacedyReference> references)
		{
			if (references.Count > 0)
			{
				references[0].ThrowOnNull("reference");
				EnreplacedyDefinition ed;
				Dictionary<Guid, Enreplacedy> mapEnreplacedies = new Dictionary<Guid, Enreplacedy>();
				bool getEnreplacedyDefinition = map.Solution.Enreplacedies.TryGetValue(references[0].LogicalName, out ed);

				if (getEnreplacedyDefinition)
				{
					List<Guid> guids = new List<Guid>();
					foreach (var reference in references)
					{
						reference.ThrowOnNull("reference");
						guids.Add(reference.Id);
						ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("LogicalName={0}, Id={1}", EnreplacedyNamePrivacy.GetEnreplacedyName(reference.LogicalName), reference.Id));
					}
					try
					{
						string primaryEnreplacedyAttribute = EventHubBasedInvalidation.CrmChangeTrackingManager.Instance.TryGetPrimaryKey(references[0].LogicalName);

						var enreplacedies = RetrieveCRMRecords(context, primaryEnreplacedyAttribute, references[0], ed, guids);
						foreach (var enreplacedy in enreplacedies)
						{
							mapEnreplacedies.Add(enreplacedy.Id, enreplacedy);
						}

						ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Retrieve Multiple Response for Enreplacedy {0} has Record Count {1} , Refrence Count {2} ", references[0].LogicalName, enreplacedies.Count, references.Count));

						// check if the enreplacedy is inactive according to the definition
						foreach (var reference in references)
						{
							var enreplacedy = mapEnreplacedies.ContainsKey(reference.Id) ? (Enreplacedy)mapEnreplacedies[reference.Id] : null;

							// Check if the enreplacedy matches on the defined relationships.
							if (!ed.ShouldIncludeInContentMap(enreplacedy))
							{
								continue;
							}

							var option = enreplacedy != null ? enreplacedy.GetAttributeValue<OptionSetValue>("statecode") : null;
							var isActive = ed.ActiveStateCode == null || (option != null && ed.ActiveStateCode.Value == option.Value);
							var node = map.Using(ContentMapLockType.Write, () => enreplacedy != null
								? isActive
									? map.Replace(enreplacedy)
									: map.Deactivate(reference)
								: map.Remove(reference));
						}

					}
					catch (FaultException<OrganizationServiceFault>)
					{
						// an exception occurs when trying to retrieve a non-existing enreplacedy
						ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("An exception occurs when trying to retrieve a non-existing enreplacedy"));
					}
				}
				else
				{
					ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Unknown: logicalName={0}", EnreplacedyNamePrivacy.GetEnreplacedyName(references[0].LogicalName)));
				}
			}
		}

19 Source : PortalCacheInvalidatorThread.cs
with MIT License
from Adoxio

private List<string> PostRequest(IEnumerable<PluginMessage> messages, bool isMetadataChangeMessage, bool isSearchIndexInvalidation = false)
		{
			List<string> enreplacediesWithSuccessfulInvalidation = new List<string>();
			try
			{
				var batchedMessages = messages
					.Where(mesg => mesg != null)
					.GroupBy(mesg => mesg.Target == null ? string.Empty : mesg.Target.LogicalName);

				foreach (var batchedmessage in batchedMessages)
				{
					List<OrganizationServiceCachePluginMessage> batchedPluginMessage = new List<OrganizationServiceCachePluginMessage>();
					var searchInvalidationDatum = new Dictionary<Guid, SearchIndexBuildRequest.SearchIndexInvalidationData>();

					foreach (var changedItem in batchedmessage)
					{
						if (changedItem != null)
						{
							if (changedItem.Target != null)
							{
								ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Posting Request for message with Enreplacedy: {0} and ChangeType: {1}", changedItem.Target.LogicalName, changedItem.MessageName));
							}

							var restartMessage = new ApplicationRestartPortalBusMessage();
							
							// Conversion to OrganizationServiceCachePluginMessage type
							var message = new OrganizationServiceCachePluginMessage();
							message.MessageName = changedItem.MessageName;
							message.RelatedEnreplacedies = changedItem.RelatedEnreplacedies;
							message.Relationship = changedItem.Relationship;
							message.Target = changedItem.Target;

							if (restartMessage.Validate(changedItem))
							{
								// The restart messages should be processed only once when the message is received from Cache subscription.
								if (!isSearchIndexInvalidation)
								{
									// restart the web application
									var task = restartMessage.InvokeAsync(new OwinContext()).WithCurrentCulture();
									task.GetAwaiter().GetResult();
									SearchIndexBuildRequest.ProcessMessage(message);
								}
							}
							else
							{
								if (!isSearchIndexInvalidation && FeatureCheckHelper.IsFeatureEnabled(FeatureNames.CmsEnabledSearching) && message.Target != null && message.Target.Id != Guid.Empty)
								{
									// Get relevant info for search index invalidation from content map before cache invalidation
									// MUST OCCUR BEFORE CACHE INVALIDATION
									if (!searchInvalidationDatum.ContainsKey(message.Target.Id))
									{
										searchInvalidationDatum.Add(message.Target.Id, GetSearchIndexInvalidationData(message));
									}
								}
								batchedPluginMessage.Add(message);
							}
						}
						else
						{
							//logging
							ADXTrace.Instance.TraceWarning(TraceCategory.Application, string.Format("ChangedItem Record is Null "));
						}
					}
					if (batchedPluginMessage.Count > 0)
					{
						if (isMetadataChangeMessage)
						{
							// Invalidate both search index as well as cache
							try
							{
								InvalidateSearchIndex(batchedPluginMessage, searchInvalidationDatum);
							}
							catch (Exception e)
							{
								// Even if exception occurs, we still need to invalidate cache, hence cathing exception here and logging error.
								ADXTrace.Instance.TraceError(TraceCategory.Exception, e.ToString());
							}
							InvalidateCache(batchedPluginMessage);
						}
						else if (isSearchIndexInvalidation)
						{
							InvalidateSearchIndex(batchedPluginMessage, searchInvalidationDatum);
						}
						else
						{
							// Invalidate cache
							InvalidateCache(batchedPluginMessage);
						}
					}

					enreplacediesWithSuccessfulInvalidation.Add(batchedmessage.Key);
				}
				return enreplacediesWithSuccessfulInvalidation;
			}
			catch (Exception e)
			{
				ADXTrace.Instance.TraceError(TraceCategory.Application, e.ToString());
				return enreplacediesWithSuccessfulInvalidation;
			}
		}

19 Source : ContentMapEntityUrlProvider.cs
with MIT License
from Adoxio

private bool? CircularReferenceCheck(WebPageNode page)
		{
			var pageDetails = new Dictionary<Guid, string>();

			if (page.IsCircularReference == null)
			{
				while (page.Parent != null)
				{
					if (pageDetails.ContainsKey(page.Id) && page.Id != Guid.Empty)
					{
						page.IsCircularReference = true;
						return true;
					}
					else
					{
						pageDetails.Add(page.Id, page.Name);
					}

					page = page.Parent;
				}

				page.IsCircularReference = false;
			}

			return page.IsCircularReference;
		}

19 Source : TraceManager.cs
with Apache License 2.0
from airbus-cert

public static UserTrace BuildFromConfig(IniData config, IETWWriter writer)
        {
            var providers = new Dictionary<Guid, Provider>();

            foreach (var providerConfig in config.Sections)
            {
                // try to parse filtering provider
                var providerDeclaration = providerConfig.SectionName.Split(new string[] { "://" }, StringSplitOptions.RemoveEmptyEntries);
                if (providerDeclaration.Length > 2)
                    continue;

                string providerName = providerDeclaration[0];

                // Try to parse provider name
                ProviderGuid providerGuid = null;
                if (!ProviderGuid.TryParse(providerName, out providerGuid))
                {
                    continue;
                }

                Forwarder forwarder = null;
                if (!Forwarder.TryBuild(providerGuid, out forwarder))
                {
                    continue;
                }

                UInt16? eventId = null;
                if (providerDeclaration.Length == 2)
                {
                    UInt16 tmp = 0;
                    if (!UInt16.TryParse(providerDeclaration[1], out tmp))
                        continue;
                    eventId = tmp;
                }

                if (!providers.ContainsKey(providerGuid.Guid))
                {
                    providers.Add(providerGuid.Guid, new Provider(providerGuid.Guid));
                }

                var provider = providers[providerGuid.Guid];

                var predicate = Filter.AnyEvent();

                if (eventId != null)
                {
                    predicate = Filter.EventIdIs(eventId.Value);
                }

                var filter = new EventFilter(predicate);
                foreach (var keyValue in providerConfig.Keys)
                {
                    forwarder.AddFilter(keyValue.KeyName, keyValue.Value);
                }

                filter.OnEvent += (IEventRecord record) =>
                {
                    try
                    {
                        forwarder.Forward(record, writer).Wait();
                    }
                    catch (System.AggregateException) { } // Some event ae not doreplacedented even for Microsoft
                };

                provider.AddFilter(filter);
            }

            if (providers.Count == 0)
            {
                throw new Exception("Unable to create a trace without provider");
            }

            UserTrace trace = new UserTrace(String.Format("Splunk-ETW-{0}", Guid.NewGuid().ToString()));
            foreach(var provider in providers.Values)
            {
                trace.Enable(provider);
            }

            return trace;
        }

19 Source : CommanderStatus.cs
with MIT License
from alerdenisov

public void Destroy(Guid id)
        {
            if(!enreplacedies.ContainsKey(id))
            {
                Debug.LogError("Unknown id: " + id);
                return;
            }

            if (enreplacedies[id].gameObject)
                GameObject.Destroy(enreplacedies[id].gameObject, 0.1f);

            enreplacedies.Remove(id);
            table.Release(id);
        }

19 Source : OwnTable.cs
with MIT License
from alerdenisov

public void Obtain(Guid id, int owner)
        {
            if (!enreplacedyOwners.ContainsKey(id))
                enreplacedyOwners.Add(id, -1);

            enreplacedyOwners[id] = owner;
        }

19 Source : OwnTable.cs
with MIT License
from alerdenisov

public void Release(Guid id)
        {
            if (enreplacedyOwners.ContainsKey(id))
                enreplacedyOwners.Remove(id);
        }

19 Source : CommanderStatus.cs
with MIT License
from alerdenisov

public void Damage(Guid id, float amount, Vector3? point = null, Vector3? force = null)
        {
            if(!enreplacedies.ContainsKey(id))
            {
                Debug.LogError("Unknown id: " + id);
                return;
            }

            var enreplacedy = enreplacedies[id] as VitalEnreplacedy;

            if(!enreplacedy)
            {
                Debug.LogError("Non vital enreplacedy: " + enreplacedies[id]);
                return;
            }

            if(!point.HasValue)
            {
                point = enreplacedy.transform.position;
            }

            if(!force.HasValue)
            {
                force = Vector3.forward;
            }

            enreplacedy.DamageReceive(amount, point.Value, force.Value);
        }

19 Source : OwnTable.cs
with MIT License
from alerdenisov

public int Owner(Guid id)
        {
            if (enreplacedyOwners.ContainsKey(id))
                return enreplacedyOwners[id];
            else
                return -1;
        }

19 Source : ID2D1Factory1.cs
with MIT License
from amerkoleci

public void RegisterEffect<T>(Func<T> effectFactory, Guid effectId) where T : ID2D1EffectImpl
        {
            CustomEffectFactory factory;
            lock (_customEffectFactories)
            {
                if (_customEffectFactories.ContainsKey(effectId))
                    throw new ArgumentException("An effect is already registered with this GUID", nameof(effectFactory));

                factory = new CustomEffectFactory(typeof(T), () => effectFactory());
                _customEffectFactories.Add(effectId, factory);
            }
            RegisterEffectFromString(effectId, factory.GetXML(), factory.GetBindings(), factory.Callback);
        }

19 Source : ID2D1Factory1.cs
with MIT License
from amerkoleci

public void RegisterEffect<T>(Guid effectId) where T : ID2D1EffectImpl, new()
        {
            lock (_customEffectFactories)
            {
                if (_customEffectFactories.ContainsKey(effectId))
                    return;

                var factory = new CustomEffectFactory(typeof(T), () => new T());
                _customEffectFactories.Add(effectId, factory);
                RegisterEffectFromString(effectId, factory.GetXML(), factory.GetBindings(), factory.Callback);
            }
        }

19 Source : ID2D1Factory1.cs
with MIT License
from amerkoleci

public void UnregisterEffect<T>() where T : CustomEffectBase, new()
        {
            lock (_customEffectFactories)
            {
                Guid effectGuid = typeof(T).GUID;
                if (!_customEffectFactories.ContainsKey(effectGuid))
                    return;

                _customEffectFactories.Remove(effectGuid);
                UnregisterEffect(effectGuid);
            }
        }

19 Source : AnalogyOnDemandPlottingManager.cs
with MIT License
from Analogy-LogViewer

private void Plotter_OnNewPointsData(object sender, (Guid Id, IEnumerable<replacedogyPlottingPointData> PointsData) e)
        {
            if (!Data.ContainsKey(e.Id))
            {
                Data[e.Id] = new List<replacedogyPlottingPointData>();
                SeriesNames[e.Id] = new List<string>();
            }

            Data[e.Id].AddRange(e.PointsData);
            foreach (var item in e.PointsData)
            {
                if (!SeriesNames[e.Id].Contains(item.Name))
                {
                    SeriesNames[e.Id].Add(item.Name);
                    OnNewSeries?.Invoke(this, (e.Id, item.Name));
                }
            }

            OnNewPointsData?.Invoke(sender, e);
        }

19 Source : AnalogyOnDemandPlottingManager.cs
with MIT License
from Analogy-LogViewer

public void ClosePlot(Guid id)
        {
            if (Plots.ContainsKey(id) && !Plots[id].IsDisposed && Plots[id].Visible)
            {
                OnHidePlot.Invoke(this, Plots[id]);
            }
        }

19 Source : AnalogyOnDemandPlottingManager.cs
with MIT License
from Analogy-LogViewer

public void ClearSeriesData(Guid id, string seriesNameToClear)
        {
            if (Plots.ContainsKey(id) && !Plots[id].IsDisposed && Plots[id].Visible)
            {
                var plot = Plots[id];
                plot.ClearSeriesData(seriesNameToClear);
                if (Data.TryGetValue(id, out var pts))
                {
                    var filtered = pts.Where(p => p.Name != seriesNameToClear).ToList();
                    Data[id] = filtered;
                }
            }
        }

19 Source : AnalogyOnDemandPlottingManager.cs
with MIT License
from Analogy-LogViewer

public void ClearAllData(Guid id)
        {
            if (Plots.ContainsKey(id) && !Plots[id].IsDisposed && Plots[id].Visible)
            {
                var plot = Plots[id];
                plot.ClearAllData();
                Data.Remove(id);
            }
        }

19 Source : AnalogyOnDemandPlottingManager.cs
with MIT License
from Analogy-LogViewer

public List<string> GetSeriesNames(Guid id)
        {
            if (!Plots.ContainsKey(id))
            {
                List<string> names = new List<string>();
                if (Data.TryGetValue(id, out var data))
                {
                    names.AddRange(data.Select(d => d.Name).Distinct());
                }

                return names;
            }

            return new List<string>(0);
        }

19 Source : AnalogyOnDemandPlottingManager.cs
with MIT License
from Analogy-LogViewer

public List<replacedogyPlottingPointData> GetData(Guid id)
        {
            if (Data.ContainsKey(id))
            {
                return Data[id];
            }

            return new List<replacedogyPlottingPointData>();
        }

19 Source : AnalogyOnDemandPlottingManager.cs
with MIT License
from Analogy-LogViewer

public void ShowPlot(Guid id, string plotreplacedle, replacedogyOnDemandPlottingStartupType startupType)
        {
            if (!Plots.ContainsKey(id) || (Plots.ContainsKey(id) && Plots[id].IsDisposed))
            {
                var uc = new OnDemandPlottingUC(id, plotreplacedle);
                uc.Hide();
                Plots[id] = uc;
            }

            OnShowPlot.Invoke(this, (Plots[id], startupType));
        }

19 Source : AnalogyOnDemandPlottingManager.cs
with MIT License
from Analogy-LogViewer

public void RemoveSeriesFromPlot(Guid id, string seriesName)
        {
            if (Plots.ContainsKey(id) && !Plots[id].IsDisposed && Plots[id].Visible)
            {
                var plot = Plots[id];
                plot.RemoveSeriesFromPlot(seriesName);
            }
        }

19 Source : ConfigurationCollection.cs
with GNU General Public License v3.0
from AndreiFedarets

private void Initialize()
        {
            if (_initialized)
            {
                return;
            }
            List<IConfiguration> remoteConfigurations = Execute(() => RemoteObject.ToList());
            if (remoteConfigurations.Count == _collection.Count)
            {
                return;
            }
            foreach (IConfiguration remoteConfiguration in remoteConfigurations)
            {
                Configuration configuration = new Configuration(remoteConfiguration, _application);
                if (!_collection.ContainsKey(configuration.Uid))
                {
                    _collection.Add(configuration.Uid, configuration);
                }
            }
            _initialized = true;
        }

19 Source : UniqueSettingsCollection.cs
with GNU General Public License v3.0
from AndreiFedarets

public bool Contains(Guid uid)
        {
            lock (Collection)
            {
                return Collection.ContainsKey(uid);
            }
        }

19 Source : RequestServer.cs
with GNU General Public License v3.0
from AndreiFedarets

public IDisposable RegisterHandler(IRequestServerHandler handler)
        {
            lock (Lock)
            {
                Guid uid = handler.Uid;
                if (_handlers.ContainsKey(uid))
                {
                    throw new TempException();
                }
                RequestHandler requestHandler = new RequestHandler(handler, this);
                _handlers[uid] = requestHandler;
                return requestHandler;
            }
        }

19 Source : ConfigurationCollection.cs
with GNU General Public License v3.0
from AndreiFedarets

public bool Contains(Guid uid)
        {
            VerifyDisposed();
            lock (_collection)
            {
                if (_collection.ContainsKey(uid))
                {
                    return true;
                }
            }
            return Execute(() => RemoteObject.Contains(uid));
        }

19 Source : FrameworkCollection.cs
with GNU General Public License v3.0
from AndreiFedarets

private void Initialize()
        {
            if (_initialized)
            {
                return;
            }
            List<IFramework> remoteFrameworks = Execute(() => RemoteObject.ToList());
            if (remoteFrameworks.Count == _collection.Count)
            {
                return;
            }
            foreach (IFramework remoteFramework in remoteFrameworks)
            {
                Framework framework = new Framework(remoteFramework);
                if (!_collection.ContainsKey(framework.Definition.Uid))
                {
                    _collection.Add(framework.Definition.Uid, framework);
                }
            }
            _initialized = true;
        }

19 Source : SessionCollection.cs
with GNU General Public License v3.0
from AndreiFedarets

private void Initialize()
        {
            if (_initialized)
            {
                return;
            }
            List<ISession> remoteSessions = Execute(() => RemoteObject.ToList());
            if (remoteSessions.Count == _collection.Count)
            {
                return;
            }
            foreach (ISession remoteSession in remoteSessions)
            {
                Session session = new Session(remoteSession, _application);
                if (!_collection.ContainsKey(session.Uid))
                {
                    _collection.Add(session.Uid, session);
                }
            }
            _initialized = true;
        }

19 Source : UniqueSettingsCollection.cs
with GNU General Public License v3.0
from AndreiFedarets

public void Add(T settings)
        {
            lock (Collection)
            {
                if (Collection.ContainsKey(settings.Uid))
                {
                    Collection[settings.Uid] = settings;
                }
                else
                {
                    Collection.Add(settings.Uid, settings);
                    OnSettingsAdded(settings);
                }
            }
        }

19 Source : FrameworkCollection.cs
with GNU General Public License v3.0
from AndreiFedarets

public bool Contains(Guid uid)
        {
            lock (Lock)
            {
                VerifyDisposed();
                return _collection.ContainsKey(uid);
            }
        }

19 Source : DynamicSettings.cs
with GNU General Public License v3.0
from AndreiFedarets

public bool Contains(Guid token)
        {
            lock (_collection)
            {
                return _collection.ContainsKey(token);
            }
        }

See More Examples