コード例 #1
0
        public bool SaveBehaviorAsTemplate(IBehavior behavior, string templateName, bool replaceExisting = false)
        {
            var key   = Helper.GetLookupName(behavior.ConcreteType, templateName);
            var saved = false;

            if (!templateBehaviors.ContainsKey(key))
            {
                var template = GetBehavior(behavior.ConcreteType);

                behavior.CopyInto(template);

                templateBehaviors.Add(key, template);

                saved = true;
            }
            else if (replaceExisting)
            {
                var template = templateBehaviors[key];
                template.Reallocate();

                behavior.CopyInto(template);

                templateBehaviors[key] = template;

                saved = true;
            }

            return(saved);
        }