Example #1
0
        /// <summary>
        /// finds the value manager that can handle the object
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public INodeValueManager FindHandlingValueManager(object obj, IGraph graph, params string[] ignoreList)
        {
            INodeValueManager rv = null;

            foreach (var each in this.ValueManagers)
            {
                //ALWAYS ignore UndeclaredValueManager
                if (each is UndeclaredValueManager)
                {
                    continue;
                }

                //don't look for handling managers from the ignore list
                if (ignoreList != null && ignoreList.Contains(each.Id))
                {
                    continue;
                }

                if (each.CanHandle(obj, graph))
                {
                    rv = each;
                    break;
                }
            }

            return(rv);
        }
Example #2
0
 public static NullCheckDecoration DecorateWithNullCheck(this INodeValueManager mgr)
 {
     Condition.Requires(mgr).IsNotNull();
     if (mgr is NullCheckDecoration)
     {
         return((NullCheckDecoration)mgr);
     }
     return(new NullCheckDecoration(mgr));
 }
Example #3
0
        public void Parse(string text)
        {
            Condition.Requires(text).IsNotNullOrEmpty();
            var list = LengthEncoder.LengthDecodeList(text);

            List <INodeValueManager> plugins = null;
            //strategy to load the managers (via assembly interrogation/plugin loading)
            Action initPlugins = () =>
            {
                TypeContainer <INodeValueManager> types = TypeContainer <INodeValueManager> .NewDefault();

                plugins = new List <INodeValueManager>();
                foreach (var each in types.ContainedTypes)
                {
                    try
                    {
                        INodeValueManager mgr = Activator.CreateInstance(each) as INodeValueManager;
                        if (list.Contains(mgr.Id))
                        {
                            plugins.Add(mgr);
                        }
                    }
                    catch { }
                }
            };

            //hydrate the managers list in the specified order
            var newList = new List <INodeValueManager>();

            foreach (var each in list)
            {
                //get the mgr by id from the current managers (we want to use managers that we've explicitly added, first)
                //  if it can't be found, get it from the plugins
                var mgr = this.ValueManagers.Find(x => x.Id == each);
                if (mgr == null)
                {
                    //we can't find the manager so load the plugins
                    if (plugins == null)
                    {
                        initPlugins();
                    }

                    mgr = plugins.Find(x => x.Id == each);
                }

                Condition.Requires(mgr).IsNotNull();
                newList.Add(mgr);
            }
            this.ValueManagers = newList;
        }
Example #4
0
        public INodeValueManager GetValueManagerById(string id)
        {
            INodeValueManager rv = null;

            foreach (var each in this.ValueManagers)
            {
                if (each.Id.Equals(id))
                {
                    rv = each;
                    break;
                }
            }

            return(rv);
        }
Example #5
0
 public override IDecorationOf<INodeValueManager> ApplyThisDecorationTo(INodeValueManager thing)
 {
     return new NullCheckDecoration(thing);
 }
Example #6
0
 public NullCheckDecoration(INodeValueManager decorated)
     : base(decorated)
 {
 }
Example #7
0
 public override IDecorationOf <INodeValueManager> ApplyThisDecorationTo(INodeValueManager thing)
 {
     return(new NullCheckDecoration(thing));
 }
Example #8
0
 public NullCheckDecoration(INodeValueManager decorated)
     : base(decorated)
 {
 }