internal static void ValidateRoles(Activity activity, string identity)
        {
            DependencyProperty dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType().BaseType);

            if (dependencyProperty == null)
            {
                dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType());
            }

            if (dependencyProperty == null)
            {
                return;
            }

            ActivityBind rolesBind = activity.GetBinding(dependencyProperty) as ActivityBind;

            if (rolesBind == null)
            {
                return;
            }

            WorkflowRoleCollection roles = rolesBind.GetRuntimeValue(activity) as WorkflowRoleCollection;

            if (roles == null)
            {
                return;
            }

            if (!roles.IncludesIdentity(identity))
            {
                throw new WorkflowAuthorizationException(activity.Name, identity);
            }
        }
Exemple #2
0
            private static DependencyProperty ParsePropertyFromString(string name)
            {
                var lastPoint = name.LastIndexOf(':');
                var ownerType = DependencyProperty.StringToOwnerType(name.Substring(0, lastPoint));

                return(DependencyProperty.FromName(name.Substring(lastPoint + 1), ownerType));
            }
        internal static bool IsBindableProperty(PropertyDescriptor propertyDescriptor)
        {
            //The property type itself is ActivityBind; we dont support such cases very well in componentmodel
            //but still we need to handle such cases as a fallback in ui
            if (propertyDescriptor.PropertyType == typeof(ActivityBind))
            {
                return(true);
            }

            //We check this condition so that we will make sure that ActivityBind UI infrastructure
            //kicks into action in cases of parameter properties. User might sometimes do this on their properties
            //but in such cases they need to write their custom property descriptors just as we have written
            //ParameterInfoBasedPropertyDescriptor
            if (propertyDescriptor.Converter is ActivityBindTypeConverter)
            {
                return(true);
            }

            //For all the other cases
            DependencyProperty dependencyProperty = DependencyProperty.FromName(propertyDescriptor.Name, propertyDescriptor.ComponentType);

            if (typeof(DependencyObject).IsAssignableFrom(propertyDescriptor.ComponentType) && dependencyProperty != null && !dependencyProperty.DefaultMetadata.IsMetaProperty)
            {
                return(true);
            }

            return(false);
        }
Exemple #4
0
        public static CustomProperty CreateCustomProperty(IServiceProvider serviceProvider, string customPropertyName, PropertyDescriptor propertyDescriptor, object propertyOwner)
        {
            CustomProperty newCustomProperty = new CustomProperty(serviceProvider);

            newCustomProperty.Name = customPropertyName;
            if (TypeProvider.IsAssignable(typeof(ActivityBind), propertyDescriptor.PropertyType))
            {
                Type baseType = PropertyDescriptorUtils.GetBaseType(propertyDescriptor, propertyOwner, serviceProvider);
                if (baseType == null)
                {
                    throw new InvalidOperationException(SR.GetString(SR.Error_CantDeterminePropertyBaseType, propertyDescriptor.Name));
                }
                newCustomProperty.Type = baseType.FullName;
            }
            else
            {
                newCustomProperty.Type = propertyDescriptor.PropertyType.FullName;
            }

            if (propertyDescriptor is ActivityBindPropertyDescriptor)
            {
                DependencyProperty dependencyProperty = DependencyProperty.FromName(propertyDescriptor.Name, propertyDescriptor.ComponentType);
                newCustomProperty.IsEvent = (dependencyProperty != null && dependencyProperty.IsEvent);
            }

            newCustomProperty.Category = propertyDescriptor.Category;
            return(newCustomProperty);
        }
		private void LoadSubStreams(UIElement element, ArrayList subStreams)
		{
			for (int i = 0; i < subStreams.Count; i++)
			{
				SubStream subStream = (SubStream)subStreams[i];
				DependencyProperty dependencyProperty = DependencyProperty.FromName(subStream._propertyName, element.GetType());
				if (dependencyProperty != null)
				{
					object value = null;
					if (subStream._data != null)
					{
						try
						{
							new SecurityPermission(SecurityPermissionFlag.SerializationFormatter).Demand();
							value = this.Formatter.Deserialize(new MemoryStream(subStream._data));
						}
						catch (SecurityException)
						{
							value = DependencyProperty.UnsetValue;
						}
					}
					element.SetValue(dependencyProperty, value);
				}
			}
		}
