Init() protected method

protected Init ( String>.Dictionary args ) : void
args String>.Dictionary
return void
        /// <summary>
        /// The factory class is lookuped up via "spatialContextFactory" in args
        /// then falling back to a Java system property (with initial caps). If neither are specified
        /// then {@link SimpleSpatialContextFactory} is chosen.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static SpatialContext MakeSpatialContext(Dictionary<String, String> args)
        {
            SpatialContextFactory instance;
            String cname;
            //if (!Configuration.GetValue("SpatialContextFactory", out cname) || cname == null)
            if (!args.TryGetValue("spatialContextFactory", out cname) || cname == null)
            {
                instance = new SpatialContextFactory();
                instance.Init(args);
                return instance.NewSpatialContext();
            }
            else
            {
                Type t = Type.GetType(cname);
                instance = (SpatialContextFactory)Activator.CreateInstance(t);

                //See if the specified type has subclassed the "NewSpatialContext" method and if so call it to do the setup
                var subClassedMethod = t.GetMethod("NewSpatialContext", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
                if (subClassedMethod != null)
                    return (SpatialContext)subClassedMethod.Invoke(instance, new object[] { });

                //Otherwise fallback to the default behaviour
                instance.Init(args);
                return instance.NewSpatialContext();
            }
        }
示例#2
0
        /// <summary>
        /// The factory class is lookuped up via "spatialContextFactory" in args
        /// then falling back to a Java system property (with initial caps). If neither are specified
        /// then {@link SimpleSpatialContextFactory} is chosen.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static SpatialContext MakeSpatialContext(Dictionary <String, String> args)
        {
            SpatialContextFactory instance;
            String cname;

            //if (!Configuration.GetValue("SpatialContextFactory", out cname) || cname == null)
            if (!args.TryGetValue("spatialContextFactory", out cname) || cname == null)
            {
                instance = new SpatialContextFactory();
                instance.Init(args);
                return(instance.NewSpatialContext());
            }
            else
            {
                Type t = Type.GetType(cname);
                instance = (SpatialContextFactory)Activator.CreateInstance(t);

                //See if the specified type has subclassed the "NewSpatialContext" method and if so call it to do the setup
                var subClassedMethod = t.GetMethod("NewSpatialContext", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
                if (subClassedMethod != null)
                {
                    return((SpatialContext)subClassedMethod.Invoke(instance, new object[] { }));
                }

                //Otherwise fallback to the default behaviour
                instance.Init(args);
                return(instance.NewSpatialContext());
            }
        }