コード例 #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Explicit initialization. Must be called on creating new project.
        /// </summary>
        public void PostInit(CapacitiesInfo capacitiesInfo,
                             OrderCustomPropertiesInfo orderCustomPropertiesInfo)
        {
            Debug.Assert(!_isInited); // init once

            // add scheme objects
            DataModel.ConfigSchemes scheme = DataModel.ConfigSchemes.CreateConfigSchemes(SCHEME_ID_CAPACITIES);
            scheme.Name  = SCHEME_NAME_CAPACITIES;
            scheme.Value = ConfigDataSerializer.SerializeCapacitiesInfo(capacitiesInfo);
            AddObject(SCHEMES_ENTITY_SET, scheme);

            scheme       = DataModel.ConfigSchemes.CreateConfigSchemes(SCHEME_ID_ORDERPROPERTIES);
            scheme.Name  = SCHEME_NAME_ORDERPROPERTIES;
            scheme.Value = ConfigDataSerializer.SerializeOrderCustomPropertiesInfo(orderCustomPropertiesInfo);
            AddObject(SCHEMES_ENTITY_SET, scheme);

            base.SaveChanges();

            // create object factory
            ObjectInitData initData = new ObjectInitData();

            initData.CapacitiesInfo            = capacitiesInfo;
            initData.OrderCustomPropertiesInfo = orderCustomPropertiesInfo;

            _fact        = new DataObjectFactory(initData);
            _objInitData = initData;

            // Attach handler for SavingChanges event.
            this.SavingChanges += new EventHandler(DataObjectContext_SavingChanges);
            _isInited           = true;
        }
コード例 #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        private void _Init()
        {
            Debug.Assert(!_isInited); // init once

            // check if project DB contains config schemes
            if (_IsConfigSchemeExist(SCHEME_ID_CAPACITIES) &&
                _IsConfigSchemeExist(SCHEME_ID_ORDERPROPERTIES))
            {
                // load schemes
                ObjectInitData initData = new ObjectInitData();
                initData.CapacitiesInfo            = _LoadCapacitiesInfo();
                initData.OrderCustomPropertiesInfo = _LoadOrderPropertiesInfo();

                // create object factory
                _fact        = new DataObjectFactory(initData);
                _objInitData = initData;

                // attach events
                this.SavingChanges += new EventHandler(DataObjectContext_SavingChanges);
                _isInited           = true;
            }
        }
コード例 #3
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        public DataObjectFactory(ObjectInitData initData)
        {
            Debug.Assert(initData != null);
            _initData = initData;
        }