Exemple #6
0
        private void LoadSubStreams(UIElement element, ArrayList subStreams)
        {
            for (int subStreamIndex = 0; subStreamIndex < subStreams.Count; ++subStreamIndex)
            {
                SubStream subStream = (SubStream)subStreams[subStreamIndex];

                // Restore the value of an individual DP
                DependencyProperty dp = DependencyProperty.FromName(subStream._propertyName, element.GetType());
                // If the dp cannot be found it may mean that we navigated back to a loose file that has been changed.
                if (dp != null)
                {
                    object newValue = null;
                    if (subStream._data != null)
                    {
                        try
                        {
                            new SecurityPermission(SecurityPermissionFlag.SerializationFormatter).Demand();     // prevent any journal metadata de-serialization in partial trust
                            newValue = this.Formatter.Deserialize(new MemoryStream(subStream._data));
                        }
                        catch (SecurityException)
                        {
                            newValue = DependencyProperty.UnsetValue;
                        }
                    }
                    element.SetValue(dp, newValue);
                }
            }
        }
        private void EnumerateEventHandlersForActivity(Guid scheduleTypeId, Activity activity)
        {
            List <ActivityHandlerDescriptor> handlerMethods = new List <ActivityHandlerDescriptor>();
            MethodInfo method = activity.GetType().GetMethod("System.Workflow.ComponentModel.IDependencyObjectAccessor.GetInvocationList", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            foreach (EventInfo info2 in activity.GetType().GetEvents(BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance))
            {
                DependencyProperty property = DependencyProperty.FromName(info2.Name, activity.GetType());
                if (property != null)
                {
                    try
                    {
                        foreach (Delegate delegate2 in method.MakeGenericMethod(new Type[] { property.PropertyType }).Invoke(activity, new object[] { property }) as Delegate[])
                        {
                            ActivityHandlerDescriptor descriptor;
                            MethodInfo info4 = delegate2.Method;
                            descriptor.Name  = info4.DeclaringType.FullName + "." + info4.Name;
                            descriptor.Token = info4.MetadataToken;
                            handlerMethods.Add(descriptor);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            this.controllerConduit.UpdateHandlerMethodsForActivity(this.programId, scheduleTypeId, activity.QualifiedName, handlerMethods);
        }
Exemple #8
0
        public override object GetValue(object component)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            object value = base.GetValue(component);

            if (value == null)
            {
                // See if there is a value in the user data DesignTimeTypeNames hashtable.
                // If yes, it's probably a wrong type name.  Show the name anyway.
                DependencyObject dependencyObject = component as DependencyObject;
                if (dependencyObject != null)
                {
                    object key = DependencyProperty.FromName(this.RealPropertyDescriptor.Name, this.RealPropertyDescriptor.ComponentType);
                    value = Helpers.GetDesignTimeTypeName(dependencyObject, key);
                    if (string.IsNullOrEmpty(value as string))
                    {
                        key   = this.RealPropertyDescriptor.ComponentType.FullName + "." + this.RealPropertyDescriptor.Name;
                        value = Helpers.GetDesignTimeTypeName(dependencyObject, key);
                    }
                }
            }

            return(value);
        }
 public virtual ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     ValidationErrorCollection errors = new ValidationErrorCollection();
     Activity activity = manager.Context[typeof(Activity)] as Activity;
     Walker walker = new Walker(true);
     walker.FoundProperty += delegate (Walker w, WalkerEventArgs args) {
         if ((args.CurrentProperty != null) && (DependencyProperty.FromName(args.CurrentProperty.Name, args.CurrentProperty.DeclaringType) == null))
         {
             object[] customAttributes = args.CurrentProperty.GetCustomAttributes(typeof(ValidationOptionAttribute), true);
             if (((customAttributes.Length > 0) ? ((ValidationOptionAttribute) customAttributes[0]).ValidationOption : ValidationOption.Optional) != ValidationOption.None)
             {
                 errors.AddRange(this.ValidateProperty(args.CurrentProperty, args.CurrentPropertyOwner, args.CurrentValue, manager));
                 args.Action = WalkerAction.Skip;
             }
         }
     };
     walker.WalkProperties(activity, obj);
     return errors;
 }
Exemple #10
0
        public void TestGetObjectDataMethod()
        {
            string activityName = "TestSerialization";
            string propertyName = SerializationTestHelperClass.propertyName;

            SerializationTestHelperClass expected = new SerializationTestHelperClass(activityName);
            object actual = null;

            BinaryFormatter formatter = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream()) {
                formatter.Serialize(ms, expected);
                ms.Position = 0;
                actual      = formatter.Deserialize(ms);
            }

            Assert.IsNotNull(actual, "#K2#1");
            Assert.IsTrue(actual is SerializationTestHelperClass, "#K2#2");

            DependencyProperty actualDepProp = DependencyProperty.FromName(propertyName, typeof(SerializationTestHelperClass));

            Assert.IsNotNull(actualDepProp, "#K2#3");
            Assert.AreEqual(propertyName, actualDepProp.Name, "#K2#4");
            Assert.AreEqual(typeof(SerializationTestHelperClass), actualDepProp.OwnerType, "#K2#5");
            Assert.AreEqual(typeof(string), actualDepProp.PropertyType, "#K2#6");
            Assert.AreEqual(activityName, ((SerializationTestHelperClass)actual).Name, "#K2#7");
        }
        public static CustomProperty CreateCustomProperty(IServiceProvider serviceProvider, string customPropertyName, PropertyDescriptor propertyDescriptor, object propertyOwner)
        {
            CustomProperty property = new CustomProperty(serviceProvider)
            {
                Name = customPropertyName
            };

            if (TypeProvider.IsAssignable(typeof(ActivityBind), propertyDescriptor.PropertyType))
            {
                System.Type type = PropertyDescriptorUtils.GetBaseType(propertyDescriptor, propertyOwner, serviceProvider);
                if (type == null)
                {
                    throw new InvalidOperationException(SR.GetString("Error_CantDeterminePropertyBaseType", new object[] { propertyDescriptor.Name }));
                }
                property.Type = type.FullName;
            }
            else
            {
                property.Type = propertyDescriptor.PropertyType.FullName;
            }
            if (propertyDescriptor is ActivityBindPropertyDescriptor)
            {
                DependencyProperty property2 = DependencyProperty.FromName(propertyDescriptor.Name, propertyDescriptor.ComponentType);
                property.IsEvent = (property2 != null) && property2.IsEvent;
            }
            property.Category = propertyDescriptor.Category;
            return(property);
        }
Exemple #12
0
        public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            DependencyProperty dependencyProperty = null;
            Activity           activity           = null;

            if (this.propertySegment != null)
            {
                activity = this.propertySegment.Object as Activity;
            }

            if (activity != null)
            {
                string propertyName = Name;
                Type   propertyType = DeclaringType;
                if (!String.IsNullOrEmpty(propertyName) && propertyType != null)
                {
                    dependencyProperty = DependencyProperty.FromName(propertyName, propertyType);
                }
            }

            object value     = null;
            object targetObj = (this.propertySegment == null) ? obj : this.propertySegment.Object;

            if (dependencyProperty != null && !dependencyProperty.DefaultMetadata.IsMetaProperty)
            {
                // If this is not a Bind, we retrieve the value through the property descriptor.
                // If we have directly assigned the value to the property then GetBinding is going to return null
                // If that happens then we need to make sure that we get at the actual value
                if (activity.IsBindingSet(dependencyProperty))
                {
                    value = activity.GetBinding(dependencyProperty);
                }
                else if (!dependencyProperty.IsEvent)
                {
                    value = activity.GetValue(dependencyProperty);
                }
                else
                {
                    value = activity.GetHandler(dependencyProperty);
                }
            }

            if (value == null)
            {
                if (this.realPropInfo != null)
                {
                    value = this.realPropInfo.GetValue(targetObj, invokeAttr, binder, index, culture);
                }
                else if (this.realPropDesc != null)
                {
                    value = this.realPropDesc.GetValue(targetObj);
                }
            }

            return(value);
        }
 internal static bool IsBindableProperty(PropertyDescriptor propertyDescriptor)
 {
     if (propertyDescriptor.PropertyType == typeof(ActivityBind))
     {
         return true;
     }
     if (propertyDescriptor.Converter is ActivityBindTypeConverter)
     {
         return true;
     }
     DependencyProperty property = DependencyProperty.FromName(propertyDescriptor.Name, propertyDescriptor.ComponentType);
     return ((typeof(DependencyObject).IsAssignableFrom(propertyDescriptor.ComponentType) && (property != null)) && !property.DefaultMetadata.IsMetaProperty);
 }
        // Token: 0x060015DE RID: 5598 RVA: 0x0006AC74 File Offset: 0x00068E74
        private XamlMember FindDependencyPropertyBackedProperty(string name, bool isAttachable, bool skipReadOnlyCheck)
        {
            XamlMember         xamlMember = null;
            DependencyProperty dependencyProperty;

            if ((dependencyProperty = DependencyProperty.FromName(name, base.UnderlyingType)) != null)
            {
                WpfXamlType wpfXamlType;
                if (this.IsBamlScenario)
                {
                    wpfXamlType = (System.Windows.Markup.XamlReader.BamlSharedSchemaContext.GetXamlType(dependencyProperty.OwnerType) as WpfXamlType);
                }
                else
                {
                    wpfXamlType = (System.Windows.Markup.XamlReader.GetWpfSchemaContext().GetXamlType(dependencyProperty.OwnerType) as WpfXamlType);
                }
                if (wpfXamlType != null)
                {
                    xamlMember = WpfXamlType.FindKnownMember(wpfXamlType, name, isAttachable);
                }
                if (xamlMember == null)
                {
                    if (this.IsBamlScenario)
                    {
                        xamlMember = new WpfXamlMember(dependencyProperty, isAttachable);
                    }
                    else if (isAttachable)
                    {
                        xamlMember = this.GetAttachedDependencyProperty(name, dependencyProperty);
                        if (xamlMember == null)
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        xamlMember = this.GetRegularDependencyProperty(name, dependencyProperty, skipReadOnlyCheck);
                        if (xamlMember == null)
                        {
                            xamlMember = this.GetAttachedDependencyProperty(name, dependencyProperty);
                        }
                        if (xamlMember == null)
                        {
                            xamlMember = new WpfXamlMember(dependencyProperty, false);
                        }
                    }
                    return(this.CacheAndReturnXamlMember(xamlMember));
                }
            }
            return(xamlMember);
        }
Exemple #15
0
        public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            DependencyProperty dependencyProperty = null;
            Activity           activity           = null;

            if (this.propertySegment != null)
            {
                activity = this.propertySegment.Object as Activity;
            }
            if (activity != null)
            {
                string name          = this.Name;
                Type   declaringType = this.DeclaringType;
                if (!string.IsNullOrEmpty(name) && (declaringType != null))
                {
                    dependencyProperty = DependencyProperty.FromName(name, declaringType);
                }
            }
            object binding = null;
            object obj3    = (this.propertySegment == null) ? obj : this.propertySegment.Object;

            if ((dependencyProperty != null) && !dependencyProperty.DefaultMetadata.IsMetaProperty)
            {
                if (activity.IsBindingSet(dependencyProperty))
                {
                    binding = activity.GetBinding(dependencyProperty);
                }
                else if (!dependencyProperty.IsEvent)
                {
                    binding = activity.GetValue(dependencyProperty);
                }
                else
                {
                    binding = activity.GetHandler(dependencyProperty);
                }
            }
            if (binding == null)
            {
                if (this.realPropInfo != null)
                {
                    return(this.realPropInfo.GetValue(obj3, invokeAttr, binder, index, culture));
                }
                if (this.realPropDesc != null)
                {
                    binding = this.realPropDesc.GetValue(obj3);
                }
            }
            return(binding);
        }
 public override object GetValue(object component)
 {
     object binding = null;
     DependencyObject obj3 = component as DependencyObject;
     DependencyProperty dependencyProperty = DependencyProperty.FromName(this.Name, this.ComponentType);
     if (((obj3 != null) && (dependencyProperty != null)) && obj3.IsBindingSet(dependencyProperty))
     {
         binding = obj3.GetBinding(dependencyProperty);
     }
     if (!(binding is ActivityBind))
     {
         binding = base.GetValue(component);
     }
     return binding;
 }
