internal THandler EnsureFeatureRegistered(ISldWorks app, IModelDoc2 model, IFeature feat, out bool isNew)
        {
            isNew = false;

            MacroFeatureDictionary featsDict;

            if (!m_Register.TryGetValue(model, out featsDict))
            {
                m_Logger.Log($"{model?.GetTitle()} model is not registered in the register");

                featsDict = new MacroFeatureDictionary();
                m_Register.Add(model, featsDict);

                var lcm = new MacroFeatureLifecycleManager(model, m_BaseName, m_Logger);
                lcm.ModelDisposed  += OnModelDisposed;
                lcm.FeatureDeleted += OnFeatureDeleted;
                m_LifecycleManagers.Add(model, lcm);
            }

            THandler handler = null;

            if (!featsDict.TryGetValue(feat, out handler))
            {
                m_Logger.Log($"{feat?.Name} feature in {model?.GetTitle()} model is not registered in the register");

                handler = new THandler();
                featsDict.Add(feat, handler);
                handler.Init(app, model, feat);
                isNew = true;
            }

            return(handler);
        }
예제 #2
0
        /// <summary>
        /// Checks if a given Sitecore template has a corresponding interface. This method does NOT check any base templates this template may have for synchronization.
        /// </summary>
        public TemplateComparisonResult IsTemplateSynchronized(TemplateItem template)
        {
            var signature = _signatureProvider.GenerateTemplateSignature(template);
            ModelTemplateReference reference;

            if (ModelDictionary.TryGetValue(template.ID.ToString(), out reference))
            {
                return(new TemplateComparisonResult(
                           template.ID.ToString(),
                           GetTemplateName(template),
                           GetModelName(reference),
                           signature,
                           reference.Metadata.VersionSignature));
            }

            return(new TemplateComparisonResult(template.ID.ToString(), GetTemplateName(template), null, signature, null));
        }