public void TestList() { var primitiveList = new PropertyList { 1, 2, 3 }; Assert.Equal(primitiveList.Count, 3); // TODO: Add As<IEnumerable<int>> conversion?! Assert.Equal(primitiveList.Select(p => p.As <int>()), new int[] { 1, 2, 3 }); Assert.Equal(primitiveList[0].As <int>(), 1); Assert.Equal(primitiveList[1].As <int>(), 2); Assert.Equal(primitiveList[2].As <int>(), 3); Assert.Throws <ArgumentOutOfRangeException>(() => primitiveList[-1]); Assert.Throws <ArgumentOutOfRangeException>(() => primitiveList[3]); primitiveList[1] = Property.Of(-1); Assert.Equal(primitiveList[1].As <int>(), -1); primitiveList.Add(4); Assert.Equal(primitiveList.Count, 4); Assert.Equal(primitiveList[3].As <int>(), 4); primitiveList.RemoveAt(3); Assert.Equal(primitiveList.Count, 3); primitiveList.Add("not int"); Assert.Equal(primitiveList.Count, 4); primitiveList[1] = Property.Of("not int"); Assert.Equal(primitiveList.Count, 4); }
public Flusso(Variable father, string[] fields, List<string> map) { this.father = father; protocolname = map[0]; propertyDefinitions = VarDefinitions.Map[map[0]]; propertyValues = new PropertyList(); if (Regex.IsMatch(map[0], "Variables|Common", RegexOptions.IgnoreCase)) name = map[0]; else name = fields[1]; name = name.Trim(); foreach (var pt in propertyDefinitions) { if (!pt.Value.Visibile) continue; int i = map.FindIndex(x => x == pt.Key); if (pt.Key=="Abilitato") { if (!Boolean.TryParse(fields[i-1], out abilitazione)) abilitazione = false; } if (i > 0) { propertyValues.Add(pt.Key, fields[i - 1].Replace("%sc%",";").Trim(),pt.Value); } else propertyValues.Add(pt.Key, "", pt.Value); } }
private static IEnumerable <KeyValuePair <string, object> > Describe(IType type) { var hierarchy = new JsObject(type.GetFullTypeHierarchy().Select(x => new KeyValuePair <object, object>(x.FullName, 1))); var newFunc = new JsFunction(); newFunc.Body.Add(type.New().Return()); var list = new PropertyList { { "ns", type.Namespace ?? "" }, { "name", type.Name }, { "kind", type.GetCorlibKind() }, { "$typecode", type.JsTypeCode() }, { "$hierarchy", hierarchy }, { "$new", newFunc }, }; if (type.ElementType != null) { list.Add("$elemType", type.ElementType.FullName); } if (type.ValueType != null) { list.Add("$valueType", type.ValueType.FullName); } return(list); }
public void OverwriteItemsWithTheSameName() { var data = new PropertyList(); data.Add("A", 100.1); data.Add("B", 1); data.Add("A", true); Assert.AreEqual(2, data.Count); Assert.AreEqual(true, data["A"].BooleanValue); Assert.AreNotEqual(100.1, data["A"].DoubleValue); }
public void Enumerable_Count() { var container = new TestContainer(); PropertyList <TestContainer, float> propertyList = container.FloatList; propertyList.Add(1); propertyList.Add(2); propertyList.Add(3); Assert.AreEqual(3, propertyList.Count()); }
public void Enumerator_InitializesCurrentToDefault() { var container = new TestContainer(); PropertyList <TestContainer, float> propertyList = container.FloatList; propertyList.Add(1); propertyList.Add(2); propertyList.Add(3); IEnumerator e = propertyList.GetEnumerator(); Assert.AreEqual(default(float), e.Current); }
void Awake() { Instance = this; IsRunning = false; IsLoading = true; IsDead = false; Properties = new PropertyList(); secTimer = InitTimer(); adManager = new AdManager(); Properties.Add("distance", 0.0f); Properties.Add("multiplier", 0.0f).WithCustomFormater(new MultiplierFormater()); Properties.Add("score", 0); Properties.Add("coins", 0); Properties.Add("chests", 0); Properties.Add("eggs", 0); Properties.Add("debug", 0); Properties.Add("heart", 0); Properties.Add("restartCount", 0); PlayerPrefs.SetInt("currentScene", 0); PlayerPrefs.SetInt("chests", 0); var highscore = 0; if (PlayerPrefs.HasKey("highscore")) { highscore = PlayerPrefs.GetInt("highscore"); } Properties.Add("highscore", highscore); uiPanels = GameObject.FindWithTag("UI"); if (GameRestarted()) { OnLoadingEnd(); } else { initAdsEngine(); } // Add default look into collection if (PlayerPrefs.GetString("availableLooks") == "") { PlayerPrefs.SetString("availableLooks", "0"); } }
///<summary> /// Initializes a new instance of <see cref="SelectDatabaseStep"/>. ///</summary> ///<param name="serviceProvider">The service provider to use for service location.</param> ///<param name="sourceModel">The <see cref="ConfigurationSourceModel"/> to update on <see cref="WizardStep.Execute"/></param> ///<param name="validatorFactory">The factory creating new <see cref="Validator"/> instances.</param> ///<param name="elementLookup">The service for locating registered elements.</param> public SelectDatabaseStep(IServiceProvider serviceProvider, ConfigurationSourceModel sourceModel, IResolver <Validator> validatorFactory, ElementLookup elementLookup ) : base(serviceProvider, validatorFactory, elementLookup) { this.sourceModel = sourceModel; var name = AddReflectedProperty(wizardData, propertyName); PropertyList.Add(new AssociatedWizardProperty(serviceProvider, wizardData, TypeDescriptor.GetProperties(wizardData)[propertyConnectionString], validatorFactory, elementLookup, name)); PropertyList.Add(new AssociatedWizardProperty(serviceProvider, wizardData, TypeDescriptor.GetProperties(wizardData)[propertyProviderName], validatorFactory, elementLookup, name)); SetDefaultDatabase(elementLookup); }
private static CategoriesDictionary GetSortedProperties(PropertyList list) { CategoriesDictionary sortedProperies = new CategoriesDictionary(); Dictionary <string, List <string> > Categories = GetCategoriesAndGroups(list); foreach (var category in Categories) { GroupsDictionary groups = new GroupsDictionary(); foreach (var group in category.Value) { PropertyList propertyList = new PropertyList(); foreach (var property in list) { if (property.Attributes.Count != 0 && (property.Attributes.First(a => a.Key == "CategoryAttribute").Value.ToString() == category.Key && property.Attributes.First(a => a.Key == "GroupName").Value.ToString() == group)) { propertyList.Add(property); } } groups.Add(group, propertyList); } sortedProperies.Add(category.Key, groups); } return(sortedProperies); }
public void Add(PartAST part) { if (part == null) { return; } if (part is ImportPackageAST) { ImportPackage = (part as ImportPackageAST); } else if (part is PropertyAST) { PropertyList.Add(part as PropertyAST); } else if (part is MethodAST) { MethodList.Add(part as MethodAST); } else if (part is AgreementAST) { AgreementList.Add(part as AgreementAST); } else if (part is SimpleUseAST) { SimpleUse = (part as SimpleUseAST); } else { throw new CompileException("错误不能识别PartAST"); } }
public virtual PropertyList LoadProperties(string path) { var xml = XElement.Parse(fileSystem.ReadAllText(path)); var result = new PropertyList(); var propertyNodes = xml.Descendants(ScopedName("PropertyGroup")).Descendants(); foreach (var node in propertyNodes) result.Add(node.Name.LocalName, node.Value); return result; }
public void RemoveItemByIndexFromDictionary() { var data = new PropertyList(); data.Add("XXX", "here!"); Assert.AreEqual("here!", data["XXX"].StringValue); Assert.AreEqual(1, data.Count); data.RemoveAt(0); Assert.AreEqual(0, data.Count); Assert.IsFalse(data.Contains("XXX")); }
public void RemoveItemByKeyFromDictionary() { var data = new PropertyList(); data.Add("A", 1); Assert.AreEqual(1, data.Count); data.Remove("A"); Assert.AreEqual(0, data.Count); Assert.AreEqual(-1, data["A", -1].Int32Value); }
internal ReadonlyPropertyCollection(IDictionary <string, string> dictionary) { _properties = new PropertyList(); foreach (var pair in dictionary) { _properties.Add(new Property() { Key = pair.Key, Value = pair.Value }); } }
public void DefineProperty(KProperty property) { if (PropertyList != null) { PropertyList.Add(property); } else { PropertyList = new List <KProperty> { property } }; }
/// <summary> /// Creates a <see cref="WizardProperty"/> based on a data structure. /// </summary> /// <param name="wizardData">The attributed structure to use for storing wizard data. See <see cref="WizardProperty"/>.</param> /// <param name="propertyName">The name of the property that must be on <paramref name="wizardData"/></param> /// <returns>An initialized wizard property based on <paramref name="wizardData"/>.</returns> protected WizardProperty AddReflectedProperty(object wizardData, string propertyName) { var property = new WizardProperty(serviceProvider, wizardData, TypeDescriptor.GetProperties(wizardData)[propertyName], validatorFactory, elementLookup ); PropertyList.Add(property); return(property); }
public void AddRange_ToNonEmptyList() { var list = new List <float> { 1, 2, 3 }; var container = new TestContainer(); PropertyList <TestContainer, float> propertyList = container.FloatList; propertyList.Add(4); propertyList.Add(5); propertyList.Add(6); list.AddRange(propertyList); Assert.AreEqual(6, list.Count); // The elements should have been added correctly to the end of the list Assert.AreEqual(4, list[3]); Assert.AreEqual(5, list[4]); Assert.AreEqual(6, list[5]); }
public void DefineProperties(IEnumerable <KProperty> properties) { if (PropertyList != null) { foreach (var property in properties) { PropertyList.Add(property); } } else { PropertyList = properties.ToList(); } }
public Canale(string name,Nodo father, string[] fields, List<string> map) { this.father = father; protocolname = map[0]; propertyDefinitions = ComDefinitions.Map[map[0]]; propertyValues = new PropertyList(); this.name = name; foreach (var pt in propertyDefinitions) { if (!pt.Value.Visibile) continue; int i = map.FindIndex(x => x == pt.Key); if (pt.Key == "Abilitato") { if (!Boolean.TryParse(fields[i - 1], out abilitazione)) abilitazione = false; } if (i > 0) { propertyValues.Add(pt.Key, (fields[i - 1]).Replace("%sc%",";"), pt.Value); } else propertyValues.Add(pt.Key, "", pt.Value); } }
/// <summary> /// Remove a property from the collection /// </summary> /// <param name="key">Key of the property to remove</param> public void Remove(string key) { PropertyList foundIndices = new PropertyList(); for (var i = 0; i < _properties.Count; i++) { var pair = _properties[i]; if (pair.Key == key) { foundIndices.Add(pair); } } foundIndices.ForEach(pair => _properties.Remove(pair)); }
public void AddBinaryData() { var propertyList = new PropertyList(); byte[] data = new byte[] { 20, 25, 35, 45, 60, 1, 0, 99 }; propertyList.Add("new_element", data); var text = propertyList.ToString(); Assert.IsNotNull(text); var loadedList = PropertyList.Read(text); var loadedData = loadedList["new_element"].BinaryValue; Assert.AreEqual(loadedData.Length, data.Length); for (int i = 0; i < data.Length; i++) { Assert.AreEqual(data[i], loadedData[i]); } }
/// <summary> /// Adds an object to the insert list /// </summary> public void Insert(T instance) { int prefix = m_Assigner.AssignPrefix(); lock (m_SQLMetas) { lock (m_CommandBuilder) { m_CommandBuilder.Append($"{(m_FirstInsert ? "" : ",")}\n({string.Join(", ", m_SQLMetas.CastEnumeration(x => $"@{prefix}_{x.Index}"))})"); } m_FirstInsert = false; lock (m_BuildProperties) { foreach (var meta in m_SQLMetas) { m_BuildProperties.Add($"@{prefix}_{meta.Index}", meta.Field.GetValue(instance)); } } } }
private void ReadFile() { if (File.Exists(FileName)) { CFCollection = new PropertyList <ConfigProperty>(); using (StreamReader sr = new StreamReader(FileName, Encoding.Default)) { while (!sr.EndOfStream) { String line = sr.ReadLine(); if (!line.StartsWith("#")) { ConfigProperty cf = new ConfigProperty(); String tmp = ""; Char splitter = '='; for (int i = 0; i < line.Length; i++) { if (line[i] != splitter) { tmp += ((Char)line[i]).ToString(); } else { cf.Name = tmp; tmp = ""; splitter = '\n'; } } cf.Value = tmp; if (cf.Name.Length > 0) { CFCollection.Add(cf); } } } sr.Close(); } } }
private static PropertyList GetAllProperties(object entity) { PropertyList list = new PropertyList(); foreach (var property in entity.GetType().GetProperties()) { var propertyClass = new PropertyClass() { Name = property.Name, Value = property.GetValue(entity) }; IList <CustomAttributeData> customAttributesData = property.GetCustomAttributesData(); Dictionary <string, object> Attributes = new Dictionary <string, object>(); if (customAttributesData != null) { foreach (var attributeGroups in customAttributesData) { foreach (var atribute in attributeGroups.NamedArguments) { Attributes.Add(atribute.MemberName, atribute.TypedValue); } foreach (var atribute in attributeGroups.ConstructorArguments) { Attributes.Add(attributeGroups.AttributeType.Name, atribute.Value); } } } propertyClass.Attributes = Attributes; if (propertyClass.Attributes.Count != 0 && propertyClass.Attributes.First(a => a.Key == "BrowsableAttribute").Value.Equals(true)) { list.Add(propertyClass); } } return(list); }
public void ClearItems() { var data = new PropertyList(); data.Add("A", 1); data.Add("B", 2); data.Add("C", 3); data.Add("D", 4); data.Add("E", 5); data.Add("F", 6); Assert.AreEqual(6, data.Count); data.Clear(); Assert.AreEqual(0, data.Count); Assert.IsFalse(data.Contains("A")); Assert.IsFalse(data.Contains("B")); Assert.IsFalse(data.Contains("C")); Assert.IsFalse(data.Contains("D")); Assert.IsFalse(data.Contains("E")); Assert.IsFalse(data.Contains("F")); }
void Awake() { Instance = this; IsRunning = false; IsLoading = true; IsDead = false; Properties = new PropertyList(); secTimer = InitTimer(); adManager = new AdManager(); Properties.Add("distance", 0.0f); Properties.Add("multiplier", 0.0f).WithCustomFormater(new MultiplierFormater()); Properties.Add("score", 0); Properties.Add("coins", 0); Properties.Add("chests", 0); Properties.Add("eggs", 0); Properties.Add("debug", 0); Properties.Add("heart", 0); PlayerPrefs.SetInt("currentScene", 0); PlayerPrefs.SetInt("chests", 0); if (PlayerPrefs.GetInt("heart") <= 0) { PlayerPrefs.SetInt("heart", 0); } var highscore = 0; if (PlayerPrefs.HasKey("highscore")) { highscore = PlayerPrefs.GetInt("highscore"); } Properties.Add("highscore", highscore); uiPanels = GameObject.FindWithTag("UI"); if (GameRestarted()) { OnLoadingEnd(); } else { InitAdsEngine(); } // Add default look and level into collection // 0 - default look, 100 - default lvl if (PlayerPrefs.GetString("availableItems") == "") { PlayerPrefs.SetString("availableItems", "0;100"); } // set default level if (!PlayerPrefs.HasKey("currentLevel")) { PlayerPrefs.SetInt("currentLevel", 100); } // uncomment to reset all props //PlayerPrefs.DeleteAll(); //PlayerPrefs.SetInt("coins", 50000); }
/// <summary> /// 添加 Property 元素 /// </summary> /// <param name="Name">需要定义的属性</param> /// <param name="Value">属性的值</param> public void AddProperty(string Name, string Value) { Property property = new Property(Name, Value); PropertyList.Add(property); }