当前位置: 首页>>代码示例>>C#>>正文


C# Properties.Add方法代码示例

本文整理汇总了C#中Properties.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Properties.Add方法的具体用法?C# Properties.Add怎么用?C# Properties.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Properties的用法示例。


在下文中一共展示了Properties.Add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			var dict = value as IDictionary<PropertyName, IProperty>;
			if (dict == null) return;
			var settings = serializer.GetConnectionSettings();
			var props = new Properties();
			foreach (var kv in dict)
			{
				var v = kv.Value as IPropertyWithClrOrigin;
				if (v?.ClrOrigin == null)
				{
					props.Add(kv.Key, kv.Value);
					continue;
				}
				//We do not have to take .Name into account from serializer PropertyName (kv.Key) already handles this
				var serializerMapping = settings.Serializer?.CreatePropertyMapping(v.ClrOrigin);
				if (serializerMapping == null || !serializerMapping.Ignore) 
					props.Add(kv.Key, kv.Value);
			}
			_dictionaryConverter.WriteJson(writer, props, serializer);
		}
开发者ID:jeroenheijmans,项目名称:elasticsearch-net,代码行数:21,代码来源:PropertiesJsonConverter.cs

示例2: StructureObjectArray

        public StructureObjectArray(PsdReader reader)
        {
            int version = reader.ReadInt32();
            this.Add("Name", reader.ReadString());
            this.Add("ClassID", reader.ReadKey());

            int count = reader.ReadInt32();

            List<Properties> items = new List<Properties>();

            for (int i = 0; i < count; i++)
            {
                Properties props = new Properties();
                props.Add("Type1", reader.ReadKey());
                props.Add("EnumName", reader.ReadType());

                props.Add("Type2", PsdUtility.ToUnitType(reader.ReadType()));
                int d4 = reader.ReadInt32();
                props.Add("Values", reader.ReadDoubles(d4));

                items.Add(props);
            }
            this.Add("items", items.ToArray());
        }
开发者ID:NtreevSoft,项目名称:psd-parser,代码行数:24,代码来源:StructureObjectArray.cs

示例3: GetProperties

		public IProperties GetProperties(ConcurrentDictionary<Type, int> seenTypes = null, int maxRecursion = 0)
		{
			var properties = new Properties();

			int seen;
			if (seenTypes != null && seenTypes.TryGetValue(_type, out seen) && seen > maxRecursion)
				return properties;

			foreach (var propertyInfo in _type.GetProperties())
			{
				var attribute = ElasticsearchPropertyAttribute.From(propertyInfo);
				if (attribute != null && attribute.Ignore)
					continue;
				var property = GetProperty(propertyInfo, attribute);
				properties.Add(propertyInfo, property);
			}

			return properties;
		}
开发者ID:matteus6007,项目名称:elasticsearch-net,代码行数:19,代码来源:PropertyWalker.cs

示例4: ReadJson

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			var r = new Properties();
			JObject o = JObject.Load(reader);

			foreach (var p in o.Properties())
			{
				var name = p.Name;
				var po = p.First as JObject;
				if (po == null)
					continue;

				var mapping = _elasticTypeConverter.ReadJson(po.CreateReader(), objectType, existingValue, serializer)
				as IProperty;
				if (mapping == null)
					continue;
				mapping.Name = name;

				r.Add(name, mapping);

			}
			return r;
		}
开发者ID:jeroenheijmans,项目名称:elasticsearch-net,代码行数:23,代码来源:PropertiesJsonConverter.cs

示例5: ReadJson

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jToken = JToken.ReadFrom(reader);

            if (jToken.Type == JTokenType.Array)
            {
                return new Properties();
            }

            if (jToken.Type == JTokenType.Object)
            {
                var properties = new Properties();
                foreach (var property in ((JObject)jToken).Properties())
                {
                    if(property.Name == "headers")
                    {
                        if (property.Value.Type == JTokenType.Object)
                        {
                            var headers = (JObject) property.Value;
                            foreach (var header in headers.Properties())
                            {
                                properties.headers.Add(header.Name, header.Value.ToString());
                            }
                        }
                    }
                    else
                    {
                        properties.Add(property.Name, property.Value.ToString());
                    }
                }
                return properties;
            }

            throw new JsonException(
                string.Format("Expected array or object for properties, but was {0}", jToken.Type), null);
        }
开发者ID:vasily-kirichenko,项目名称:EasyNetQ,代码行数:36,代码来源:PropertyConverter.cs

