Пример #1
0
 private static ExtendedAttributeValue CreateDefaultValue(ExtendedAttributeField field)
 {
     return(new ExtendedAttributeValue
     {
         ColumnIdentifier = field.ColumnIdentifier,
         Value = DefaultValues[field.FieldType](field)
     });
 }
Пример #2
0
 private void Awake()
 {
     inventory     = new List <RoomObject>();
     equippedItems = new List <RoomObject>();
     textPrompt    = FindObjectOfType <TextPrompt>();
     defaultValues = FindObjectOfType <DefaultValues>();
 }
Пример #3
0
        void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Page.User.IsInRole("ProjectAdministrator"))
                {
                    ProjectData.SelectMethod = "GetAllProjects";
                }
                else
                {
                    ProjectData.SelectParameters.Add(new Parameter("userName", TypeCode.String, Page.User.Identity.Name));
                    ProjectData.SelectParameters.Add(new Parameter("sortParameter", TypeCode.String, string.Empty));
                    ProjectData.SelectMethod = "GetProjectsByManagerUserName";
                }
                ProjectList.DataBind();

                UserData.SelectParameters.Add(new Parameter("userNames", TypeCode.String, BuildValueList(ProjectList.Items, false)));
                UserData.SelectMethod = "GetProjectMembers";

                DateTime startingDate = DefaultValues.GetDateTimeMinValue();
                DateTime endDate      = DateTime.Now;
                StartDate.Text = startingDate.ToString("d");
                EndDate.Text   = endDate.ToString("d");
            }
        }
        private DefaultValues CreateAndInitialize(IDbConnection db, int count = 1)
        {
            db.DropAndCreateTable<DefaultValues>();
            db.GetLastSql().Print();

            DefaultValues firstRow = null;
            for (var i = 1; i <= count; i++)
            {
                var defaultValues = new DefaultValues { Id = i };
                db.Insert(defaultValues);

                var row = db.SingleById<DefaultValues>(1);
                row.PrintDump();
                Assert.That(row.DefaultInt, Is.EqualTo(1));
                Assert.That(row.DefaultIntNoDefault, Is.EqualTo(0));
                Assert.That(row.NDefaultInt, Is.EqualTo(1));
                Assert.That(row.DefaultDouble, Is.EqualTo(1.1).Within(.1d));
                Assert.That(row.NDefaultDouble, Is.EqualTo(1.1).Within(.1d));
                Assert.That(row.DefaultString, Is.EqualTo("String"));

                if (firstRow == null)
                    firstRow = row;
            }

            return firstRow;
        }
Пример #5
0
        public void ClientRegistred(Client client, string billingMessage, DefaultValues defaults)
        {
            try {
                new NotificationService(session, defaults).NotifySupplierAboutDrugstoreRegistration(client, false);

                var user = client.Users.FirstOrDefault();
                var body = new StringWriter();
                body.WriteLine("Оператор: {0}", SecurityContext.Administrator.UserName);
                body.WriteLine("Регион: {0}", client.HomeRegion.Name);
                if (user != null)
                {
                    body.WriteLine("Имя пользователя: {0}", user.Login);
                }
                body.WriteLine("Код: {0}", client.Id);

                if (!String.IsNullOrEmpty(billingMessage))
                {
                    body.WriteLine("Сообщение в биллинг: " + billingMessage);
                }

                if (user != null && user.Accounting.IsFree)
                {
                    body.WriteLine(user.Accounting.RegistrationMessage);
                }

                NotificationHelper.NotifyAboutRegistration(
                    String.Format("\"{0}\" - успешная регистрация", client.FullName),
                    body.ToString());
            }
            catch (Exception e) {
                _log.Error("Ошибка при отправке уведомления", e);
            }
        }