Exemple #17
0
        public virtual ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            ValidationErrorCollection errors = new ValidationErrorCollection();

            Activity activity = manager.Context[typeof(Activity)] as Activity;

            // Validate all members that support validations.
            Walker walker = new Walker(true);

            walker.FoundProperty += delegate(Walker w, WalkerEventArgs args)
            {
                //If we find dynamic property of the same name then we do not invoke the validator associated with the property
                //Attached dependency properties will not be found by FromName().

                // args.CurrentProperty can be null if the property is of type IList.  The walker would go into each item in the
                // list, but we don't need to validate these items.
                if (args.CurrentProperty != null)
                {
                    DependencyProperty dependencyProperty = DependencyProperty.FromName(args.CurrentProperty.Name, args.CurrentProperty.DeclaringType);
                    if (dependencyProperty == null)
                    {
                        object[]         validationVisibilityAtrributes = args.CurrentProperty.GetCustomAttributes(typeof(ValidationOptionAttribute), true);
                        ValidationOption validationVisibility           = (validationVisibilityAtrributes.Length > 0) ? ((ValidationOptionAttribute)validationVisibilityAtrributes[0]).ValidationOption : ValidationOption.Optional;
                        if (validationVisibility != ValidationOption.None)
                        {
                            errors.AddRange(ValidateProperty(args.CurrentProperty, args.CurrentPropertyOwner, args.CurrentValue, manager));
                            // don't probe into subproperties as validate object inside the ValidateProperties call does it for us
                            args.Action = WalkerAction.Skip;
                        }
                    }
                }
            };

            walker.WalkProperties(activity, obj);

            return(errors);
        }
                public Dependent(object source, MemberExpression exp)
                {
                    bool registered = false;

                    if (source is DependencyObject)
                    {
                        _dp = DependencyProperty.FromName(exp.Member.Name, source.GetType());
                        if (_dp != null)
                        {
                            ((DependencyObject)source).RegisterPropertyChangedHandler(_dp, OnDependencyPropertyChanged);
                            registered = true;
                        }
                    }

                    if (!registered && source is INotifyPropertyChanged)
                    {
                    }
                }