示例6: MakeSegmentIOProperties

		private static Properties MakeSegmentIOProperties(Dictionary<string, string> properties)
		{
			var prop = new Properties();
			foreach (var key in properties.Keys)
			{
				prop.Add(key, properties[key]);
			}
			return prop;
			return prop;
		}
开发者ID:StephenMcConnel,项目名称:DesktopAnalytics.net,代码行数:10,代码来源:Analytics.cs

示例7: ReportException

		/// <summary>
		/// Sends the exception's message and stacktrace, plus additional information the
		/// program thinks may be relevant. Limitted to MAX_EXCEPTION_REPORTS_PER_RUN
		/// </summary>
		public static void ReportException(Exception e, Dictionary<string, string> moreProperties)
		{
			if (!AllowTracking)
				return;

			_exceptionCount++;

			// we had an incident where some problem caused a user to emit hundreds of thousands of exceptions,
			// in the background, blowing through our Analytics service limits and getting us kicked off.
			if (_exceptionCount > MAX_EXCEPTION_REPORTS_PER_RUN)
			{
				return;
			}

			var props = new Properties()
			{
				{ "Message", e.Message },
				{ "Stack Trace", e.StackTrace }
			};
			if (moreProperties != null)
			{
				foreach (var key in moreProperties.Keys)
				{
					props.Add(key, moreProperties[key]);
				}
			}
			TrackWithApplicationProperties("Exception", props);
		}
开发者ID:StephenMcConnel,项目名称:DesktopAnalytics.net,代码行数:32,代码来源:Analytics.cs

