packages/System.Linq.Dynamic.Core.1.0.7.13/src/System.Linq.Dynamic.Core/DynamicClass.cs
(开头部分) 14KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
#if UAP10_0
using System.Dynamic;
namespace System.Linq.Dynamic.Core
{
/// <summary>
/// Provides a base class for dynamic objects for UAP10_0.
/// </summary>
public class DynamicClass : DynamicObject
{
readonly Dictionary<string, object> _properties = new Dictionary<string, object>();
/// <summary>
/// Initializes a new instance of the <see cref="DynamicClass"/> class.
/// </summary>
/// <param name="propertylist">The propertylist.</param>
public DynamicClass(params KeyValuePair<string, object>[] propertylist)
{
foreach (var kvp in propertylist)
{
_properties.Add(kvp.Key, kvp.Value);
}
}
/// <summary>
/// Gets or sets the <see cref="object"/> with the specified name.
/// </summary>
/// <value>
/// The <see cref="object"/>.
/// </value>
/// <param name="name">The name.</param>
/// <returns>Value from the property.</returns>
public object this[string name]
{
get
{
object result;
if (_properties.TryGetValue(name, out result))
return result;
return null;
}
set
{
if (_properties.ContainsKey(name))
_properties[name] = value;
else
_properties.Add(name, value);
}
}
/// <summary>
/// Returns the enumeration of all dynamic member names.
/// </summary>
/// <returns>
/// A sequence that contains dynamic member names.
后面还有 268 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
