예제 #1
0
 /// <summary>
 /// Copies the property.
 /// </summary>
 /// <param name="prop">The property.</param>
 public void CopyProperty(IMapProperty prop)
 {
     if (prop is null)
     {
         return;
     }
     MapProperties.Add(prop.Convert <TClassType>(this));
 }
예제 #2
0
        void ParsePropertyElement()
        {
            if (currentParentElement == CCTileMapProperty.None)
            {
                CCLog.Log("CCTileMapInfo: ParsePropertyElement: Parent element is unsupported. Cannot add property named '{0}' with value '{1}'",
                          currentAttributeDict[PropertyElementName], currentAttributeDict[PropertyElementValue]);
            }
            else if (currentParentElement == CCTileMapProperty.Map)
            {
                // The parent element is the map
                string value = currentAttributeDict[PropertyElementValue];
                string key   = currentAttributeDict[PropertyElementName];
                MapProperties.Add(key, value);
            }
            else if (currentParentElement == CCTileMapProperty.Layer)
            {
                int             layersCount = Layers != null ? Layers.Count : 0;
                CCTileLayerInfo layer       = layersCount > 0 ? Layers[layersCount - 1] : null;

                string value = currentAttributeDict[PropertyElementValue];
                string key   = currentAttributeDict[PropertyElementName];
                // Add the property to the layer
                layer.Properties.Add(key, value);
            }
            else if (currentParentElement == CCTileMapProperty.ObjectGroup)
            {
                int objGroupsCount = ObjectGroups != null ? ObjectGroups.Count : 0;
                CCTileMapObjectGroup objectGroup = objGroupsCount > 0 ? ObjectGroups[objGroupsCount - 1] : null;
                string value = currentAttributeDict[PropertyElementValue];
                string key   = currentAttributeDict[PropertyElementName];
                objectGroup.Properties.Add(key, value);
            }
            else if (currentParentElement == CCTileMapProperty.Object)
            {
                // The parent element is the last object
                int objGroupsCount = ObjectGroups != null ? ObjectGroups.Count : 0;
                CCTileMapObjectGroup objectGroup = objGroupsCount > 0 ? ObjectGroups[objGroupsCount - 1] : null;

                List <Dictionary <string, string> > objects = objectGroup.Objects;
                int objCount = objects != null ? objects.Count : 0;
                Dictionary <string, string> dict = objCount > 0 ? objects[objCount - 1] : null;

                string propertyName  = currentAttributeDict[PropertyElementName];
                string propertyValue = currentAttributeDict[PropertyElementValue];
                dict.Add(propertyName, propertyValue);
            }
            else if (currentParentElement == CCTileMapProperty.Tile)
            {
                Dictionary <string, string> dict = TileProperties[ParentGID];

                string propertyName  = currentAttributeDict[PropertyElementName];
                string propertyValue = currentAttributeDict[PropertyElementValue];
                dict.Add(propertyName, propertyValue);
            }
        }
예제 #3
0
        /// <summary>
        /// Sets a property as a map type.
        /// </summary>
        /// <typeparam name="TDataType">The type of the data type.</typeparam>
        /// <param name="expression">Expression pointing to the property</param>
        /// <returns>The map object</returns>
        /// <exception cref="ArgumentNullException">expression</exception>
        public Map <TClassType, TDataType> Map <TDataType>(System.Linq.Expressions.Expression <Func <TClassType, TDataType> > expression)
            where TDataType : class
        {
            if (expression is null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            var ReturnValue = new Map <TClassType, TDataType>(expression, this);

            MapProperties.Add(ReturnValue);
            return(ReturnValue);
        }