public bool TryGetRelationshipIndex(IDictionary <Guid, IList <MediaItemAspect> > aspects, IDictionary <Guid, IList <MediaItemAspect> > linkedAspects, out int index) { index = -1; SingleMediaItemAspect linkedAspect; if (!MediaItemAspect.TryGetAspect(linkedAspects, CompanyAspect.Metadata, out linkedAspect)) { return(false); } string name = linkedAspect.GetAttributeValue <string>(CompanyAspect.ATTR_COMPANY_NAME); SingleMediaItemAspect aspect; if (!MediaItemAspect.TryGetAspect(aspects, MovieAspect.Metadata, out aspect)) { return(false); } IEnumerable <string> companies = aspect.GetCollectionAttribute <string>(MovieAspect.ATTR_COMPANIES); List <string> nameList = new SafeList <string>(companies); index = nameList.IndexOf(name); return(index >= 0); }
public bool TryGetRelationshipIndex(IDictionary <Guid, IList <MediaItemAspect> > aspects, IDictionary <Guid, IList <MediaItemAspect> > linkedAspects, out int index) { index = -1; SingleMediaItemAspect linkedAspect; if (!MediaItemAspect.TryGetAspect(linkedAspects, PersonAspect.Metadata, out linkedAspect)) { return(false); } string name = linkedAspect.GetAttributeValue <string>(PersonAspect.ATTR_PERSON_NAME); SingleMediaItemAspect aspect; if (!MediaItemAspect.TryGetAspect(aspects, AudioAlbumAspect.Metadata, out aspect)) { return(false); } IEnumerable <string> persons = aspect.GetCollectionAttribute <string>(AudioAlbumAspect.ATTR_ARTISTS); List <string> nameList = new SafeList <string>(persons); index = nameList.IndexOf(name); return(index >= 0); }
public bool TryGetRelationshipIndex(IDictionary <Guid, IList <MediaItemAspect> > aspects, IDictionary <Guid, IList <MediaItemAspect> > linkedAspects, out int index) { index = -1; SingleMediaItemAspect linkedAspect; if (!MediaItemAspect.TryGetAspect(linkedAspects, CharacterAspect.Metadata, out linkedAspect)) { return(false); } string name = linkedAspect.GetAttributeValue <string>(CharacterAspect.ATTR_CHARACTER_NAME); SingleMediaItemAspect aspect; if (!MediaItemAspect.TryGetAspect(aspects, VideoAspect.Metadata, out aspect)) { return(false); } IEnumerable <string> actors = aspect.GetCollectionAttribute <string>(VideoAspect.ATTR_CHARACTERS); List <string> nameList = new SafeList <string>(actors); index = nameList.IndexOf(name); return(index >= 0); }
/// <summary> ///Clear 的测试 ///</summary> public void ClearTestHelper <ValueT>() { SafeList <ValueT> target = new SafeList <ValueT>(); // TODO: 初始化为适当的值 target.Clear(); Assert.Inconclusive("无法验证不返回值的方法。"); }
public override EnterMethodFlags EnterMethod(Method method) { //Console.WriteLine(method.FullName); if (this.methodStack.Count == 0 && !bStartMonitoring) { var assemblyShortname = method.Definition.Module.Assembly.ShortName; if (assemblyShortname == this.currentAssemblyLoc) { //Whereever the main method, it is the assembly under analysis, //since our tool assumes that there is only one assembly var assembly = method.Definition.Module.Assembly; DUCoverMain.Initialize(assembly); bStartMonitoring = true; } } if (bStartMonitoring) { this.methodStack.Push(method); var tempLastLoadedFields = new SafeList <Field>(); tempLastLoadedFields.AddRange(lastLoadedFields); this.lastLoadedFieldsStack.Push(tempLastLoadedFields); this.lastLoadedFields.Clear(); } return(base.EnterMethod(method)); // 'true' indicates that we want callbacks for the argument values }
/// <summary> /// If type is an interface, returns all concrete implementing classes /// else if type is an abstract class, returns all concrete extending classes /// </summary> /// <param name="psd"></param> /// <param name="type"></param> /// <param name="extendingClasses"></param> /// <returns></returns> public static bool TryGetExtendingClasses(PexMeStaticDatabase psd, TypeEx type, out IIndexable <TypeDefinition> extendingClasses) { //load inheritance hierarchies if not already done psd.LoadInheritanceHierarchies(); extendingClasses = null; TypeStore ts; if (!psd.TypeDictionary.TryGetValue(type.Definition, out ts)) { return(false); } SafeSet <TypeDefinition> extendingClassesSet = new SafeSet <TypeDefinition>(); CollectAllExtendingClasses(ts, extendingClassesSet); if (extendingClassesSet.Count == 0) { return(false); } var extendingClassesList = new SafeList <TypeDefinition>(); foreach (var tdef in extendingClassesSet) { extendingClassesList.Add(tdef); } extendingClasses = extendingClassesList; return(true); }
/// <summary> /// /// </summary> /// <param name="e"></param> void Log_ProblemHandler(Microsoft.ExtendedReflection.Logging.ProblemEventArgs e) { //TODO: Xusheng's code for additional OCI issues if (e.Result == TryGetModelResult.Success) { return; } CodeLocation location = e.FlippedLocation; var term = e.Suffix; SafeDictionary <Field, FieldValueHolder> fieldValues; SafeList <TypeEx> allFieldTypes; SafeList <Field> fields = TargetBranchAnalyzer.GetInvolvedFields(this.host, e.TermManager, term, out fieldValues, out allFieldTypes); //Not an object creation issue if (fields == null || fields.Count == 0) { return; } this.host.Log.LogMessage("ProblemHandler", "Recorded an issue at code location " + location.ToString()); if (!PexMeConstants.USE_TERM_SOLVER) { //A heuristic to choose the explorable type this.tba.HandleTargetBranch(location, term, e.TermManager, allFieldTypes[0]); } }
/// <summary> /// Initializes a new instance of the <see cref="SceneCameraRenderer"/> class. /// </summary> public SceneCameraRenderer() { Mode = new CameraRendererModeForward(); PreRenderers = new SafeList<IGraphicsRenderer>(); PostRenderers = new SafeList<IGraphicsRenderer>(); CullingMask = EntityGroupMask.All; }
public void SynchronizedListFact() { var list = new SafeList <string>(); void AddElements() { Enumerable.Range(0, Iterations) .ToList() .ForEach(i => list.Add(i.ToString())); } var threads = new List <Thread>() { new Thread(AddElements) { Name = "1" }, new Thread(AddElements) { Name = "2" }, new Thread(AddElements) { Name = "3" }, new Thread(AddElements) { Name = "4" } }; threads.ForEach(t => t.Start()); threads.ForEach(t => t.Join()); Assert.Equal(Iterations * 4, list.Count()); }
public void RunSimpleListThreaded() { int NUMBER_OF_ITERATIONS = 1000; int NUMBER_OF_THREADS_PER_OP = 10; int NUMBER_OF_STARTING_ITEMS = NUMBER_OF_ITERATIONS * NUMBER_OF_THREADS_PER_OP; //Change the below object from SafeList to //NonSafeList to see the test fail. ISimpleList list = new SafeList(); //Prefill the list so that we KNOW that after all additions and removals //there will be the original number of items still in the list. //This is because doing a Remove on an empty list will not reduce the count. for (int i = 0; i < NUMBER_OF_STARTING_ITEMS; i++) { list.Add(new Object()); } List<Thread> threads = new List<Thread>(); for (int k = 0; k < NUMBER_OF_THREADS_PER_OP; k++) { threads.Add(new Thread(delegate() { Thread.Sleep(10); //Allow time for other threads to start for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) { list.Add(new object()); } }) ); } for (int k = 0; k < 10; k++) { threads.Add(new Thread(delegate() { Thread.Sleep(10); //Allow time for other threads to start for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) { list.Remove(); } }) ); } //Start all the threads foreach (Thread t in threads) { t.Start(); } //Wait for them all to end foreach (Thread t in threads) { t.Join(); } Assert.AreEqual(list.Count, NUMBER_OF_STARTING_ITEMS); }
/// <summary> /// Creates a thread. /// </summary> /// <returns>ThreadId</returns> public int CreateThread() { int threadId; if (!this.DestroyedExecutionMonitorIds.TryDequeue(out threadId)) { threadId = this.ThreadExecutionMonitors.Count; this.ThreadExecutionMonitors.Add(null); } SafeDebug.Assert(this.ThreadExecutionMonitors[threadId] == null, "this.destroyedExecutionMonitorIds[threadId] == null"); SafeList <IThreadExecutionMonitor> childExecutionMonitors = new SafeList <IThreadExecutionMonitor>(2); // all callbacks foreach (var monitorFactory in this.MonitorFactories) { IThreadExecutionMonitor monitor; if (monitorFactory.TryCreateThreadMonitor(threadId, out monitor)) { childExecutionMonitors.Add(monitor); } } this.ThreadExecutionMonitors[threadId] = new ThreadExecutionMonitorMultiplexer(childExecutionMonitors); return(threadId); }
public Task RemoveAt(int index) { var item = DisplayList[index]; SafeList.Remove(item); return(Refresh()); }
private List <TItem> GetData() { if (SafeList == null) { return(null); } var query = SafeList.AsQueryable(); if (ColumnFilters != null) { query = ColumnFilters.SetFilters(query); } if (ColumnSorts != null) { query = ColumnSorts.SetOrderBys(query); } Paginator.Count = query.Count(); if (Paginator != null && Paginator.PageSize.HasValue) { query = query.Skip(Paginator.PageSize.Value * (Paginator.Page - 1)).Take(Paginator.PageSize.Value); } return(query.ToList()); }
public Task UpdateAt(int index, TItem item) { var dataIndex = SafeList.IndexOf(DisplayList[index]); SafeList[dataIndex] = item; return(Refresh()); }
/// <summary> ///SafeList`1 构造函数 的测试 ///</summary> public void SafeListConstructorTest1Helper <ValueT>() { IEnumerable <ValueT> collection = null; // TODO: 初始化为适当的值 SafeList <ValueT> target = new SafeList <ValueT>(collection); Assert.Inconclusive("TODO: 实现用来验证目标的代码"); }
private static string eliminateParameterizedTypes(string s) { // find all occurrences of [...] and eliminate var res = (string)s.Clone(); var stack = new SafeList <int>(); stack.Add(res.IndexOf("[", 0)); while (stack.Count > 0) { var topIndex = stack[stack.Count - 1]; if (topIndex == -1) { break; } var nextLeft = res.IndexOf("[", topIndex + 1); var nextRight = res.IndexOf("]", topIndex + 1); if (nextLeft != -1 && nextLeft < nextRight) { stack.Add(nextLeft); continue; } res = res.Remove(topIndex, nextRight - topIndex + 1); stack.RemoveAt(stack.Count - 1); if (stack.Count == 0 && topIndex < res.Length) { stack.Add(res.IndexOf("[", topIndex)); } } return(res); }
public void SetUp() { list = new SafeList <string>() { "zero", "one", "two", "three", "four" }; }
/// <summary> /// Initializes a new instance of the <see cref="SceneCameraRenderer"/> class. /// </summary> public SceneCameraRenderer() { Mode = new CameraRendererModeForward(); PreRenderers = new SafeList <IGraphicsRenderer>(); PostRenderers = new SafeList <IGraphicsRenderer>(); CullingMask = EntityGroupMask.All; }
VariablesCollector(TermManager termManager, SafeDictionary <Field, FieldValueHolder> fieldValues, SafeList <Field> allFields, SafeList <TypeEx> allFieldTypes) : base(termManager, OnCollection.Fail) { this.FieldValues = fieldValues; this.Fields = allFields; this.Types = allFieldTypes; }
public GameLevel() { GameSettings.SetCursor(CursorType.Wand); BackgroundColor = Color.LightBlue; Enemies = new SafeList <Enemy>(); Projectiles = new SafeList <Projectile>(); int x = GameSettings.BaseWidth / 2 - 64 / 2; int y = GameSettings.FloorLevel - 64 * 5 + 4; _wizard = new Wizard(new Vector2(GameSettings.BaseWidth / 2, y + 28)); BackgroundObjects.Add(_wizard); BackgroundObjects.Add(new Tower(0) { Position = new Rectangle(x, y, 64, 64) }); y += 64; for (; y < GameSettings.FloorLevel; y += 64) { BackgroundObjects.Add(new Tower() { Position = new Rectangle(x, y, 64, 64) }); } }
/// <summary>Clears the cache of configuration entries. (ConfigurationEntries) /// Re-accessing the ConfigurationEntries property rereads all configuration entries from the database.</summary> public void ClearCacheOfConfigurationEntries() { using (ACMonitor.Lock(_10020_LockValue)) { _ACConfigListCache = null; } }
/// <summary> ///SafeList`1 构造函数 的测试 ///</summary> public void SafeListConstructorTestHelper <ValueT>() { int iCapacity = 0; // TODO: 初始化为适当的值 SafeList <ValueT> target = new SafeList <ValueT>(iCapacity); Assert.Inconclusive("TODO: 实现用来验证目标的代码"); }
protected void urlModifyingPlugins_Changed(SafeList <IQuerystringPlugin> sender) { lock (_cachedUrlDataSync) { _cachedDirectives = null; _cachedExtensions = null; } }
/// <summary> ///Count 的测试 ///</summary> public void CountTestHelper <ValueT>() { SafeList <ValueT> target = new SafeList <ValueT>(); // TODO: 初始化为适当的值 int actual; actual = target.Count; Assert.Inconclusive("验证此测试方法的正确性。"); }
public RetryEngine() { this.disposed = false; this.taskQueue = new SafeQueue <TaskBag <TTask> >(); this.retryList = new SafeList <TaskBag <TTask> >(); this.eventSafeTrigger = new EventSafeTrigger(); this.retryingCount = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public ThreadMonitorManager(Configuration configuration) : base() { this.Configuration = configuration; this.MonitorFactories = new SafeList<IThreadMonitorFactory>(); this.ThreadExecutionMonitors = new SafeList<ThreadExecutionMonitorMultiplexer>(); this.DestroyedExecutionMonitorIds = new SafeQueue<int>(); }
/// <summary> ///AddRange 的测试 ///</summary> public void AddRangeTestHelper <ValueT>() { SafeList <ValueT> target = new SafeList <ValueT>(); // TODO: 初始化为适当的值 IEnumerable <ValueT> collection = null; // TODO: 初始化为适当的值 target.AddRange(collection); Assert.Inconclusive("无法验证不返回值的方法。"); }
public LibraryConfig() { libraryProviders = new SafeList <ILibraryContainerLink>(); this.RootLibaryContainer = new RootLibraryContainer(libraryProviders); this.ActiveContainer = this.RootLibaryContainer; }
/// <summary> ///Add 的测试 ///</summary> public void AddTestHelper <ValueT>() { SafeList <ValueT> target = new SafeList <ValueT>(); // TODO: 初始化为适当的值 ValueT value = default(ValueT); // TODO: 初始化为适当的值 target.Add(value); Assert.Inconclusive("无法验证不返回值的方法。"); }
internal SaveException(EntityManager em, JNode jn) : base() { _message = jn.Get<String>("ExceptionMessage") ?? "see EntityErrors"; var entityErrors = jn.GetArray<EntityError>("Errors", "errors", "EntityErrors", "entityErrors"); entityErrors = entityErrors.Select(ee => ee.Resolve(em)); _entityErrors = new SafeList<EntityError>(entityErrors); IsServerError = true; }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public ThreadMonitorManager(Configuration configuration) : base() { this.Configuration = configuration; this.MonitorFactories = new SafeList <IThreadMonitorFactory>(); this.ThreadExecutionMonitors = new SafeList <ThreadExecutionMonitorMultiplexer>(); this.DestroyedExecutionMonitorIds = new SafeQueue <int>(); }
/// <summary> ///RemoveAt 的测试 ///</summary> public void RemoveAtTestHelper <ValueT>() { SafeList <ValueT> target = new SafeList <ValueT>(); // TODO: 初始化为适当的值 int iIndex = 0; // TODO: 初始化为适当的值 target.RemoveAt(iIndex); Assert.Inconclusive("无法验证不返回值的方法。"); }
/// <summary> ///ForEach 的测试 ///</summary> public void ForEachTestHelper <ValueT>() { SafeList <ValueT> target = new SafeList <ValueT>(); // TODO: 初始化为适当的值 Action <ValueT> action = null; // TODO: 初始化为适当的值 target.ForEach(action); Assert.Inconclusive("无法验证不返回值的方法。"); }
public FileLogger() { mSavePath = string.Empty; mSaveFrontName = "Log"; mSaveExtName = "log"; mFinalFilePath = string.Empty; mFileSaver = new FileSaver(); mWaitMessages = new SafeList<string>(); mTempSeconds = 0; }
public void AddToRecommendedFactories(string typeEx, PexExplorableCandidate factory) { SafeList<PexExplorableCandidate> existingList; if (!this.recommendedFactories.TryGetValue(typeEx, out existingList)) { existingList = new SafeList<PexExplorableCandidate>(); this.recommendedFactories.Add(typeEx, existingList); } existingList.Add(factory); }
public static SafeList<Field> GetInvolvedFields(IPexComponent host, TermManager termManager, Term t, out SafeDictionary<Field, FieldValueHolder> fieldValues, out SafeList<TypeEx> allFieldTypes) { using (var ofc = new ObjectFieldCollector(host, termManager)) { ofc.VisitTerm(default(TVoid), t); fieldValues = ofc.FieldValues; allFieldTypes = ofc.Types; return ofc.Fields; } }
/// <summary> /// If type is an interface, returns all concrete implementing classes /// else if type is an abstract class, returns all concrete extending classes /// </summary> /// <param name="psd"></param> /// <param name="type"></param> /// <param name="extendingClasses"></param> /// <returns></returns> public static bool TryGetExtendingClasses(PexMeStaticDatabase psd, TypeEx type, out IIndexable<TypeDefinition> extendingClasses) { //load inheritance hierarchies if not already done psd.LoadInheritanceHierarchies(); extendingClasses = null; TypeStore ts; if (!psd.TypeDictionary.TryGetValue(type.Definition, out ts)) return false; SafeSet<TypeDefinition> extendingClassesSet = new SafeSet<TypeDefinition>(); CollectAllExtendingClasses(ts, extendingClassesSet); if (extendingClassesSet.Count == 0) return false; var extendingClassesList = new SafeList<TypeDefinition>(); foreach (var tdef in extendingClassesSet) { extendingClassesList.Add(tdef); } extendingClasses = extendingClassesList; return true; }
/// <summary> /// Constructor. /// </summary> /// <param name="log">IEventLog</param> /// <param name="threadIndex">Thread index</param> /// <param name="callMonitor">IThreadMonitor</param> /// <param name="testingEngine">ITestingEngine</param> /// <param name="configuration">Configuration</param> public ThreadExecutionMonitorDispatcher(IEventLog log, int threadIndex, IThreadMonitor callMonitor, ITestingEngine testingEngine, Configuration configuration) : base(threadIndex) { SafeDebug.AssertNotNull(callMonitor, "callMonitor"); this.ThreadIndex = threadIndex; this.Configuration = configuration; this.ThreadTrace = new List<ThreadTrace>(); this.DebugTrace = new SafeList<string>(); this.CallStack = new SafeStack<Method>(); this.IsDoHandlerCalled = false; this.IsEntryActionCalled = false; this.IsExitActionCalled = false; this.IsAction = false; this.RecordRW = false; this.IsCreateMachineMethod = false; // Registers a callback to emit the thread trace. The callback // is invoked at the end of each testing iteration. testingEngine.RegisterPerIterationCallBack(EmitThreadTrace); }
// Find out how many fields require user provided factory methods public static bool GetTargetExplorableField(IEnumerable<Field> involvedFields, out Field targetField, out TypeEx declaringType, IPexComponent host,out TypeEx targetType) { targetField = null; var allInvolvedFields = new SafeList<Field>(); allInvolvedFields.AddRange(involvedFields); int numFields = allInvolvedFields.Count; if (numFields < 1) { declaringType = null; targetType = null; return false; } // // if (numFields == 1) // { // targetField = allInvolvedFields[0]; // if (!MethodOrFieldAnalyzer.TryGetDeclaringTypeDefinition(host, targetField, out declaringType)) // { // declaringType = null; // return false; // } // return true; // } // allInvolvedFields.Reverse(); TypeEx prevFieldType = null; for (int count = 0; count < allInvolvedFields.Count; count++) { var currentField = allInvolvedFields[count]; // if (count + 1 < allInvolvedFields.Count) // { // prevFieldType = allInvolvedFields[count + 1].Type; // } if (!MethodOrFieldAnalyzer.TryGetDeclaringTypeDefinition(host, currentField, out declaringType)) { host.Log.LogError(WikiTopics.MissingWikiTopic, "targetfield", "Failed to get the declaring type for the field " + currentField.FullName); ErrorLog.AppendLine("Failed to get the declaring type for the field " + currentField.FullName); targetType = null; return false; } try { SafeDebug.Assume( prevFieldType == null || prevFieldType == declaringType || prevFieldType.IsAssignableTo(declaringType) || declaringType.IsAssignableTo(prevFieldType), "The current field type (" + declaringType + ") should be the same as the previous field type (" + prevFieldType + ")"); if (MethodOrFieldAnalyzer.IsFieldExternallyVisible(host, declaringType, currentField)) { prevFieldType = currentField.Type; continue; } } catch (Exception ex) { ErrorLog.AppendLine("Failed to compute external visibility of field " + currentField.FullName + " because of " + ex); } targetField = currentField; targetType = declaringType; return true; } targetField = allInvolvedFields[allInvolvedFields.Count - 1]; if (!MethodOrFieldAnalyzer.TryGetDeclaringTypeDefinition(host, targetField, out declaringType)) { host.Log.LogError(WikiTopics.MissingWikiTopic, "targetfield", "Failed to get the declaring type for the field " + targetField.FullName); targetType = null; return false; } targetType = targetField.Type; return true; }
/// <summary> /// Creates a thread. /// </summary> /// <returns>ThreadId</returns> public int CreateThread() { int threadId; if (!this.DestroyedExecutionMonitorIds.TryDequeue(out threadId)) { threadId = this.ThreadExecutionMonitors.Count; this.ThreadExecutionMonitors.Add(null); } SafeDebug.Assert(this.ThreadExecutionMonitors[threadId] == null, "this.destroyedExecutionMonitorIds[threadId] == null"); SafeList<IThreadExecutionMonitor> childExecutionMonitors = new SafeList<IThreadExecutionMonitor>(2); // all callbacks foreach (var monitorFactory in this.MonitorFactories) { IThreadExecutionMonitor monitor; if (monitorFactory.TryCreateThreadMonitor(threadId, out monitor)) { childExecutionMonitors.Add(monitor); } } this.ThreadExecutionMonitors[threadId] = new ThreadExecutionMonitorMultiplexer(childExecutionMonitors); return threadId; }
public void Purge(bool isForced, SafeList<Canvas> invalidatedResources) { if(isForced) { foreach(Canvas.ResolvedContext item in _UsedRegions) { item.BackingContext = null; } _UsedRegions.Clear(); _FreeRegions.Clear(); _FreeRegions.AddLast(new Rectangle(Point.Empty, Region.Size)); _FreeArea = Region.Area; } }
public void Purge(bool isForced, SafeList<Canvas> invalidatedResources) { if(isForced) { var context = (Canvas.ResolvedContext)_CanvasContext.Target; if(context != null) { context.BackingContext = null; invalidatedResources.Add(context.Target); } _CanvasContext.Target = null; } else if(!_CanvasContext.IsAlive) { _CanvasContext.Target = null; } }
/// <summary> /// Adds a controllable type /// </summary> /// <param name="type"></param> public void AddPexGeneratedFactoryMethod(string type, string factoryMethod) { SafeList<string> suggestedFactoryMethods; if (!this.pexGeneratedFactories.TryGetValue(type, out suggestedFactoryMethods)) { suggestedFactoryMethods = new SafeList<string>(); this.pexGeneratedFactories[type] = suggestedFactoryMethods; } suggestedFactoryMethods.Add(factoryMethod); }
internal ImportResult(IEnumerable<IEntity> entities, Dictionary<EntityKey, EntityKey> tempKeyMap) { _importedEntities = new SafeList<IEntity>(entities); _tempKeyMap = new ReadOnlyDictionary<EntityKey, EntityKey>(tempKeyMap); }
/// <summary> /// 返信されたIDを追加します。 /// </summary> public void AddInReplyFromUserScreenName(string screenName) { if (inReplyFromScreenNames == null) inReplyFromScreenNames = new SafeList<string>(); inReplyFromScreenNames.AddUnique(screenName); InReplyFromUpdated(); }
/// <summary> /// 指定したIDをfavったリストに追加します。 /// </summary> public void AddFavored(TwitterUser user) { if (favoredAccounts == null) favoredAccounts = new SafeList<TwitterUser>(); favoredAccounts.AddUnique(user); FavoredAccountsUpdated(); TweetModel.RaiseExtraDataTableUpdated(this.LinkId); }
/// <summary> /// Default constructor /// </summary> public ParticleSystem() { emitters = new SafeList<ParticleEmitter>(); }
public override EnterMethodFlags EnterMethod(Method method) { //Console.WriteLine(method.FullName); if (this.methodStack.Count == 0 && !bStartMonitoring) { var assemblyShortname = method.Definition.Module.Assembly.ShortName; if (assemblyShortname == this.currentAssemblyLoc) { //Whereever the main method, it is the assembly under analysis, //since our tool assumes that there is only one assembly var assembly = method.Definition.Module.Assembly; DUCoverMain.Initialize(assembly); bStartMonitoring = true; } } if (bStartMonitoring) { this.methodStack.Push(method); var tempLastLoadedFields = new SafeList<Field>(); tempLastLoadedFields.AddRange(lastLoadedFields); this.lastLoadedFieldsStack.Push(tempLastLoadedFields); this.lastLoadedFields.Clear(); } return base.EnterMethod(method); // 'true' indicates that we want callbacks for the argument values }
/// <summary> /// Checks whether there are any looping requireements based on looping threshold and enhances /// the sequence accordingly. Applies only for INCREMENT and DECREMENT field modification types /// </summary> /// <param name="pucls"></param> /// <param name="p"></param> private void CheckNEnhanceForLooping(PersistentUncoveredLocationStore pucls, int fitnessval, FieldModificationType fmt, SafeList<Field> culpritFields) { if (fmt != FieldModificationType.INCREMENT && fmt != FieldModificationType.DECREMENT) return; //Not even a single execution happened on this location. if (fitnessval == Int32.MaxValue) return; var field = culpritFields[0]; FieldStore fs; if (!this.pmd.FieldDictionary.TryGetValue(field, out fs)) return; Dictionary<string, Method> writeMethods = new Dictionary<string, Method>(); foreach (var mset in fs.WriteMethods.Values) { foreach (var m in mset) { var sig = MethodOrFieldAnalyzer.GetMethodSignature(m); writeMethods.Add(sig, m); } } foreach (var seq in pucls.SuggestedMethodSequences) { string loop_method; if (!this.IsEligibleForLooping(seq, field, writeMethods, fs, out loop_method)) continue; pucls.LoopingFeatureApplied = true; this.host.Log.LogWarning(WikiTopics.MissingWikiTopic, "LoopingFeature", "Applying looping feature on method: " + loop_method + " (" + (fitnessval - 1) + ")"); for (int count = 1; count < fitnessval; count++) seq.Sequence.Add(loop_method); } }
public SaveException(String message, IEnumerable<EntityError> entityErrors) : base(message) { _entityErrors = new SafeList<EntityError>(entityErrors); IsServerError = true; }
/// <summary> /// Adds a field to an unsuccessful code location. /// </summary> /// <param name="location"></param> /// <param name="fields"></param> public void AddFieldsOfUncoveredCodeLocations(CodeLocation location, SafeList<Field> fields, FieldModificationType fmt, Term condition, string terms, int fitnessval, TypeEx explorableType, SafeList<TypeEx> allFieldTypes) { //No need to process this location. if (fields.Count == 0) { return; } Field targetField; TypeEx declaringType; //This declaring type is considered as explorable type in the rest of the analysis if (!PexMeFactoryGuesser.GetTargetExplorableField(this, fields, out targetField, out declaringType)) { this.Log.LogError(WikiTopics.MissingWikiTopic, "factoryguesser", "Failed to retrieve the target field for uncovered location " + location.ToString()); return; } //Compare the declaring type and actual explorable type. //If there is a inheritance relation, use the actual one if (explorableType.IsAssignableTo(declaringType)) { declaringType = explorableType; } var uclskey = UncoveredCodeLocationStore.GetKey(location.ToString(), declaringType.ToString(), condition.UniqueIndex); UncoveredCodeLocationStoreList uclslist; if (!this.unCoveredLocationDic.TryGetValue(uclskey, out uclslist)) { uclslist = new UncoveredCodeLocationStoreList(); uclslist.Location = location; uclslist.ExplorableType = declaringType.ToString(); uclslist.TermIndex = condition.UniqueIndex; this.unCoveredLocationDic[uclskey] = uclslist; } var ucls = new UncoveredCodeLocationStore(); ucls.Location = location; ucls.ExplorableType = declaringType; ucls.TargetField = targetField; ucls.AllFields.AddRange(fields); ucls.AllFieldTypes.AddRange(allFieldTypes); ucls.TermIndex = condition.UniqueIndex; //add the sequence of method calls ucls.MethodCallSequence = new MethodSignatureSequence(); foreach (var m in this.LastExecutedFactoryMethodCallSequence) { ucls.MethodCallSequence.Sequence.Add(MethodOrFieldAnalyzer.GetMethodSignature(m)); } ucls.IsADefectDetectingSequence = this.DefectDetectingSequence; ucls.CUTMethodCallSequence = this.LastExecutedCUTMethodCallSequence; if (!uclslist.StoreList.Contains(ucls)) { ucls.TextualTerms.Add(terms); ucls.DesiredFieldModificationType = fmt; ucls.Fitnessvalue = fitnessval; uclslist.StoreList.Add(ucls); } }
/// <summary> /// Adds a type to predefined classes store /// </summary> /// <param name="typename"></param> /// <param name="typeEx"></param> public void AddToPredinedStore(string typename, TypeEx typeEx) { SafeList<TypeEx> existingDefinedTypes; if (!definedTypes.TryGetValue(typename, out existingDefinedTypes)) { existingDefinedTypes = new SafeList<TypeEx>(); definedTypes.Add(typename, existingDefinedTypes); } existingDefinedTypes.Add(typeEx); }
protected void urlModifyingPlugins_Changed(SafeList<IQuerystringPlugin> sender) { lock (_cachedUrlDataSync) { _cachedDirectives = null; _cachedExtensions = null; } }
public void AddFactoryMethodForDebug(string typeName, string factoryMethod) { if (isDebug) { SafeList<string> mList; if (!this.FactoryMethodInfo.TryGetValue(typeName, out mList)) this.FactoryMethodInfo[typeName] = mList = new SafeList<string>(); mList.Add(factoryMethod); } }
public void Purge(bool isForced, SafeList<Canvas> invalidatedResources) { if(isForced) { _OccupiedArea = 0; _FragmentedArea = 0; _FreeRegions.Clear(); _FreeRegions.AddLast(new Rectangle(Point.Empty, Region.Size)); PurgeUsedRegions(true, invalidatedResources); } else { PurgeUsedRegions(false, invalidatedResources); } }
internal SaveResult(IEnumerable<IEntity> entities, Dictionary<EntityKey, EntityKey> keyMappings) { _savedEntities = new SafeList<IEntity>(entities); _keyMappings = new ReadOnlyDictionary<EntityKey, EntityKey>(keyMappings); }
private void PurgeUsedRegions(bool forcePurge, SafeList<Canvas> invalidatedResources) { for(var item = _UsedRegions.First; item != null; item = item.Next) { if(!item.Value.CanvasReference.IsAlive || forcePurge) { if(forcePurge) { var context = (Canvas.ResolvedContext)item.Value.CanvasReference.Target; if(context != null) { context.BackingContext = null; invalidatedResources.Add(context.Target); } } Rectangle region = item.Value.ActualRegion; _UsedRegions.Remove(item); _FragmentedArea += region.Area; } } }
private static void AddToCulpritField(IEnumerable<Field> accessedFields, SafeList<Field> culpritFields) { foreach (var acfield in accessedFields) { if (PexMeFilter.IsTypeSupported(acfield.Type)) { culpritFields.Add(acfield); } } }
/// <summary> /// OBSOLETE: /// </summary> /// <param name="termManager"></param> /// <param name="left"></param> /// <param name="right"></param> /// <param name="binOp"></param> /// <param name="bNegated"></param> /// <param name="culpritFields"></param> /// <param name="completeTerm"></param> /// <param name="fmt"></param> /// <param name="fitnessval"></param> private void handleNoConstantsInTerm(TermManager termManager, Term left, Term right, BinaryOperator binOp, bool bNegated, SafeList<Field> culpritFields, Term completeTerm, out FieldModificationType fmt, out int fitnessval) { fmt = FieldModificationType.UNKNOWN; //Term termUnderAnalysis = null; //Term otherTerm = null; //Field instanceField; //if (termManager.TryGetInstanceField(left, out instanceField) && culpritFields.Contains(instanceField)) //{ // termUnderAnalysis = left; // otherTerm = right; //} //else //{ // if (termManager.TryGetInstanceField(right, out instanceField)) // if (culpritFields.Contains(instanceField)) // { // termUnderAnalysis = right; // otherTerm = left; // } //} //if (termUnderAnalysis == null) // return; //object value; //if (termManager.TryGetObject(left, out value)) //{ // if (value == null && binOp == BinaryOperator.Ceq) // { // fmt = bNegated ? FieldModificationType.NON_NULL_SET : FieldModificationType.NULL_SET; // } // else if (value is int || value is Int16 || value is Int32 || value is Int64) // { // fmt = FieldModificationType.INCREMENT; //TODO: Needs to get actual values and decide based on that // } //} else if (termManager.TryGetObject(right, out value)) //{ // if (value == null && binOp == BinaryOperator.Ceq) // { // fmt = bNegated ? FieldModificationType.NON_NULL_SET : FieldModificationType.NULL_SET; // } // else if (value is int || value is Int16 || value is Int32 || value is Int64) // { // fmt = FieldModificationType.INCREMENT; //TODO: Needs to get actual values and decide based on that // } //} //TODO: A worst fix to proceed further fitnessval = Int32.MaxValue; if (culpritFields.Count == 0) return; var culprittype = culpritFields[0].Type; if (culprittype.IsReferenceType) fmt = FieldModificationType.NON_NULL_SET; else { var typestr = culprittype.ToString(); if (typestr == "System.Boolean") fmt = FieldModificationType.TRUE_SET; else if (typestr == "System.Int32" || typestr == "System.Int64" || typestr == "System.Int16") { SafeDictionary<Field, FieldValueHolder> fieldValues; //TermSolver.SolveTerm(this.ter, completeTerm, out fieldValues); fmt = FieldModificationType.INCREMENT; } } }