Exemple #19
0
        public void TestFromNameMethod()
        {
            string             propertyName = "To";
            Type               ownerType    = typeof(ClassProp3);
            DependencyProperty expected     = DependencyProperty.Register(propertyName, typeof(string),
                                                                          ownerType, new PropertyMetadata("*****@*****.**"));

            DependencyProperty actual = DependencyProperty.FromName(propertyName, ownerType);

            Assert.IsNotNull(actual, "#K1#1");
            Assert.AreEqual(expected.Name, actual.Name, "#K1#2");
            Assert.AreEqual(expected.OwnerType, actual.OwnerType, "#K1#3");
            Assert.AreEqual(expected.PropertyType, actual.PropertyType, "#K1#4");
            Assert.AreSame(expected, actual, "#K1#5");

            actual = DependencyProperty.FromName("garbage", ownerType);

            Assert.IsNull(actual, "#K1#11");
        }
Exemple #20
0
        private void LoadSubStreams(UIElement element, ArrayList subStreams)
        {
            for (int subStreamIndex = 0; subStreamIndex < subStreams.Count; ++subStreamIndex)
            {
                SubStream subStream = (SubStream)subStreams[subStreamIndex];

                // Restore the value of an individual DP
                DependencyProperty dp = DependencyProperty.FromName(subStream._propertyName, element.GetType());
                // If the dp cannot be found it may mean that we navigated back to a loose file that has been changed.
                if (dp != null)
                {
                    object newValue = null;
                    if (subStream._data != null)
                    {
                        newValue = this.Formatter.Deserialize(new MemoryStream(subStream._data));
                    }
                    element.SetValue(dp, newValue);
                }
            }
        }
