コード例 #1
0
        protected static void ProcessProfileKeys(ContentProfile profile, ProfileItem profileItem)
        {
            Assert.ArgumentNotNull(profile, "profile");
            Assert.ArgumentNotNull(profileItem, "profileItem");
            Assert.IsFalse(profile.ProfileID == ID.Null, "profile ID");

            foreach (ProfileKeyItem profileKeyItem in profileItem.Keys.ToList())
            {
                ProfileKeyItem keyItem = profileKeyItem;
                // NM: Check to see if there are any keys
                if (profile.Keys.Length == 0)
                {
                    continue;
                }

                if (profile.Keys.FirstOrDefault(k => string.Compare(k.Key, keyItem.Name, StringComparison.OrdinalIgnoreCase) == 0) == null)
                {
                    ContentProfileKeyData key = new ContentProfileKeyData(keyItem)
                    {
                        Value = keyItem.GetDefaultValue()
                    };
                    profile.AddKey(key);
                }
            }
            foreach (ContentProfileKeyData key in profile.Keys.Where(key => key.ProfileDefinitionId == Guid.Empty))
            {
                profile.RemoveKey(key);
            }
            UpdateKeyValues(profile);
        }
コード例 #2
0
            public override void Calculate()
            {
                if (Profile.Presets == null || Profile.Presets.Count == 0)
                {
                    return;
                }
                int num = 0;
                Dictionary <string, float> dictionary1 = new Dictionary <string, float>();

                foreach (string presetKey in Profile.Presets.Keys)
                {
                    if (string.IsNullOrEmpty(presetKey))
                    {
                        return;
                    }
                    ContentProfile presetProfileData = GetPresetProfileData(Profile, presetKey);
                    if (presetProfileData == null)
                    {
                        return;
                    }
                    ++num;
                    foreach (ContentProfileKeyData contentProfileKeyData in presetProfileData.Keys)
                    {
                        string key = contentProfileKeyData.Key.ToLowerInvariant();
                        if (!dictionary1.ContainsKey(key))
                        {
                            dictionary1.Add(key, 0.0f);
                        }
                        Dictionary <string, float> dictionary2;
                        string index;
                        (dictionary2 = dictionary1)[index = key] = dictionary2[index] + contentProfileKeyData.Value;
                    }
                }
                if (num <= 0)
                {
                    return;
                }
                List <string> list = new List <string>(dictionary1.Keys);

                foreach (string str in list)
                {
                    Dictionary <string, float> dictionary2;
                    string index;
                    (dictionary2 = dictionary1)[index = str] = dictionary2[index] / num;
                }
                foreach (string str in list)
                {
                    string keyId = str;
                    ContentProfileKeyData contentProfileKeyData = Profile.Keys.FirstOrDefault(k => string.Compare(k.Key, keyId, StringComparison.InvariantCultureIgnoreCase) == 0);
                    if (contentProfileKeyData != null)
                    {
                        contentProfileKeyData.Value = dictionary1[keyId];
                    }
                }
            }
コード例 #3
0
            public virtual void Calculate()
            {
                if (Profile.Presets == null || Profile.Presets.Count == 0)
                {
                    return;
                }
                if (Profile.Presets.Count > 1)
                {
                    profile.Presets = new Dictionary <string, float>
                    {
                        {
                            Profile.Presets.Keys.First(),
                            100f
                        }
                    }
                }
                ;
                string presetKey = Profile.Presets.Keys.First();

                if (string.IsNullOrEmpty(presetKey))
                {
                    return;
                }
                ContentProfile presetProfileData = GetPresetProfileData(Profile, presetKey);

                if (presetProfileData == null)
                {
                    return;
                }
                foreach (ContentProfileKeyData contentProfileKeyData1 in presetProfileData.Keys)
                {
                    string keyId = contentProfileKeyData1.Key;
                    ContentProfileKeyData contentProfileKeyData2 = Profile.Keys.FirstOrDefault(k => string.Compare(k.Key, keyId, StringComparison.InvariantCultureIgnoreCase) == 0);
                    if (contentProfileKeyData2 != null)
                    {
                        contentProfileKeyData2.Value = contentProfileKeyData1.Value;
                    }
                }
            }