Пример #6
0
        public List <IComparable[]> ConvertTableDataToNewSchema(List <List <IComparable> > oldRows,
                                                                List <ColumnDefinition> newColumnDefinitions,
                                                                List <ColumnDefinition> oldColumnDefinitions)
        {
            var nameAndTypeToNewColumnDefinition = newColumnDefinitions.ToDictionary(x => Tuple.Create(x.ColumnName.ToLower(), x.Type), x => x);

            var indexToNewColumnDefinition = newColumnDefinitions.ToDictionary(x => x.Index, x => x);

            var indexToDefinitionOld = oldColumnDefinitions.ToDictionary(x => x.Index, x => x);

            List <IComparable[]> newRows = new List <IComparable[]>();

            for (int i = 0; i < oldRows.Count; i++)
            {
                IComparable[] newRow = new IComparable[newColumnDefinitions.Count];

                var populatedIndexes = new HashSet <byte>();

                //fill in values for columns that exist in both
                for (byte j = 0; j < oldRows[i].Count; j++)
                {
                    ColumnDefinition oldColDefinition = indexToDefinitionOld[j];

                    Tuple <string, TypeEnum> columnKey = Tuple.Create(oldColDefinition.ColumnName.ToLower(), oldColDefinition.Type);

                    if (!nameAndTypeToNewColumnDefinition.ContainsKey(columnKey))
                    {
                        continue;
                    }

                    ColumnDefinition newDefinition = nameAndTypeToNewColumnDefinition[columnKey];

                    byte newColumnIndex = newDefinition.Index;

                    newRow[newColumnIndex] = oldRows[i][j];

                    if (newDefinition.Type == TypeEnum.String && newDefinition.ByteSize != ((string)oldRows[i][j]).Length)
                    {
                        newRow[newColumnIndex] = GetResizedStringValue((string)oldRows[i][j], newDefinition);
                    }

                    populatedIndexes.Add(newColumnIndex);
                }

                //set default values for newly added columns
                for (byte j = 0; j < newRow.Length; j++)
                {
                    if (!populatedIndexes.Contains(j))
                    {
                        IComparable val = DefaultValues.GetDefaultDotNetValueForType(indexToNewColumnDefinition[j].Type);

                        newRow[j] = val;
                    }
                }

                newRows.Add(newRow);
            }

            return(newRows);
        }
 public void SetDefaultInstance()
 {
     if (DefaultInstance == null)
     {
         var constuctor = type.GetConstructor(new Type[] { });
         if (constuctor != null)
         {
             DefaultInstance = constuctor.Invoke(new object[] { });
         }
         var prop = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
         if (DefaultInstance != null)
         {
             foreach (PropertyInfo item in prop)
             {
                 DefaultValues.Add(item, item.GetValue(DefaultInstance, new object[] { }));
             }
         }
         else
         {
             foreach (PropertyInfo item in prop)
             {
                 DefaultValues.Add(item, item.PropertyType.GetDefaultValue());
             }
         }
     }
 }
 /// <summary>
 /// Ensure the operating context is in a valid state prior to using it.
 /// </summary>
 internal virtual void Validate()
 {
     if (this.Defaults == null)
     {
         this.Defaults = new DefaultValues();
     }
 }
        /// <summary>
        /// Get the default values for a particular templare
        /// </summary>
        /// <param name="templateID"></param>
        /// <returns>A DefaultValues object</returns>
        private DefaultValues GetDefaultValues(int templateID)
        {
            TimeSpan          timeSpan       = DateTime.Now.TimeOfDay;
            DefaultValues     def            = new DefaultValues();
            TalentDataObjects talDataObjects = new TalentDataObjects();
            string            cacheKey       = "ActivityTemplateDefaults" + Talent.Common.Utilities.FixStringLength("MAINTENANCE", 50) + Talent.Common.Utilities.FixStringLength("*ALL", 50);

            talDataObjects.Settings = businessObjects.Environment.Settings.GetBasicSettingsObject();
            DataTable defaults = talDataObjects.ActivitiesSettings.TblActivityTemplatesDefaults.GetDefaultsByTemplateID(templateID);

            if (Talent.Common.TalentThreadSafe.ItemIsInCache(cacheKey))
            {
                def = (DefaultValues)businessObjects.Data.Cache.Get(cacheKey);
            }
            else
            {
                try
                {
                    if (defaults.Rows.Count > 0)
                    {
                        def = PopulateDefaults(def, defaults);
                    }
                }
                catch (Exception ex)
                {
                }
                //Add to cache now
                businessObjects.Data.Cache.Add(cacheKey, def, businessObjects.Environment.Settings.CacheTimeInMins);
            }
            businessObjects.Logging.LoadTestLog("ActivityTemplateDefaults.cs", "GetDefaultValuesByTemplateID", timeSpan);
            return(def);
        }
        /// <summary>
        /// Fills the defaultvalues object from tbl_activity_templates_defaults
        /// </summary>
        /// <param name="def"></param>
        /// <param name="defaults"></param>
        /// <returns>Default Values object</returns>
        private DefaultValues PopulateDefaults(DefaultValues def, DataTable defaults)
        {
            try
            {
                foreach (DataRow defRow in defaults.Rows)
                {
                    try
                    {
                        switch (defRow["DEFAULT_NAME"].ToString())
                        {
                        case "COMPLIMENTARY_CHECK_ENABLED":
                            def.ComplimentaryCheckEnabled = businessObjects.Data.Validation.CheckForDBNull_Boolean_DefaultFalse(defRow["DEFAULT_VALUE"]);
                            break;

                        case "DISPLAY_ON_PRICE_BAND":
                            def.DisplayOnPriceBand = businessObjects.Data.Validation.CheckForDBNull_Boolean_DefaultFalse(defRow["DEFAULT_VALUE"]);
                            break;

                        case "DISPLAY_ON_PRICE_CODE":
                            def.DisplayOnPriceCode = businessObjects.Data.Validation.CheckForDBNull_Boolean_DefaultFalse(defRow["DEFAULT_VALUE"]);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(def);
        }
Пример #11
0
        public void ResolveWithDefaults()
        {
            //TODO - this method is potentially disastrously O(N^2) slow due to linear search nested in loop

            //Add missing entries
            foreach (Binding default_binding in DefaultValues)
            {
                var binding = Bindings.FirstOrDefault(x => x.DisplayName == default_binding.DisplayName);
                if (binding == null)
                {
                    Bindings.Add(default_binding);
                }
                else
                {
                    //patch entries with updated settings (necessary because of TODO LARP
                    binding.Ordinal        = default_binding.Ordinal;
                    binding.DefaultBinding = default_binding.DefaultBinding;
                    binding.TabGroup       = default_binding.TabGroup;
                    binding.ToolTip        = default_binding.ToolTip;
                    binding.Ordinal        = default_binding.Ordinal;
                }
            }

            List <Binding> entriesToRemove = (from entry in Bindings let binding = DefaultValues.FirstOrDefault(x => x.DisplayName == entry.DisplayName) where binding == null select entry).ToList();

            //Remove entries that no longer exist in defaults

            foreach (Binding entry in entriesToRemove)
            {
                Bindings.Remove(entry);
            }
        }
Пример #12
0
        public override bool UpdateCategory(Category newCategory)
        {
            if (newCategory == null)
            {
                throw (new ArgumentNullException("newCategory"));
            }

            if (newCategory.Id <= DefaultValues.GetCategoryIdMinValue())
            {
                throw (new ArgumentOutOfRangeException("newCategory.Id"));
            }

            SqlCommand sqlCmd = new SqlCommand();

            AddParamToSQLCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);

            AddParamToSQLCmd(sqlCmd, "@CategoryId", SqlDbType.Int, 0, ParameterDirection.Input, newCategory.Id);
            AddParamToSQLCmd(sqlCmd, "@CategoryAbbreviation", SqlDbType.NText, 255, ParameterDirection.Input, newCategory.Abbreviation);
            AddParamToSQLCmd(sqlCmd, "@CategoryEstimateDuration", SqlDbType.Decimal, 0, ParameterDirection.Input, newCategory.EstimateDuration);
            AddParamToSQLCmd(sqlCmd, "@CategoryName", SqlDbType.NText, 255, ParameterDirection.Input, newCategory.Name);
            AddParamToSQLCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, newCategory.ProjectId);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_CATEGORY_UPDATE);
            ExecuteScalarCmd(sqlCmd);

            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;

            return(returnValue == 0 ? true : false);
        }
Пример #13
0
        public void ResolveWithDefaults()
        {
            // TODO - this method is potentially disastrously O(N^2) slow due to linear search nested in loop

            // Add missing entries
            foreach (Binding defaultBinding in DefaultValues)
            {
                var binding = Bindings.FirstOrDefault(b => b.DisplayName == defaultBinding.DisplayName);
                if (binding == null)
                {
                    Bindings.Add(defaultBinding);
                }
                else
                {
                    // patch entries with updated settings (necessary because of TODO LARP
                    binding.Ordinal        = defaultBinding.Ordinal;
                    binding.DefaultBinding = defaultBinding.DefaultBinding;
                    binding.TabGroup       = defaultBinding.TabGroup;
                    binding.ToolTip        = defaultBinding.ToolTip;
                    binding.Ordinal        = defaultBinding.Ordinal;
                }
            }

            // Remove entries that no longer exist in defaults
            Bindings.RemoveAll(entry => DefaultValues.All(b => b.DisplayName != entry.DisplayName));
        }
Пример #14
0
 public void Read(AssetStream stream)
 {
     m_layerArray        = stream.ReadArray <OffsetPtr <LayerConstant> >();
     m_stateMachineArray = stream.ReadArray <OffsetPtr <StateMachineConstant> >();
     Values.Read(stream);
     DefaultValues.Read(stream);
 }
 private static void UpdateValues()
 {
     using (new SessionScope()) {
         _values = DefaultValues.Get();
     }
     _lastUpdate = DateTime.Now;
 }
Пример #16
0
 public void Read(EndianStream stream)
 {
     m_layerArray        = stream.ReadArray(() => new OffsetPtr <LayerConstant>(new LayerConstant(m_assetsFile)));
     m_stateMachineArray = stream.ReadArray(() => new OffsetPtr <StateMachineConstant>(new StateMachineConstant(m_assetsFile)));
     Values.Read(stream);
     DefaultValues.Read(stream);
 }
 public StockMarketSimulation(DefaultValues dv)
 {
     this.defaultValues = dv;
     StockMarketSimulation.simDay = 0;
     stopwatch = new Stopwatch();
     StopwatchTimes = new List<string>();
 }
Пример #18
0
        private DefaultValues TryRestoreSettingsBackup(string fileName)
        {
            DefaultValues defaultValues = null;

            var lastIndexOf = fileName.LastIndexOf(".");

            var extension = fileName.Substring(lastIndexOf);

            var fileBaseName = fileName.Substring(0, lastIndexOf);

            for (var backupIndex = 1; backupIndex <= MaximumBackups; backupIndex++)
            {
                var newFileName = fileBaseName + "." + backupIndex.ToString() + extension;

                if (_ioServices.File.Exists(newFileName))
                {
                    try
                    {
                        var settings = SerializerHelper.Deserialize <Settings>(_ioServices, newFileName);

                        defaultValues = settings.DefaultValues;

                        break;
                    }
                    catch
                    { }
                }
            }

            return(defaultValues);
        }
        public void Get_email_price_date_test()
        {
            //триггер на Обновлении PriceItem - PriceItemBeforeUpdate, постоянно обновляет дату текущим временем, поэтому ноужно вставлять "просроченную" дату.
            _email = Guid.NewGuid().ToString().Replace("-", string.Empty) + "@analit.net";

            _supplier = DataMother.CreateSupplier();
            _supplier.ContactGroupOwner.Group(ContactGroupType.ClientManagers).AddContact(ContactType.Email, _email);

            Save(_supplier);

            var item = _supplier.Prices.First().Costs.First().PriceItem;
            var itemCosts = _supplier.Prices.First().Costs.First(); var newpPriceItem = new PriceItem()

            {
                DownloadLogs = item.DownloadLogs, FormRule = item.FormRule, PriceDate = DateTime.MinValue, Source = item.Source
            };
            itemCosts.PriceItem = newpPriceItem;
            Save(itemCosts);

            _defaults = session.Query <DefaultValues>().First();
            _service  = new NotificationService(session, _defaults);
            _client   = DataMother.TestClient();
            Flush();

            var emails = _service.GetEmailsForNotification(_client);

            Assert.IsFalse(emails.Contains(_email));
        }
Пример #20
0
        private async Task <DefaultValues> CreateAndInitializeAsync(IDbConnection db, int count = 1)
        {
            db.DropAndCreateTable <DefaultValues>();
            db.GetLastSql().Print();

            DefaultValues firstRow = null;

            for (var i = 1; i <= count; i++)
            {
                var defaultValues = new DefaultValues {
                    Id = i
                };
                await db.InsertAsync(defaultValues);

                var row = await db.SingleByIdAsync <DefaultValues>(1);

                row.PrintDump();
                Assert.That(row.DefaultInt, Is.EqualTo(1));
                Assert.That(row.DefaultIntNoDefault, Is.EqualTo(0));
                Assert.That(row.NDefaultInt, Is.EqualTo(1));
                Assert.That(row.DefaultDouble, Is.EqualTo(1.1).Within(.1d));
                Assert.That(row.NDefaultDouble, Is.EqualTo(1.1).Within(.1d));
                Assert.That(row.DefaultString, Is.EqualTo("String"));

                if (firstRow == null)
                {
                    firstRow = row;
                }
            }

            return(firstRow);
        }
        /// <summary>
        /// Buffer that can be used to retrieve the default values
        /// </summary>
        /// <param name="templateID"></param>
        /// <returns></returns>
        public DefaultValues GetDefaults(int templateID)
        {
            DefaultValues activityDefaultValues = new DefaultValues();

            activityDefaultValues = GetDefaultValues(templateID);
            return(activityDefaultValues);
        }
Пример #22
0
        static void Main(string[] args)
        {
            DefaultValues dv = new DefaultValues();

            Console.WriteLine("byte={0}", dv.b);
            Console.WriteLine("sbyte={0}", dv.sb);
            Console.WriteLine("short={0}", dv.s);
            Console.WriteLine("ushort={0}", dv.us);
            Console.WriteLine("int={0}", dv.i);
            Console.WriteLine("uint={0}", dv.ui);
            Console.WriteLine("long={0}", dv.l);
            Console.WriteLine("ulong={0}", dv.ul);
            Console.WriteLine("float={0}", dv.f);
            Console.WriteLine("double={0}", dv.d);
            Console.WriteLine("char={0}", dv.ch);
            Console.WriteLine("bool={0}", dv.bo);
            Console.WriteLine("decimal={0}", dv.dec);
            Console.WriteLine("string={0}", dv.str);

            Valori v = new Valori();


            SmartPhone sp = new SmartPhone {
                Marca = ""
            };

            Console.ReadLine();
        }
Пример #23
0
 public void Read(AssetReader reader)
 {
     LayerArray        = reader.ReadAssetArray <OffsetPtr <LayerConstant> >();
     StateMachineArray = reader.ReadAssetArray <OffsetPtr <StateMachineConstant> >();
     Values.Read(reader);
     DefaultValues.Read(reader);
 }
    static void Main()
    {
        DefaultValues dv = new DefaultValues();

        Console.WriteLine(dv.c);
        Console.WriteLine(dv.d);
    }
Пример #25
0
        public override Category GetCategoryByCategoryId(int Id)
        {
            if (Id <= DefaultValues.GetCategoryIdMinValue())
            {
                throw (new ArgumentOutOfRangeException("Id"));
            }


            SqlCommand sqlCmd = new SqlCommand();

            AddParamToSQLCmd(sqlCmd, "@CategoryId", SqlDbType.Int, 0, ParameterDirection.Input, Id);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_CATEGORY_GETCATEGORYBYID);

            List <Category> categoryList = new List <Category>();

            TExecuteReaderCmd <Category>(sqlCmd, TGenerateCategoryListFromReader <Category>, ref categoryList);

            if (categoryList.Count > 0)
            {
                return(categoryList[0]);
            }
            else
            {
                return(null);
            }
        }
