Beispiel #1
0
        public ComponentImporter(Type type, ICustomTypeDescriptor typeDescriptor, IObjectConstructor constructor)
            : base(type)
        {
            if (typeDescriptor == null)
                typeDescriptor = new CustomTypeDescriptor(type);

            int count = 0;
            PropertyDescriptorCollection properties = typeDescriptor.GetProperties();
            IObjectMemberImporter[] importers = new IObjectMemberImporter[properties.Count];

            for (int i = 0; i < properties.Count; i++)
            {
                IServiceProvider sp = properties[i] as IServiceProvider;

                if (sp == null)
                    continue;

                IObjectMemberImporter importer = (IObjectMemberImporter) sp.GetService(typeof(IObjectMemberImporter));

                if (importer == null)
                    continue;

                importers[i] = importer;
                count++;
            }

            _properties = properties;

            if (count > 0)
                _importers = importers;

            _constructor = constructor;
        }
Beispiel #2
0
        void load_reduce()
        {
            object[]           args        = (object[])stack.pop();
            IObjectConstructor constructor = (IObjectConstructor)stack.pop();

            stack.add(constructor.construct(args));
        }
Beispiel #3
0
        void load_obj()
        {
            ArrayList          args        = stack.pop_all_since_marker();
            IObjectConstructor constructor = (IObjectConstructor)args[0];

            args = args.GetRange(1, args.Count - 1);
            object obj = constructor.construct(args.ToArray());

            stack.add(obj);
        }
Beispiel #4
0
        private void Start()
        {
            if (PrefabManager.GetInstance() == null)
            {
                throw new ApplicationException("can not init prefab manager");
            }

            Instance = this;
#if BUILD_SERVER
            GameChoice.Gamemode = GameMode.Server;
#endif
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
                if (GameChoice.GameMode == GameMode.Offline)
                {
                    creator = new AppOfflineConstructor();
                    _buildAppOffline();
                }
                break;

            case RuntimePlatform.LinuxPlayer:
                break;

            case RuntimePlatform.OSXEditor:
            case RuntimePlatform.OSXPlayer:
            case RuntimePlatform.WindowsPlayer:
            case RuntimePlatform.WindowsEditor:
                if (GameChoice.GameMode == GameMode.Offline)
                {
                    creator = new PcOfflineConstructor();
                    _buildPcOffline();
                }
                else if (GameChoice.GameMode == GameMode.Online)
                {
                    creator = new OnlineClientConstructor();
                    _buildOnlineClient();
                }
                else if (GameChoice.GameMode == GameMode.Server)
                {
                    creator = new ServerConstructor();
                    _buildOnlineServer();
                }
                break;

            default:
                throw new ArgumentException($"does not support at platform {Application.platform}");
            }
        }
Beispiel #5
0
        private void load_newobj_ex()
        {
            Hashtable          kwargs      = (Hashtable)stack.pop();
            var                args        = (object[])stack.pop();
            IObjectConstructor constructor = (IObjectConstructor)stack.pop();

            if (kwargs.Count == 0)
            {
                stack.add(constructor.construct(args));
            }
            else
            {
                throw new PickleException("newobj_ex with keyword arguments not supported");
            }
        }
Beispiel #6
0
        public ComponentImporter(Type type, ICustomTypeDescriptor typeDescriptor, IObjectConstructor constructor) :
            base(type)
        {
            if (typeDescriptor == null)
            {
                typeDescriptor = new CustomTypeDescriptor(type);
            }

            int count = 0;
            PropertyDescriptorCollection properties = typeDescriptor.GetProperties();

            IObjectMemberImporter[] importers = new IObjectMemberImporter[properties.Count];

            for (int i = 0; i < properties.Count; i++)
            {
                IServiceProvider sp = properties[i] as IServiceProvider;

                if (sp == null)
                {
                    continue;
                }

                IObjectMemberImporter importer = (IObjectMemberImporter)sp.GetService(typeof(IObjectMemberImporter));

                if (importer == null)
                {
                    continue;
                }

                importers[i] = importer;
                count++;
            }

            _properties = properties;

            if (count > 0)
            {
                _importers = importers;
            }

            _constructor = constructor;
        }
Beispiel #7
0
 /**
  * Register additional object constructors for custom classes.
  */
 public static void registerConstructor(string module, string classname, IObjectConstructor constructor)
 {
     objectConstructors[module + "." + classname]=constructor;
 }
Beispiel #8
0
 /**
  * Register additional object constructors for custom classes.
  */
 public static void registerConstructor(string module, string classname, IObjectConstructor constructor)
 {
     objectConstructors[module + "." + classname] = constructor;
 }
Beispiel #9
0
 public ComponentImporter(Type type, IObjectConstructor constructor) :
     this(type, null, constructor)
 {
 }
Beispiel #10
0
 public ComponentImporter(Type type, IObjectConstructor constructor)
     : this(type, null, constructor)
 {
 }
 public TransientLifetimeManager()
 {
     _constructor = new ObjectConstructor();
 }
 public TransientLifetimeManager(IObjectConstructor constructor)
 {
     _constructor = constructor;
 }
Beispiel #13
0
 public SingletonLifetimeManager(IObjectConstructor constructor)
 {
     _constructor = constructor;
 }
Beispiel #14
0
 public SingletonLifetimeManager()
 {
     _constructor = new ObjectConstructor();
 }