public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox) { m_caches = caches; m_cache = caches.MainCache; //prior to 9-20-2011 this was not set, if we find there was a reason get rid of this. m_choices = choices; m_sandbox = sandbox; m_fIconsForAnalysisChoices = fIconsForAnalysisChoices; m_wsAnalysis = caches.MainCache.DefaultAnalWs; m_wsUi = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs; m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs); m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis); m_tssEmptyVern = m_tsf.MakeString("", m_sandbox.RawWordformWs); m_tssMissingEntry = m_tssMissingMorphs; // It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default // fonts may have different sizes, requiring differnt line heights to align things well. m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingMorphPos = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingWordPos = m_tssMissingMorphPos; m_PulldownArrowPic = VwConstructorServices.ConvertImageToComPicture(ResourceHelper.InterlinPopupArrow); m_dxmpArrowPicWidth = ConvertPictureWidthToMillipoints(m_PulldownArrowPic.Picture); IWritingSystem wsObj = caches.MainCache.ServiceLocator.WritingSystemManager.Get(m_sandbox.RawWordformWs); if (wsObj != null) m_fRtl = wsObj.RightToLeftScript; }
//private CachePair[] GetStoresCachePairs(CachePair[] oldCachedStores, AcquiredLockServices[] services) //{ // var newCachedStores = services.Select(x => { // var dbParameters = x.AcquiredDbParameters; // var old = oldCachedStores?.FirstOrDefault(o => o.DbParameters.Equals(dbParameters)); // return old ?? new CachePair // { // DbParameters = dbParameters, // Store = dbInstanceStoreFactory(dbParameters), // }; // }).ToArray(); // return newCachedStores; //} //private IPacketsStore FromCachePairs(CachePair[] cachePairs, AcquiredDbParameters acquiredDbParameters) //{ // return cachePairs?.FirstOrDefault(x => x.DbParameters.Equals(acquiredDbParameters))?.Store; //} // есть негативный низковерятный вариант когда каждый раз будет резервироваться новая бд, тогда закешированной значение будет постянно меняться (а в нашем случае у него есть логика инициализации на которую тратится время) private IPacketsStore GetPacketsStore(AcquiredLockServices services) { var acquiredDbParameters = services.AcquiredDbParameters; var storePair = this.cachedPacketsStorePair; if (storePair == null || !acquiredDbParameters.Equals(storePair.DbParameters)) { lock (this.cachePairsLock) { if (storePair == null || !acquiredDbParameters.Equals(storePair.DbParameters)) { storePair = new CachePair { DbParameters = acquiredDbParameters, Store = this.dbInstanceStoreFactory(acquiredDbParameters), }; this.cachedPacketsStorePair = storePair; } else { storePair = this.cachedPacketsStorePair; } } } return(storePair.Store); }
/// <summary/> protected virtual void Dispose(bool fDisposing) { System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().ToString() + " *******"); if (fDisposing && !IsDisposed) { // Dispose managed resources here. if (m_PulldownArrowPic != null) { m_PulldownArrowPic.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_sandbox = null; // Client gave it to us, so has to deal with it. m_caches = null; // Client gave it to us, so has to deal with it. m_PulldownArrowPic = null; m_tsf = null; m_tssMissingEntry = null; // Same as m_tssMissingMorphs, so just null it. m_tssMissingWordPos = null; // Same as m_tssMissingMorphPos, so just null it. m_tssMissingMorphs = null; m_tssEmptyAnalysis = null; m_tssEmptyVern = null; m_tssMissingMorphGloss = null; m_tssMissingMorphPos = null; IsDisposed = true; }
public static T LuaGet <T>(String lua, uint a) { if (!luaValues.ContainsKey(lua)) { luaValues[lua] = new CachePair { Iteration = -1 } } ; var lv = luaValues[lua]; if (lv.Iteration < iterationCounter || lv.Iteration > iterationCounter) { lv.Value = Lua.GetReturnVal <T>(lua, a); lv.Iteration = iterationCounter; luaCount++; if (luaCount % 100 == 0) { Write("luaavg:" + luaCount / inst.time); } LogDebug(lua + " => " + lv.Value); } return((T)lv.Value); }
public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox) { m_caches = caches; m_cache = caches.MainCache; //prior to 9-20-2011 this was not set, if we find there was a reason get rid of this. m_choices = choices; m_sandbox = sandbox; m_fIconsForAnalysisChoices = fIconsForAnalysisChoices; m_wsAnalysis = caches.MainCache.DefaultAnalWs; m_wsUi = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs; m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs); m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis); m_tssEmptyVern = m_tsf.MakeString("", m_sandbox.RawWordformWs); m_tssMissingEntry = m_tssMissingMorphs; // It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default // fonts may have different sizes, requiring differnt line heights to align things well. m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingMorphPos = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingWordPos = m_tssMissingMorphPos; m_PulldownArrowPic = VwConstructorServices.ConvertImageToComPicture(ResourceHelper.InterlinPopupArrow); m_dxmpArrowPicWidth = ConvertPictureWidthToMillipoints(m_PulldownArrowPic.Picture); IWritingSystem wsObj = caches.MainCache.ServiceLocator.WritingSystemManager.Get(m_sandbox.RawWordformWs); if (wsObj != null) { m_fRtl = wsObj.RightToLeftScript; } }
public override bool Equals(object obj) { if (obj is CachePair) { CachePair theirObject = (CachePair)obj; return(smallIndex == theirObject.smallIndex && bigIndex == theirObject.bigIndex); } return(false); }
int m_cchPrevMorphemes; // Total length of morphemes before m_imorph. public MorphemeBreaker(CachePair caches, string input, int hvoSbWord, int wsVern, SandboxBase sandbox) { m_caches = caches; m_sda = caches.DataAccess; m_cda = (IVwCacheDa)m_sda; m_input = input; m_hvoSbWord = hvoSbWord; m_cOldMorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); ITsStrFactory m_tsf = TsStrFactoryClass.Create(); m_wsVern = wsVern; m_types = m_caches.MainCache.ServiceLocator.GetInstance<IMoMorphTypeRepository>(); m_sandbox = sandbox; }
private static void Subdivide(int level) { List <Face> newFaces = new List <Face>((int)FacesInLevel(level)); Dictionary <CachePair, int> meshCache = new Dictionary <CachePair, int>((int)EdgesInLevel(level)); List <Face> oldLevel = faces[level - 1]; for (int faceIndex = 0; faceIndex < oldLevel.Count; faceIndex++) { Face face = oldLevel[faceIndex]; Vector3d point1Vector = verticies[face.point1]; Vector3d point2Vector = verticies[face.point2]; Vector3d point3Vector = verticies[face.point3]; CachePair cacheID12 = new CachePair(face.point1, face.point2); CachePair cacheID13 = new CachePair(face.point1, face.point3); CachePair cacheID23 = new CachePair(face.point2, face.point3); int newPoint1; int newPoint2; int newPoint3; //Add or select the vertex between point 12 if (!meshCache.TryGetValue(cacheID12, out newPoint1)) { newPoint1 = verticies.Count; verticies.Add((point1Vector + point2Vector).normalized); meshCache.Add(cacheID12, newPoint1); } //Add or select the vertex between point 13 if (!meshCache.TryGetValue(cacheID13, out newPoint2)) { newPoint2 = verticies.Count; verticies.Add((point1Vector + point3Vector).normalized); meshCache.Add(cacheID13, newPoint2); } //Add or select the vertex between point 23 if (!meshCache.TryGetValue(cacheID23, out newPoint3)) { newPoint3 = verticies.Count; verticies.Add((point2Vector + point3Vector).normalized); meshCache.Add(cacheID23, newPoint3); } //Add the faces newFaces.Add(new Face(face.point1, newPoint1, newPoint2)); newFaces.Add(new Face(face.point2, newPoint3, newPoint1)); newFaces.Add(new Face(face.point3, newPoint2, newPoint3)); newFaces.Add(new Face(newPoint3, newPoint2, newPoint1)); } faces.Add(newFaces); }
/// <summary> /// This contructor is only to be used by the /// </summary> /// <param name="owner"></param> /// <param name="caches"></param> /// <param name="choices"></param> /// <param name="anal"></param> public UpdateRealAnalysisMethod(SandboxBase owner, CachePair caches, InterlinLineChoices choices, WfiAnalysis anal) { m_sandbox = owner; m_caches = caches; m_hvoSbWord = kSbWord; // kSbWord really is a constant, not a real hvo. //m_hvoWordform = hvoWordform; //m_hvoWfiAnalysis = hvoWfiAnalysis; m_anal = anal; //m_hvoWordGloss = hvoWordGloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; //m_tssForm = tssForm; }
public GetRealAnalysisMethod(IHelpTopicProvider helpTopicProvider, SandboxBase owner, CachePair caches, int hvoSbWord, AnalysisTree oldAnalysis, IWfiAnalysis wa, IWfiGloss gloss, InterlinLineChoices choices, ITsString tssForm, bool fWantOnlyWfiAnalysis) : this() { m_helpTopicProvider = helpTopicProvider; m_sandbox = owner; m_caches = caches; m_hvoSbWord = hvoSbWord; m_oldAnalysis = oldAnalysis; m_wf = oldAnalysis.Wordform; m_wa = wa; m_wg = gloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; m_tssForm = tssForm; m_fWantOnlyWfiAnalysis = fWantOnlyWfiAnalysis; }
/// <summary> /// This contructor is only to be used by the /// </summary> /// <param name="owner"></param> /// <param name="caches"></param> /// <param name="choices"></param> /// <param name="anal"></param> public UpdateRealAnalysisMethod(SandboxBase owner, CachePair caches, InterlinLineChoices choices, IWfiAnalysis anal) { m_sandbox = owner; m_caches = caches; m_hvoSbWord = kSbWord; // kSbWord really is a constant, not a real hvo. //m_hvoWordform = hvoWordform; //m_hvoWfiAnalysis = hvoWfiAnalysis; m_anal = anal; //m_hvoWordGloss = hvoWordGloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; //m_tssForm = tssForm; var servLoc = m_caches.MainCache.ServiceLocator; m_moFormRepos = servLoc.GetInstance<IMoFormRepository>(); m_senseRepos = servLoc.GetInstance<ILexSenseRepository>(); m_msaRepos = servLoc.GetInstance<IMoMorphSynAnalysisRepository>(); }
/// <summary> /// This contructor is only to be used by the /// </summary> /// <param name="owner"></param> /// <param name="caches"></param> /// <param name="choices"></param> /// <param name="anal"></param> public UpdateRealAnalysisMethod(SandboxBase owner, CachePair caches, InterlinLineChoices choices, IWfiAnalysis anal) { m_sandbox = owner; m_caches = caches; m_hvoSbWord = kSbWord; // kSbWord really is a constant, not a real hvo. //m_hvoWordform = hvoWordform; //m_hvoWfiAnalysis = hvoWfiAnalysis; m_anal = anal; //m_hvoWordGloss = hvoWordGloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; //m_tssForm = tssForm; var servLoc = m_caches.MainCache.ServiceLocator; m_moFormRepos = servLoc.GetInstance <IMoFormRepository>(); m_senseRepos = servLoc.GetInstance <ILexSenseRepository>(); m_msaRepos = servLoc.GetInstance <IMoMorphSynAnalysisRepository>(); }
protected override void DisposeUnmanagedResources() { // Dispose unmanaged resources here, whether disposing is true or false. m_rgvsli = null; m_caches = null; m_sandbox = null; m_rootb = null; m_items = null; m_comboList = null; }
public GetRealAnalysisMethod(SandboxBase owner, CachePair caches, int hvoSbWord, int hvoWordform, int hvoWfiAnalysis, int hvoWordGloss, InterlinLineChoices choices, ITsString tssForm, bool fWantOnlyWfiAnalysis) { m_sandbox = owner; m_caches = caches; m_hvoSbWord = hvoSbWord; m_hvoWordform = hvoWordform; m_hvoWfiAnalysis = hvoWfiAnalysis; m_hvoWordGloss = hvoWordGloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; m_tssForm = tssForm; m_fWantOnlyWfiAnalysis = fWantOnlyWfiAnalysis; }
internal InterlinComboHandler(SandboxBase sandbox) : this() { m_sandbox = sandbox; m_caches = sandbox.Caches; m_wsVern = m_sandbox.RawWordformWs; m_wsAnal = m_caches.MainCache.DefaultAnalWs; m_wsUser = m_caches.MainCache.DefaultUserWs; m_hvoSbWord = kSbWord; m_rootb = sandbox.RootBox; }
// only for testing internal void SetSandboxForTesting(SandboxBase sandbox) { m_sandbox = sandbox; m_caches = sandbox.Caches; m_wsVern = m_caches.MainCache.DefaultVernWs; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. } // Dispose unmanaged resources here, whether disposing is true or false. m_sandbox = null; // Client gave it to us, so has to deal with it. m_caches = null; // Client gave it to us, so has to deal with it. Marshal.ReleaseComObject(m_PulldownArrowPic); m_PulldownArrowPic = null; Marshal.ReleaseComObject(m_tsf); m_tsf = null; m_tssMissingEntry = null; // Same as m_tssMissingMorphs, so just null it. m_tssMissingWordPos = null; // Same as m_tssMissingMorphPos, so just null it. Marshal.ReleaseComObject(m_tssMissingMorphs); m_tssMissingMorphs = null; Marshal.ReleaseComObject(m_tssEmptyAnalysis); m_tssEmptyAnalysis = null; Marshal.ReleaseComObject(m_tssEmptyVern); m_tssEmptyVern = null; Marshal.ReleaseComObject(m_tssMissingMorphGloss); m_tssMissingMorphGloss = null; Marshal.ReleaseComObject(m_tssMissingMorphPos); m_tssMissingMorphPos = null; base.Dispose(disposing); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { // Dispose managed resources here. if (m_comboList != null && (m_comboList is IDisposable) && (m_comboList as Control).Parent == null) (m_comboList as IDisposable).Dispose(); else if (m_comboList is ComboListBox) { // It typically has a parent, the special form used to display it, so will not // get disposed by the above, but we do want to dispose it. (m_comboList as IDisposable).Dispose(); } if (m_items != null) m_items.Clear(); // I've seen it contain ints or MorphItems. } // Dispose unmanaged resources here, whether disposing is true or false. m_rgvsli = null; m_caches = null; m_sandbox = null; m_rootb = null; m_items = null; m_comboList = null; m_isDisposed = true; }
public static void Write(CachePair pair, BinaryWriter writer) { IList<PsiRuleSymbol> ruleItems = pair.Rules; writer.Write(ruleItems.Count); foreach (PsiRuleSymbol ruleItem in ruleItems) { ruleItem.Write(writer); } IList<PsiOptionSymbol> optionItems = pair.Options; writer.Write(optionItems.Count); foreach (PsiOptionSymbol optionItem in optionItems) { optionItem.Write(writer); } }
/// <summary/> protected virtual void Dispose(bool fDisposing) { System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().ToString() + " *******"); if (fDisposing && !IsDisposed) { // Dispose managed resources here. if (m_PulldownArrowPic != null) m_PulldownArrowPic.Dispose(); } // Dispose unmanaged resources here, whether disposing is true or false. m_sandbox = null; // Client gave it to us, so has to deal with it. m_caches = null; // Client gave it to us, so has to deal with it. m_PulldownArrowPic = null; m_tsf = null; m_tssMissingEntry = null; // Same as m_tssMissingMorphs, so just null it. m_tssMissingWordPos = null; // Same as m_tssMissingMorphPos, so just null it. m_tssMissingMorphs = null; m_tssEmptyAnalysis = null; m_tssEmptyVern = null; m_tssMissingMorphGloss = null; m_tssMissingMorphPos = null; IsDisposed = true; }
public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox) { m_caches = caches; m_choices = choices; m_sandbox = sandbox; m_fIconsForAnalysisChoices = fIconsForAnalysisChoices; m_wsAnalysis = caches.MainCache.LangProject.DefaultAnalysisWritingSystem; m_wsUi = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs; m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs); m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis); m_tssEmptyVern = m_tsf.MakeString("", m_sandbox.RawWordformWs); m_tssMissingEntry = m_tssMissingMorphs; // It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default // fonts may have different sizes, requiring differnt line heights to align things well. m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingMorphPos = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingWordPos = m_tssMissingMorphPos; m_PulldownArrowPic = (stdole.IPicture)OLECvt.ToOLE_IPictureDisp(ResourceHelper.InterlinPopupArrow); m_dxmpArrowPicWidth = ConvertPictureWidthToMillipoints(m_PulldownArrowPic); IWritingSystem wsObj = caches.MainCache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(m_sandbox.RawWordformWs); if (wsObj != null) m_fRtl = wsObj.RightToLeft; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create the dialog for modifying headers and footers /// </summary> /// <param name="cache">the cache</param> /// <param name="curHFSet">publication header/footer set</param> /// <param name="pub">publication (used to determine if the publication is right-bound /// or left-bound to determine placement of objects and dialog labels in dialog</param> /// <param name="helpProvider">provides context-senstive help for this dialog</param> /// ------------------------------------------------------------------------------------ public HeaderFooterModifyDlg(FdoCache cache, IPubHFSet curHFSet, IPublication pub, IHelpTopicProvider helpProvider) { m_caches = new CachePair(); m_caches.MainCache = cache; m_caches.CreateSecCache(); m_curHFSet = curHFSet; m_pub = pub; m_helpProvider = helpProvider; LoadRealDataIntoSec(); InitializeComponent(); m_innerHeaderText = m_lblLeftHeader.Text; m_innerFooterText = m_lblLeftFooter.Text; m_outerHeaderText = m_lblRightHeader.Text; m_outerFooterText = m_lblRightFooter.Text; ChangePanelsToViews(); m_lastFocusedView = m_hfsvHeader; m_txtBoxDescription.Text = m_curHFSet.Description.Text; m_txtBoxName.Text = m_curHFSet.Name; UpdateOKButton(); }
int m_cchPrevMorphemes; // Total length of morphemes before m_imorph. public MorphemeBreaker(CachePair caches, string input, int hvoSbWord, int wsVern, SandboxBase sandbox) { m_caches = caches; m_sda = caches.DataAccess; m_cda = (IVwCacheDa)m_sda; m_input = input; m_hvoSbWord = hvoSbWord; m_cOldMorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); ITsStrFactory m_tsf = TsStrFactoryClass.Create(); m_wsVern = wsVern; m_types = new MoMorphTypeCollection(m_caches.MainCache); m_sandbox = sandbox; }