Exemple #21
0
        public static void ValidateRoles(Activity activity, string identity)
        {
            DependencyProperty dp = DependencyProperty.FromName("Roles", activity.GetType().BaseType);

            if (dp == null)
            {
                dp = DependencyProperty.FromName("Roles", activity.GetType());
            }
            if (dp != null)
            {
                ActivityBind bind = activity.GetBinding(dp);
                if (bind != null)
                {
                    WorkflowRoleCollection collection = bind.GetRuntimeValue(activity) as WorkflowRoleCollection;
                    if ((collection != null) && !collection.IncludesIdentity(identity))
                    {
                        throw new WorkflowAuthorizationException(activity.Name, identity);
                    }
                }
            }
        }
        internal static void ValidateRoles(Activity activity, string identity)
        {
            DependencyProperty dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType().BaseType);

            if (dependencyProperty == null)
            {
                dependencyProperty = DependencyProperty.FromName("Roles", activity.GetType());
            }
            if (dependencyProperty != null)
            {
                ActivityBind binding = activity.GetBinding(dependencyProperty);
                if (binding != null)
                {
                    WorkflowRoleCollection runtimeValue = binding.GetRuntimeValue(activity) as WorkflowRoleCollection;
                    if ((runtimeValue != null) && !runtimeValue.IncludesIdentity(identity))
                    {
                        throw new WorkflowAuthorizationException(activity.Name, identity);
                    }
                }
            }
        }