Пример #26
0
    static FooPlugin()
    {
        var bar = new Bar();

        Defaults = new DefaultValues()
                   .Add(() => PluginFunction(42, 13))
                   .Add(() => AnotherFunction(bar));
    }
Пример #27
0
 public AdvBandedViewModelAdapterController()
 {
     DefaultValues.Add("AutoFillDown", true);
     DefaultValues.Add("ColVIndex", 0);
     DefaultValues.Add("RowIndex", 0);
     NonNullableObjects.Add("RowIndex");
     NonNullableObjects.Add("ColVIndex");
 }
Пример #28
0
 protected GridViewModelAdapterControllerBase()
 {
     DefaultValues.Add("EnableMasterViewMode", false);
     DefaultValues.Add("MultiSelect", true);
     DefaultValues.Add("ColumnAutoWidth", true);
     GridViewMappings.Add("ShowFooter", "IsFooterVisible");
     GridViewMappings.Add("ShowGroupPanel", "IsGroupPanelVisible");
 }
Пример #29
0
 private void Start()
 {
     textPrompt    = FindObjectOfType <TextPrompt>();
     roomTracker   = FindObjectOfType <RoomTracker>();
     player        = FindObjectOfType <Player>();
     actionHandler = FindObjectOfType <ActionHandler>();
     defaultValues = FindObjectOfType <DefaultValues>();
 }
