本文整理汇总了C#中IDictionaryAdapter类的典型用法代码示例。如果您正苦于以下问题:C# IDictionaryAdapter类的具体用法?C# IDictionaryAdapter怎么用?C# IDictionaryAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDictionaryAdapter类属于命名空间,在下文中一共展示了IDictionaryAdapter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetValue
public override void SetValue(IXmlNode node, IDictionaryAdapter parent, IXmlAccessor accessor, object oldValue, ref object value)
{
var newNode = (XmlNode) value;
using (var writer = new XmlSubtreeWriter(node))
newNode.WriteTo(writer);
}
开发者ID:leloulight,项目名称:Core,代码行数:7,代码来源:XmlXmlNodeSerializer.cs
示例2: InvalidOperationException
void IDictionaryInitializer.Initialize(IDictionaryAdapter dictionaryAdapter, object[] behaviors)
{
var meta = dictionaryAdapter.Meta;
if (meta.MetaInitializers.OfType<XPathBehavior>().FirstOrDefault() == null)
{
throw new InvalidOperationException(string.Format(
"Interface {0} requested xpath support, but was not configured properly. " +
"Did you forget to add an XPathBehavior?", meta.Type.FullName));
}
var xmlMeta = dictionaryAdapter.GetXmlMeta();
if (dictionaryAdapter.This.CreateStrategy == null)
{
dictionaryAdapter.This.CreateStrategy = this;
dictionaryAdapter.This.AddCopyStrategy(this);
}
if (rootXmlMeta == null)
{
rootXmlMeta = xmlMeta;
Context.ApplyBehaviors(rootXmlMeta, behaviors);
if (Parent == null)
{
foreach (var behavior in behaviors)
{
if (behavior is XPathAttribute)
{
var attrib = (XPathAttribute)behavior;
var compiledExpression = attrib.CompiledExpression;
if (MoveOffRoot(root, XPathNodeType.Element) == false || Context.Matches(compiledExpression, root))
{
break;
}
var navigator = Context.SelectSingleNode(compiledExpression, root);
if (navigator != null)
{
root = navigator;
break;
}
}
}
MoveOffRoot(root, XPathNodeType.Element);
}
}
else
{
if (overlays == null)
overlays = new Dictionary<Type, XPathContext>();
XPathContext overlay;
if (overlays.TryGetValue(meta.Type, out overlay) == false)
{
overlay = new XPathContext().ApplyBehaviors(xmlMeta, behaviors);
overlays.Add(meta.Type, overlay);
}
}
}
开发者ID:Jarvin-Guan,项目名称:CleanAOP,代码行数:60,代码来源:XPathAdapter.cs
示例3: SetValue
public override void SetValue(IXmlNode node, IDictionaryAdapter parent, IXmlAccessor accessor, ref object value)
{
var source = (Array) value;
var target = (Array) null;
var itemType = source.GetType().GetElementType();
var subaccessor = accessor.GetCollectionAccessor(itemType);
var cursor = subaccessor.SelectCollectionItems(node, true);
var serializer = subaccessor.Serializer;
var references = XmlAdapter.For(parent).References;
for (var i = 0; i < source.Length; i++)
{
var originalItem = source.GetValue(i);
var assignedItem = originalItem;
subaccessor.SetValue(cursor, parent, references, cursor.MoveNext(), null /* TODO: Get Value */, ref assignedItem);
if (target != null)
{
target.SetValue(assignedItem, i);
}
else if (!Equals(assignedItem, originalItem))
{
target = Array.CreateInstance(itemType, source.Length);
Array.Copy(source, target, i);
target.SetValue(assignedItem, i);
}
}
cursor.RemoveAllNext();
if (target != null)
value = target;
}
开发者ID:radiy,项目名称:Core,代码行数:34,代码来源:XmlArraySerializer.cs
示例4: GetValue
public override object GetValue(IXmlNode node, IDictionaryAdapter parent, IXmlAccessor accessor)
{
using (var reader = new XmlSubtreeReader(node, Root))
return serializer.CanDeserialize(reader)
? serializer.Deserialize(reader)
: null;
}
开发者ID:elevine,项目名称:Core,代码行数:7,代码来源:XmlDefaultSerializer.cs
示例5: CopyTo
public void CopyTo(IDictionaryAdapter other, Func<PropertyDescriptor, bool> selector)
{
if (ReferenceEquals(this, other))
{
return;
}
if (other.Meta.Type.IsAssignableFrom(Meta.Type) == false)
{
throw new ArgumentException(string.Format(
"Unable to copy to {0}. The type must be assignable from {1}.",
other.Meta.Type.FullName, Meta.Type.FullName));
}
if (This.CopyStrategies.Aggregate(false, (copied, s) => copied | s.Copy(this, other, ref selector)))
{
return;
}
selector = selector ?? (property => true);
foreach (var property in This.Properties.Values.Where(property => selector(property)))
{
var propertyValue = GetProperty(property.PropertyName, true);
other.SetProperty(property.PropertyName, ref propertyValue);
}
}
开发者ID:jeremymeng,项目名称:Core,代码行数:27,代码来源:DictionaryAdapterBase.Copy.cs
示例6: GetValueCore
private object GetValueCore(IXmlNode node, IDictionaryAdapter parent, IXmlAccessor accessor)
{
var itemType = node.ClrType.GetGenericArguments()[0];
var listType = ListTypeConstructor.MakeGenericType(itemType);
var subaccessor = accessor.GetCollectionAccessor(itemType);
return Activator.CreateInstance(listType, node, parent, subaccessor);
}
开发者ID:leloulight,项目名称:Core,代码行数:7,代码来源:XmlCollectionSerializer.cs
示例7: SetValue
public override void SetValue(IXmlNode node, IDictionaryAdapter parent, IXmlAccessor accessor, object oldValue, ref object value)
{
if (node.ClrType != typeof(object))
XmlTypeSerializer.For(node.ClrType).SetValue(node, parent, accessor, oldValue, ref value);
else
node.Clear();
}
开发者ID:leloulight,项目名称:Core,代码行数:7,代码来源:XmlDynamicSerializer.cs
示例8: GetValue
public override object GetValue(IXmlNode node, IDictionaryAdapter parent, IXmlAccessor accessor)
{
var source = node.AsRealizable<XmlNode>();
return (source != null && source.IsReal)
? source.Value
: null;
}
开发者ID:leloulight,项目名称:Core,代码行数:8,代码来源:XmlXmlNodeSerializer.cs
示例9: GetPropertyAsString
bool IDictionaryPropertySetter.SetPropertyValue(IDictionaryAdapter dictionaryAdapter,
string key, ref object value, PropertyDescriptor property)
{
if (value != null)
{
value = GetPropertyAsString(property, value);
}
return true;
}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:9,代码来源:StringValuesAttribute.cs
示例10: GetPropertyValue
public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key, object storedValue, PropertyDescriptor property, bool ifExists)
{
if (storedValue != null)
{
return storedValue;
}
throw new InvalidOperationException(string.Format("App setting '{0}' not found!", key));
}
开发者ID:jhonner72,项目名称:plat,代码行数:9,代码来源:AppSettingWrapperAttribute.cs
示例11: Hashtable
object IDictionaryCreateStrategy.Create(IDictionaryAdapter adapter, Type type, IDictionary dictionary)
{
dictionary = dictionary ??
#if SILVERLIGHT
new Dictionary<object, object>();
#else
new Hashtable();
#endif
return adapter.This.Factory.GetAdapter(type, dictionary, adapter.This.Descriptor); ;
}
开发者ID:leloulight,项目名称:Core,代码行数:10,代码来源:CreateHashtableDictionaryStrategy.cs
示例12: Equals
public bool Equals(IDictionaryAdapter adapter1, IDictionaryAdapter adapter2)
{
var id1 = adapter1.GetProperty("Id", false);
if (id1 == null) return false;
var id2 = adapter2.GetProperty("Id", false);
if (id2 == null) return false;
return id1.Equals(id2);
}
开发者ID:leloulight,项目名称:Core,代码行数:10,代码来源:IdEqualityHashCodeStrategy.cs
示例13: GetDictionaryMeta
private static DictionaryAdapterMeta GetDictionaryMeta(IDictionaryAdapter dictionaryAdapter, Type otherType)
{
var meta = dictionaryAdapter.Meta;
if (otherType != null && otherType != meta.Type)
{
meta = dictionaryAdapter.This.Factory.GetAdapterMeta(otherType,
new DictionaryDescriptor().AddBehavior(XPathBehavior.Instance));
}
return meta;
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:10,代码来源:XPathExtensions.cs
示例14: ApplyValidationRules
private void ApplyValidationRules(IDictionaryAdapter dictionaryAdapter, IEnumerable<IValidationRule> rules,
PropertyDescriptor property, object propertyValue, IList<String> errors)
{
if (rules != null)
{
foreach (var rule in rules)
{
rule.Apply(dictionaryAdapter, property, propertyValue, errors);
}
}
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:11,代码来源:TestDictionaryValidator.cs
示例15: GetPropertyValue
public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter,
string key, object storedValue, PropertyDescriptor property, bool ifExists)
{
if (storedValue == null || storedValue.Equals(UnassignedGuid))
{
storedValue = Guid.NewGuid();
property.SetPropertyValue(dictionaryAdapter, key, ref storedValue, dictionaryAdapter.This.Descriptor);
}
return storedValue;
}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:11,代码来源:NewGuidAttribute.cs
示例16: GetDictionaryMeta
private static DictionaryAdapterMeta GetDictionaryMeta(IDictionaryAdapter dictionaryAdapter, Type otherType)
{
var meta = dictionaryAdapter.Meta;
if (otherType != null && otherType != meta.Type)
{
var descriptor = new DictionaryDescriptor();
dictionaryAdapter.This.Descriptor.CopyBehaviors(descriptor);
meta = dictionaryAdapter.This.Factory.GetAdapterMeta(otherType, descriptor);
}
return meta;
}
开发者ID:Jarvin-Guan,项目名称:CleanAOP,代码行数:11,代码来源:XPathExtensions.cs
示例17: GetHashCode
public bool GetHashCode(IDictionaryAdapter adapter, out int hashCode)
{
var id = adapter.GetProperty("Id", false);
if (id != null)
{
hashCode = id.GetHashCode();
return true;
}
hashCode = 0;
return false;
}
开发者ID:leloulight,项目名称:Core,代码行数:11,代码来源:IdEqualityHashCodeStrategy.cs
示例18: GetValue
public override object GetValue(IXmlNode node, IDictionaryAdapter parent, IXmlAccessor accessor)
{
var items = new ArrayList();
var itemType = node.ClrType.GetElementType();
var references = XmlAdapter.For(parent).References;
accessor
.GetCollectionAccessor(itemType)
.GetCollectionItems(node, parent, references, items);
return items.ToArray(itemType);
}
开发者ID:elevine,项目名称:Core,代码行数:12,代码来源:XmlArraySerializer.cs
示例19: Validate
public string Validate(IDictionaryAdapter dictionaryAdapter, PropertyDescriptor property)
{
List<String> errors = new List<string>();
var globalRules = AttributesUtil.GetTypeAttributes<IValidationRule>(dictionaryAdapter.Meta.Type);
var propertyRules = AttributesUtil.GetAttributes<IValidationRule>(property.Property);
var propertyValue = dictionaryAdapter.GetProperty(property.PropertyName, true);
ApplyValidationRules(dictionaryAdapter, propertyRules, property, propertyValue, errors);
ApplyValidationRules(dictionaryAdapter, globalRules, property, propertyValue, errors);
return String.Join(Environment.NewLine, errors.ToArray());
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:12,代码来源:TestDictionaryValidator.cs
示例20: SetValue
public override void SetValue(IXmlNode node, IDictionaryAdapter parent, IXmlAccessor accessor, object oldValue, ref object value)
{
var serializable = (IXmlSerializable) value;
var root = XmlDefaultSerializer.Root;
using (var writer = new XmlSubtreeWriter(node))
{
// Pre-write containing element
writer.WriteStartElement(string.Empty, root.ElementName, root.Namespace);
serializable.WriteXml(writer);
writer.WriteEndElement();
}
}
开发者ID:elevine,项目名称:Core,代码行数:13,代码来源:XmlCustomSerializer.cs
注:本文中的IDictionaryAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论