示例8: InitializeProperties

        /// <summary>
        /// Loads all properties from database into objects. If this method is re-called, it will re-query the database.
        /// </summary>
        /// <remarks>
        /// This optimizes sql calls. This will first check if all of the properties have been loaded. If not, 
        /// then it will query for all property types for the current version from the db. It will then iterate over each
        /// cmdPropertyData row and store the id and propertyTypeId in a list for lookup later. Once the records have been 
        /// read, we iterate over the cached property types for this ContentType and create a new property based on
        /// our stored list of proeprtyTypeIds. We then have a cached list of Property objects which will get returned
        /// on all subsequent calls and is also used to return a property with calls to getProperty.
        /// </remarks>
        private void InitializeProperties()
        {
            m_LoadedProperties = new Properties();

            if (this.ContentType == null)
                return;

            //Create anonymous typed list with 2 props, Id and PropertyTypeId of type Int.
            //This will still be an empty list since the props list is empty.
            var propData = m_LoadedProperties.Select(x => new { Id = 0, PropertyTypeId = 0 }).ToList();

            string sql = @"select id, propertyTypeId from cmsPropertyData where [email protected]";

            using (IRecordsReader dr = SqlHelper.ExecuteReader(sql,
                SqlHelper.CreateParameter("@versionId", Version)))
            {
                while (dr.Read())
                {
                    //add the item to our list
                    propData.Add(new { Id = dr.Get<int>("id"), PropertyTypeId = dr.Get<int>("propertyTypeId") });
                }
            }

            foreach (PropertyType pt in this.ContentType.PropertyTypes)
            {
                if (pt == null)
                    continue;

                //get the propertyId
                var property = propData
                    .Where(x => x.PropertyTypeId == pt.Id)
                    .SingleOrDefault();
                if (property == null)
                    continue;
                var propertyId = property.Id;

                Property p = null;
                try
                {
                    p = new Property(propertyId, pt);
                }
                catch
                {
                    continue; //this remains from old code... not sure why we would do this?
                }

                m_LoadedProperties.Add(p);
            }
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:60,代码来源:Content.cs

示例9: ReadProperties

 private void ReadProperties(PsdReader reader, int level, Properties props)
 {
     reader.Skip('\t', level);
     char c = reader.ReadChar();
     if (c == ']')
     {
         return;
     }
     else if (c == '<')
     {
         reader.Skip('<');
     }
     reader.Skip('\n');
     //Properties props = new Properties();
     while (true)
     {
         reader.Skip('\t', level);
         c = reader.ReadChar();
         if (c == '>')
         {
             reader.Skip('>');
             return;
         }
         else
         {
             //assert c == 9;
             c = reader.ReadChar();
             //assert c == '/' : "unknown char: " + c + " on level: " + level;
             string name = string.Empty;
             while (true)
             {
                 c = reader.ReadChar();
                 if (c == ' ' || c == 10)
                 {
                     break;
                 }
                 name += c;
             }
             if (c == 10)
             {
                 Properties p = new Properties();
                 this.ReadProperties(reader, level + 1, p);
                 if (p.Count > 0)
                     props.Add(name, p);
                 reader.Skip('\n');
             }
             else if (c == ' ')
             {
                 object value = this.ReadValue(reader, level + 1);
                 props.Add(name, value);
             }
             else
             {
                 //assert false;
             }
         }
     }
 }
开发者ID:NtreevSoft,项目名称:psd-parser,代码行数:58,代码来源:StructureEngineData.cs

示例10: ReadTileset

        static void ReadTileset(XmlNode node, ref Map map, string base_path)
        {
            TileSet r    = new TileSet();
            r.FirstGid   = node.ReadInt("firstgid");
            r.Source     = node.ReadTag("source");
            r.Name       = node.ReadTag("name");
            r.TileWidth  = node.ReadInt("tilewidth");
            r.TileHeight = node.ReadInt("tileheight");
            r.Spacing    = node.ReadInt("spacing");
            r.Margin     = node.ReadInt("margin");

            Console.Out.WriteLine (r.Source);

            if (r.Source != "") {

                String filename = Path.Combine (base_path, r.Source);

                Console.Out.WriteLine (r.Source);

                try {

                XmlDocument extTileset = new XmlDocument ();
                extTileset.Load (File.OpenRead (filename));
                foreach (XmlNode extNode in extTileset.ChildNodes) {

                    if (extNode.Name == "tileset")
                        node = extNode;
                }

                r.Name       = node.ReadTag("name");
                r.TileWidth  = node.ReadInt("tilewidth");
                r.TileHeight = node.ReadInt("tileheight");
                r.Spacing    = node.ReadInt("spacing");
                r.Margin     = node.ReadInt("margin");

                FileInfo fi = new FileInfo (filename);
                base_path = fi.DirectoryName;

                } catch (Exception e) {
                    Console.Out.WriteLine (e.Message);
                    return;
                }
            }

            if (node.HasChildNodes)
            {
                foreach (XmlNode child in node.ChildNodes)
                {

                    if (child.Name == "image") {
                        string c = child.ReadTag ("trans", "FFFFFF");
                        if (c.Length == 6 && !c.StartsWith ("#")) {
                            c = "#" + c;
                        }
                        Color t = ColorTranslator.FromHtml (c);

                        if (child.Attributes ["trans"] != null) {
                            r.Images.Add (new Image () {
                                Source = child.ReadTag ("source"),
                                TransColor = t,
                                UseTransColor = true
                            });
                        } else {
                            r.Images.Add (new Image () {
                                Source = child.ReadTag ("source"),
                                TransColor = t,
                                UseTransColor = false
                            });
                        }
                    } else if (child.Name == "tile") {
                        int id = child.ReadInt ("id");
                        Properties tileprops = new Properties();
                        XmlNode data = child.FirstChild; // Should be a properties tag.
                        foreach (XmlNode property in data.ChildNodes) {
                            tileprops.Add (property.ReadTag ("name"), property.ReadTag ("value"));
                        }
                        r.TileProperties.Add (id, tileprops);
                    }
                }
            }

            //r.ReadBitmaps(base_path);

            map.TileSets.Add(r);
        }
开发者ID:jgeumlek,项目名称:Element-Chronicles-Prototype,代码行数:85,代码来源:Map.cs

示例11: loadValue

        /// <summary>
        ///  Load value from <property>...</property> tag. Null returned if value cannot be determined.
        /// </summary>
        private Object loadValue(XmlNode e, String key, int type)
        {
            String text = XMLUtils.GetText(e);

            switch (type)
            {
                case PropertySet_Fields.BOOLEAN:
                    return TextUtils.ParseBoolean(text);

                case PropertySet_Fields.INT:
                    return TextUtils.ParseInt(text);

                case PropertySet_Fields.LONG:
                    return  TextUtils.ParseLong(text);

                case PropertySet_Fields.DOUBLE:
                    return TextUtils.ParseDouble(text);

                case PropertySet_Fields.STRING:
                case PropertySet_Fields.TEXT:
                    return text;

                case PropertySet_Fields.DATE:

                    try
                    {
                        return DateTime.Parse(text, new DateTimeFormatInfo());
                    }
                    catch (FormatException )
                    {
                        return null; // if the date cannot be parsed, ignore it.
                    }
                    //return null;
                case PropertySet_Fields.OBJECT:

                    try
                    {
                        return TextUtils.decodeObject(text);
                    }
                    catch (Exception )
                    {
                        return null; // if Object cannot be decoded, ignore it.
                    }

                case PropertySet_Fields.XML:

                    try
                    {
                        XmlDocument doc=new XmlDocument();
                            doc.LoadXml(text);
                        return doc;

                    }
                    catch (Exception )
                    {
                        return null; // if XML cannot be parsed, ignore it.
                    }

                case PropertySet_Fields.DATA:

                    try
                    {
                        return new Data(TextUtils.DecodeBytes(text));
                    }
                    catch (IOException )
                    {
                        return null; // if data cannot be decoded, ignore it.
                    }
                    //return null;

                case PropertySet_Fields.PROPERTIES:

                    try
                    {

                        Properties props = new Properties();
                        XmlNodeList pElements = e.SelectNodes( "properties/property");

                        foreach(XmlNode pElement in pElements)
                        {

                            props.Add(XMLUtils.GetAttribute(pElement,"key"), XMLUtils.GetElementText(pElement));
                        }

                        return props;
                    }
                    catch (Exception )
                    {
                        return null; // could not get nodes via x-path
                    }

                default:
                    return null;

            }
        }
开发者ID:BackupTheBerlios,项目名称:nwf,代码行数:99,代码来源:XMLPropertySet.cs

示例12: InitializeProperties

        /// <summary>
        /// Loads all properties from database into objects. If this method is re-called, it will re-query the database.
        /// </summary>
        /// <remarks>
        /// This optimizes sql calls. This will first check if all of the properties have been loaded. If not, 
        /// then it will query for all property types for the current version from the db. It will then iterate over each
        /// cmdPropertyData row and store the id and propertyTypeId in a list for lookup later. Once the records have been 
        /// read, we iterate over the cached property types for this ContentType and create a new property based on
        /// our stored list of proeprtyTypeIds. We then have a cached list of Property objects which will get returned
        /// on all subsequent calls and is also used to return a property with calls to getProperty.
        /// </remarks>
        private void InitializeProperties()
        {
            m_LoadedProperties = new Properties();

            if (ContentBase != null)
            {
                //NOTE: we will not load any properties where HasIdentity = false - this is because if properties are 
                // added to the property collection that aren't persisted we'll get ysods
                m_LoadedProperties.AddRange(ContentBase.Properties.Where(x => x.HasIdentity).Select(x => new Property(x)));
                return;
            }

            if (this.ContentType == null)
                return;

            //Create anonymous typed list with 2 props, Id and PropertyTypeId of type Int.
            //This will still be an empty list since the props list is empty.
            var propData = m_LoadedProperties.Select(x => new { Id = 0, PropertyTypeId = 0 }).ToList();

            string sql = @"select id, propertyTypeId from cmsPropertyData where [email protected]";

            using (IRecordsReader dr = SqlHelper.ExecuteReader(sql,
                SqlHelper.CreateParameter("@versionId", Version)))
            {
                while (dr.Read())
                {
                    //add the item to our list
                    propData.Add(new { Id = dr.Get<int>("id"), PropertyTypeId = dr.Get<int>("propertyTypeId") });
                }
            }

            foreach (PropertyType pt in this.ContentType.PropertyTypes)
            {
                if (pt == null)
                    continue;

                //get the propertyId
                var property = propData.LastOrDefault(x => x.PropertyTypeId == pt.Id);
                if (property == null)
                {
                    continue;
                    //var prop = Property.MakeNew(pt, this, Version);
                    //property = new {Id = prop.Id, PropertyTypeId = pt.Id};
                }
                var propertyId = property.Id;

                Property p = null;
                try
                {
                    p = new Property(propertyId, pt);
                }
                catch
                {
                    continue; //this remains from old code... not sure why we would do this?
                }

                m_LoadedProperties.Add(p);
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:70,代码来源:Content.cs

示例13: ReportException

		/// <summary>
		/// Sends the exception's message and stacktrace, plus additional information the
		/// program thinks may be relevant.
		/// </summary>
		public static void ReportException(Exception e, Dictionary<string, string> moreProperties)
		{
			if (!AllowTracking)
				return;

			var props = new Properties()
			{
				{ "Message", e.Message },
				{ "Stack Trace", e.StackTrace }
			};
			if (moreProperties != null)
			{
				foreach (var key in moreProperties.Keys)
				{
					props.Add(key, moreProperties[key]);
				}
			}
			TrackWithDefaultProperties("Exception", props);
		}
开发者ID:JohnThomson,项目名称:DesktopAnalytics.net,代码行数:23,代码来源:Analytics.cs


注:本文中的Properties.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。