Пример #30
0
        public void SaveSettings(string fileName, DefaultValues defaultValues)
        {
            var settings = new Settings()
            {
                DefaultValues = defaultValues,
            };

            SerializerHelper.Serialize(_ioServices, fileName, settings);
        }
Пример #31
0
 public void NotifySupplierAboutAddressRegistration(Address address, DefaultValues defaults)
 {
     try {
         new NotificationService(session, defaults).NotifySupplierAboutAddressRegistration(address);
     }
     catch (Exception e) {
         _log.Error("Ошибка при отправке уведомления", e);
     }
 }
Пример #32
0
    private static void showFlavorTexts(RoomObject obj, DefaultValues defaultValues)
    {
        GUILayout.Space(10);
        EditorGUILayout.LabelField(new GUIContent("Flavor Texts", "Set the responses when something happens to this object. " +
                                                  "Flavor texts get printed regardless of the action's success or not."), EditorStyles.boldLabel);

        if (defaultValues.eatActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Edible Flavor Text", "The response that's printed when the player attempts to eat this object."));
            obj.edibleFlavorText = EditorGUILayout.TextArea(obj.edibleFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.drinkActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Drinkable Flavor Text", "The response that's printed when the player attempts to drink this object."));
            obj.drinkableFlavorText = EditorGUILayout.TextArea(obj.drinkableFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.talkActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Talkable Flavor Text", "The response that's printed when the player attempts to talk to this object."));
            obj.talkableFlavorText = EditorGUILayout.TextArea(obj.talkableFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.killActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Killable Flavor Text", "The response that's printed when the player attemps to kill this object."));
            obj.killableFlavorText = EditorGUILayout.TextArea(obj.killableFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.breakActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Breakable Flavor Text", "The response that's printed when the player attempts to break this object."));
            obj.breakableFlavorText = EditorGUILayout.TextArea(obj.breakableFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.sitActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Sittable Flavor Text", "The response that's printed when the player attempts to sit on this object."));
            obj.sittableFlavorText = EditorGUILayout.TextArea(obj.sittableFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.useActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Usable Flavor Text", "The response that's printed when the player attempts to use this object."));
            obj.usableFlavorText = EditorGUILayout.TextArea(obj.usableFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.pickupActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Pickupable Flavor Text", "The response that's printed when the player attempts to pick up this object."));
            obj.pickupableFlavorText = EditorGUILayout.TextArea(obj.pickupableFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.wearActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Wearable Flavor Text", "The response that's printed when the player attempts to wear this object."));
            obj.wearableFlavorText = EditorGUILayout.TextArea(obj.wearableFlavorText, EditorStyles.textArea);
        }
        if (defaultValues.openActive)
        {
            EditorGUILayout.PrefixLabel(new GUIContent("Openable Flavor Text", "The response that's printed when the player attempts to open this object."));
            obj.openableFlavorText = EditorGUILayout.TextArea(obj.openableFlavorText, EditorStyles.textArea);
        }
    }
Пример #33
0
 public static void Run()
 {
     // 初期化せずにフィールドを読んでみる(規定値が入っている)
     var a = new DefaultValues();
     Console.WriteLine(a.i);
     Console.WriteLine(a.x);
     Console.WriteLine((int)a.c); // '\0' (ヌル文字)は表示できないので数値化して表示
     Console.WriteLine(a.b); // False
     Console.WriteLine(a.s == null); // null は表示できないので比較で。True になる
 }
 private void createAgents(DefaultValues dv)
 {
     int agentNumber = dv.ternaAgentNumber + dv.randomAgentNumber + dv.rsAgentNumber + dv.raAgentNumber;
     for (int i = 0; i < agentNumber; i++)
     {
         if (i < dv.randomAgentNumber) AgentList.Add(new RandomAgent(i, dv));
         else if (i < dv.randomAgentNumber+dv.ternaAgentNumber) AgentList.Add(new TernaAgent(i, dv));
         else if (i < dv.randomAgentNumber+dv.ternaAgentNumber+dv.rsAgentNumber) AgentList.Add(new RiskSeekingAgent(i, dv));
         else if (i < dv.randomAgentNumber + dv.ternaAgentNumber + dv.rsAgentNumber + dv.raAgentNumber) AgentList.Add(new RiskAvoidingAgent(i, dv));
     }
 }
Пример #35
0
        private void agentPreferencesMenu_Click(object sender, EventArgs e)
        {
            AgentSettingsDialog dialog = new AgentSettingsDialog();
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                agentValues = new DefaultValues(dialog.EpochNumber, dialog.NumberOfTernaAgents, dialog.NumberOfRandomAgents, dialog.NumberOfRiskSeekingAgents, dialog.NumberOfRiskAvoidingAgents, dialog.NumberOfStocks, dialog.Budget, dialog.MaxOrders, dialog.StopLoss, (float) dialog.ProbOfImitatingMarket,
                                                (float)dialog.ProbOfLocalImitation, (float) dialog.AsymmetricBuySellProb, (float)dialog.ProbBeforeOpening,
                                                (float) dialog.MinCorrection, (float)dialog.MaxCorrection, (float)dialog.FloorPrice, (float)dialog.AgentProbActBelowFloorPrice, dialog.MeanPriceHistoryLength,
                                                dialog.LocalHistoryLength, (float) dialog.AgentProbAdoptStopLoss, (float)dialog.MaxLossRate);
            }
        }
        public RandomAgent(int number, DefaultValues df)
        {
            this.number = number;
            this.maxOrderNumber = df.maxOrderNumber;

            this.minCorrectingCoefficient = df.minCorrectingCoefficient;
            this.maxCorrectingCoefficient = df.maxCorrectingCoefficient;

            this.budget = df.budget;
            this.budgetHistory = new List<float>();
            this.budgetHistory.Add(this.budget);
            this.ownedStocks = new Dictionary<int, int>();
            createStockInventory(df);
        }
Пример #37
0
        public Form1()
        {
            InitializeComponent();

            //create default values
            defaultValues = new defaultValues();
            defaultValues.days = 100;
            defaultValues.selectedStockNumber = 0;
            defaultValues.numberOfStocks = 5;

            //create stock manager
            stockManager = new StockManager();
            stockManager.loadRealDataStocks(defaultValues.numberOfStocks);

            agentValues = new DefaultValues();
        }
 public TernaAgent(int number, DefaultValues df)
 {
     this.number = number;
     this.maxOrderNumber = df.maxOrderNumber;
     this.stopLossInterval = df.stopLossInterval;
     this.probOfImitatingTheMarket = df.probOfImitatingTheMarket;
     this.probOfLocalImitation = df.probOfLocalImitation;
     this.asymmetricBuySellProb = df.asymmetricBuySellProb;
     this.agentProbToActBeforeOpening = df.agentProbToActBeforeOpening;
     this.minCorrectingCoefficient = df.minCorrectingCoefficient;
     this.maxCorrectingCoefficient = df.maxCorrectingCoefficient;
     this.floorP = df.floorP;
     this.agentProbToActBelowFloorPrice = df.agentProbToActBelowFloorPrice;
     this.meanPriceHistoryLength = df.meanPriceHistoryLength;
     this.localHistoryLength = df.localHistoryLength;
     this.agentProbToAdoptStopLoss = df.agentProbToAdoptStopLoss;
     this.maxLossRate = df.maxLossRate;
     this.budget = df.budget;
     this.budgetHistory = new List<float>();
     this.budgetHistory.Add(this.budget);
     this.ownedStocks = new Dictionary<int, int>();
     createStockInventory(df);
 }
 public AgentManager(DefaultValues dv)
 {
     this.dv = dv;
     createAgents(dv);
 }
 public StockMarketSimulation()
 {
     DefaultValues defaultValues = new DefaultValues();
     stopwatch = new Stopwatch();
     StopwatchTimes = new List<string>();
 }
Пример #41
0
        /// <summary>
        /// Organize fields and values to set in a HybridDictionary
        /// </summary>
        /// <param name="defaultValues"></param>
        /// <returns></returns>
        private static DefaultValues[] PrepareDefaultValues(XmlNode defaultValues)
        {
            XmlNodeList nodes = defaultValues.ChildNodes;
            if (nodes.Count == 0)
                return null;

            DefaultValues[] arrDV = new DefaultValues[nodes.Count];
            DefaultValues dvObj;
            for (int i = 0; i < nodes.Count; i++)
            {
                dvObj = new DefaultValues();

                dvObj.ValueToCompare = (nodes[i].Attributes["value"] != null)? nodes[i].Attributes["value"].Value: null;

                if (nodes[i].Name == "equals")
                    dvObj.compareType = CompareType.EQUALS;
                else if (nodes[i].Name == "differs")
                    dvObj.compareType = CompareType.DIFFERS;
                else if (nodes[i].Name == "any")
                    dvObj.compareType = CompareType.NONE;

                if (nodes[i].ChildNodes.Count > 0)
                {
                    dvObj.FieldsToSet = new ArrayList();
                    foreach (XmlNode field in nodes[i].ChildNodes)
                    {
                        dvObj.FieldsToSet.Add(
                            new string[] {
                                field.Attributes["id"].Value,
                                field.Attributes["value"]  != null ? field.Attributes["value"].Value  : null,
                                (field.Attributes["required"] != null && field.Attributes["required"].Value.ToLower() == bool.TrueString.ToLower() ? bool.TrueString : bool.FalseString),
                                (field.Attributes["disabled"] != null && field.Attributes["disabled"].Value.ToLower() == bool.TrueString.ToLower() ? bool.TrueString : bool.FalseString),
                                (field.Attributes["invisible"] != null && field.Attributes["invisible"].Value.ToLower() == bool.TrueString.ToLower() ? bool.TrueString : bool.FalseString),
                                (field.Attributes["set"] != null ? field.Attributes["set"].Value:""),
                                null // this is the value to inspect and is set on DoManegedNodes
                            }
                        );
                    }
                }

                arrDV[i] = dvObj;
            }

            return arrDV;
        }
Пример #42
0
			/// <summary>
			/// Ensure the operating context is in a valid state prior to using it.
			/// </summary>
			internal virtual void Validate()
			{
				if (this.Defaults == null)
					this.Defaults = new DefaultValues();
			}
Пример #43
0
 protected void createStockInventory(DefaultValues defaultValues)
 {
     for (int i = 0; i < defaultValues.stockNumber; i++)
     {
         this.ownedStocks.Add(i, 0);
     }
 }