Exemple #23
0
        private XamlMember TransformMember(XamlMember member)
        {
            var declType = member.DeclaringType;
            var name     = member.Name;

            var depProp = DependencyProperty.FromName(name, declType.UnderlyingType);

            if (depProp != null)
            {
                if (!propCache.TryGetValue(depProp, out var uMember))
                {
                    if (!ownerTypeCache.TryGetValue(depProp.OwningType, out var xamlType))
                    {
                        ownerTypeCache.Add(depProp.OwningType, xamlType = new XamlType(depProp.OwningType, schemaContext));
                    }
                    propCache.Add(depProp, uMember = new KnitXamlPropertyMember(depProp, xamlType, dependencyObjectType));
                }
                return(uMember);
            }

            return(member);
        }
        /// <summary>
        ///     Static method that returns a DependencyPropertyDescriptor for a given property name.
        ///     The name may refer to a direct or attached property.  OwnerType is the type of
        ///     object that owns the property definition.  TargetType is the type of object you wish
        ///     to set the property for.  For direct properties, they are the same type.  For attached
        ///     properties they usually differ.
        /// </summary>
        public static DependencyPropertyDescriptor FromName(string name, Type ownerType, Type targetType,
                                                            bool ignorePropertyType)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (ownerType == null)
            {
                throw new ArgumentNullException("ownerType");
            }
            if (targetType == null)
            {
                throw new ArgumentNullException("targetType");
            }

            DependencyProperty dp = DependencyProperty.FromName(name, ownerType);

            if (dp != null)
            {
                if (ignorePropertyType)
                {
                    try
                    {
                        return(FromProperty(dp, ownerType, targetType, ignorePropertyType));
                    }
                    catch (AmbiguousMatchException)
                    {
                        return(FromProperty(dp, targetType));
                    }
                }
                else
                {
                    return(FromProperty(dp, targetType));
                }
            }

            return(null);
        }
        private static CorrelationToken GetCorrelationToken(Activity activity)
        {
            DependencyProperty dependencyProperty = DependencyProperty.FromName("CorrelationToken", activity.GetType());

            if (dependencyProperty == null)
            {
                dependencyProperty = DependencyProperty.FromName("CorrelationToken", activity.GetType().BaseType);
            }
            CorrelationToken token = activity.GetValue(dependencyProperty) as CorrelationToken;

            if (token == null)
            {
                throw new InvalidOperationException(SR.GetString("Error_CorrelationTokenMissing", new object[] { activity.Name }));
            }
            CorrelationToken token2 = CorrelationTokenCollection.GetCorrelationToken(activity, token.Name, token.OwnerActivityName);

            if (token2 == null)
            {
                throw new InvalidOperationException(SR.GetString("Error_CorrelationTokenMissing", new object[] { activity.Name }));
            }
            return(token2);
        }
 public override void SetValue(object component, object value)
 {
     object obj2 = this.GetValue(component);
     ActivityBind bind = value as ActivityBind;
     DependencyObject obj3 = component as DependencyObject;
     DependencyProperty dependencyProperty = DependencyProperty.FromName(this.Name, this.ComponentType);
     if (((obj3 != null) && (dependencyProperty != null)) && (bind != null))
     {
         using (new ComponentChangeDispatcher(base.ServiceProvider, obj3, this))
         {
             if (dependencyProperty.IsEvent && (base.ServiceProvider != null))
             {
                 IEventBindingService service = base.ServiceProvider.GetService(typeof(IEventBindingService)) as IEventBindingService;
                 if ((service != null) && (service.GetEvent(base.RealPropertyDescriptor) != null))
                 {
                     base.RealPropertyDescriptor.SetValue(component, null);
                 }
             }
             obj3.SetBinding(dependencyProperty, bind);
             base.OnValueChanged(obj3, EventArgs.Empty);
             goto Label_00F8;
         }
     }
     if (((obj3 != null) && (dependencyProperty != null)) && obj3.IsBindingSet(dependencyProperty))
     {
         using (new ComponentChangeDispatcher(base.ServiceProvider, obj3, this))
         {
             obj3.RemoveProperty(dependencyProperty);
             base.OnValueChanged(obj3, EventArgs.Empty);
         }
     }
     base.SetValue(component, value);
     Label_00F8:
     if ((obj2 != value) && (((obj2 is ActivityBind) && !(value is ActivityBind)) || (!(obj2 is ActivityBind) && (value is ActivityBind))))
     {
         TypeDescriptor.Refresh(component);
     }
 }
