private void OnSetKeyValue(ExtendedPropertyInfo extendedProperty, object extendee, object value)
 {
     if (extendee != null && value != null && !this.keylookupDictionary.Contains(value))
     {
         this.keylookupDictionary.Add(value, extendee);
     }
 }
        private object OnGetKeyValue(ExtendedPropertyInfo extendedProperty, object extendee)
        {
            DictionaryEntry?entry = null;

            if (extendedProperty.SerializationManager.WorkflowMarkupStack[typeof(DictionaryEntry)] != null)
            {
                entry = (DictionaryEntry)extendedProperty.SerializationManager.WorkflowMarkupStack[typeof(DictionaryEntry)];
            }
            else
            {
                Debug.Assert(false, "Dictionary Entry not found in the WorkflowMarkupStack");
            }

            if (entry.HasValue && entry.Value.Value == extendee)
            {
                return(entry.Value.Key);
            }
            return(null);
        }
Exemplo n.º 3
0
        internal static bool IsExtendedProperty(WorkflowMarkupSerializationManager manager, IList <PropertyInfo> propInfos, XmlQualifiedName xmlQualifiedName)
        {
            foreach (PropertyInfo propInfo in propInfos)
            {
                ExtendedPropertyInfo extendedProperty = propInfo as ExtendedPropertyInfo;
                if (extendedProperty == null)
                {
                    continue;
                }

                string           prefix = String.Empty;
                XmlQualifiedName qualifiedPropertyName = extendedProperty.GetXmlQualifiedName(manager, out prefix);
                if (qualifiedPropertyName.Name.Equals(xmlQualifiedName.Name, StringComparison.Ordinal) &&
                    qualifiedPropertyName.Namespace.Equals(xmlQualifiedName.Namespace, StringComparison.Ordinal))
                {
                    return(true);
                }
            }

            return(false);
        }
        internal override ExtendedPropertyInfo[] GetExtendedProperties(WorkflowMarkupSerializationManager manager, object extendee)
        {
            List <ExtendedPropertyInfo> extendedProperties = new List <ExtendedPropertyInfo>();
            DictionaryEntry?            entry = null;

            if (manager.WorkflowMarkupStack[typeof(DictionaryEntry)] != null)
            {
                entry = (DictionaryEntry)manager.WorkflowMarkupStack[typeof(DictionaryEntry)];
            }
            if (this.deserializingDictionary || (entry.HasValue && entry.Value.Value == extendee))
            {
                ExtendedPropertyInfo extendedProperty =
                    new ExtendedPropertyInfo(typeof(DictionaryEntry).GetProperty("Key", BindingFlags.Public | BindingFlags.Instance),
                                             new GetValueHandler(OnGetKeyValue),
                                             new SetValueHandler(OnSetKeyValue),
                                             new GetQualifiedNameHandler(OnGetXmlQualifiedName), manager);

                extendedProperties.Add(extendedProperty);
            }
            return(extendedProperties.ToArray());
        }
 private XmlQualifiedName OnGetXmlQualifiedName(ExtendedPropertyInfo extendedProperty, WorkflowMarkupSerializationManager manager, out string prefix)
 {
     prefix = StandardXomlKeys.Definitions_XmlNs_Prefix;
     return(new XmlQualifiedName(extendedProperty.Name, StandardXomlKeys.Definitions_XmlNs));
 }