Exemple #27
0
            public static bool IsBindableOrMetaProperty(PropertyInfo propertyInfo, out bool isMetaProperty)
            {
                isMetaProperty = false;
                if (propertyInfo.DeclaringType.Equals(compositeActivityType) || propertyInfo.DeclaringType.Equals(dependencyObjectType))
                {
                    return(false);
                }
                if (propertyInfo.DeclaringType.Equals(activityType) && !string.Equals(propertyInfo.Name, "Name", StringComparison.Ordinal))
                {
                    return(false);
                }
                if (activityConditionType.IsAssignableFrom(propertyInfo.PropertyType))
                {
                    return(false);
                }
                DependencyProperty property = DependencyProperty.FromName(propertyInfo.Name, propertyInfo.DeclaringType);

                if ((property != null) && property.DefaultMetadata.IsMetaProperty)
                {
                    isMetaProperty = true;
                }
                return(true);
            }
        // Token: 0x060020FC RID: 8444 RVA: 0x00097CD4 File Offset: 0x00095ED4
        private object GetDpOrPi(Type ownerType, string propName)
        {
            object obj = null;

            if (ownerType != null)
            {
                obj = DependencyProperty.FromName(propName, ownerType);
                if (obj == null)
                {
                    PropertyInfo propertyInfo = null;
                    MemberInfo[] member       = ownerType.GetMember(propName, MemberTypes.Property, BindingFlags.Instance | BindingFlags.Public);
                    foreach (PropertyInfo propertyInfo2 in member)
                    {
                        if (propertyInfo2.GetIndexParameters().Length == 0 && (propertyInfo == null || propertyInfo.DeclaringType.IsAssignableFrom(propertyInfo2.DeclaringType)))
                        {
                            propertyInfo = propertyInfo2;
                        }
                    }
                    obj = propertyInfo;
                }
            }
            return(obj);
        }
        /// <summary>
        ///     Static method that returns a DependencyPropertyDescriptor for a given property name.
        ///     The name may refer to a direct or attached property.  OwnerType is the type of
        ///     object that owns the property definition.  TargetType is the type of object you wish
        ///     to set the property for.  For direct properties, they are the same type.  For attached
        ///     properties they usually differ.
        /// </summary>
        public static DependencyPropertyDescriptor FromName(string name, Type ownerType, Type targetType)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (ownerType == null)
            {
                throw new ArgumentNullException("ownerType");
            }
            if (targetType == null)
            {
                throw new ArgumentNullException("targetType");
            }

            DependencyProperty dp = DependencyProperty.FromName(name, ownerType);

            if (dp != null)
            {
                return(FromProperty(dp, targetType));
            }

            return(null);
        }
        public override object GetValue(object component)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }
            object designTimeTypeName = base.GetValue(component);

            if (designTimeTypeName == null)
            {
                DependencyObject owner = component as DependencyObject;
                if (owner != null)
                {
                    object key = DependencyProperty.FromName(base.RealPropertyDescriptor.Name, base.RealPropertyDescriptor.ComponentType);
                    designTimeTypeName = System.Workflow.Activities.Common.Helpers.GetDesignTimeTypeName(owner, key);
                    if (string.IsNullOrEmpty(designTimeTypeName as string))
                    {
                        key = base.RealPropertyDescriptor.ComponentType.FullName + "." + base.RealPropertyDescriptor.Name;
                        designTimeTypeName = System.Workflow.Activities.Common.Helpers.GetDesignTimeTypeName(owner, key);
                    }
                }
            }
            return(designTimeTypeName);
        }