//
        // Attached property getter for the compiled expression root for the implementation surface area of an activity
        public static object GetCompiledExpressionRootForImplementation(object target)
        {
            object value = null;

            AttachablePropertyServices.TryGetProperty(target, compiledExpressionRootForImplementationProperty, out value);
            return(value);
        }
        public void BasicWithIAPSType()
        {
            ImplementsIAPS a = new ImplementsIAPS();

            object value;

            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(a, propertyOne, out value), "We expect the store doesn't have propertyOne for 'a' yet");
            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(a, propertyTwo, out value), "We expect the store doesn't have propertyTwo for 'a' yet");

            IAttachedPropertyStore aAsIAPS = a as IAttachedPropertyStore;

            Assert.IsNotNull(aAsIAPS);
            Assert.IsFalse(aAsIAPS.TryGetProperty(propertyOne, out value), "We expect the type does not have propertyOne yet");
            Assert.IsFalse(aAsIAPS.TryGetProperty(propertyTwo, out value), "We expect the type does not have propertyTwo yet");

            AttachablePropertyServices.SetProperty(a, propertyOne, "Foo Bar");
            Assert.IsTrue(AttachablePropertyServices.GetAttachedPropertyCount(a) == 1);
            var props = new KeyValuePair <AttachableMemberIdentifier, object> [1];

            AttachablePropertyServices.CopyPropertiesTo(a, props, 0);
            Assert.IsTrue((string)props[0].Value == "Foo Bar");
            Assert.IsTrue(AttachablePropertyServices.TryGetProperty(a, propertyOne, out value) && (string)value == "Foo Bar", "We should now find the property");
            Assert.IsTrue(aAsIAPS.TryGetProperty(propertyOne, out value) && (string)value == "Foo Bar", "And it's storage should be local on the instance");

            string valueAsString;

            Assert.IsTrue(AttachablePropertyServices.TryGetProperty(a, propertyOne, out valueAsString) && valueAsString == "Foo Bar");

            Assert.IsTrue(AttachablePropertyServices.RemoveProperty(a, propertyOne), "We should be able to remove the property");
            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(a, propertyOne, out value), "We should not have the property anymore");
            Assert.IsFalse(aAsIAPS.TryGetProperty(propertyOne, out value), "Even the local copy should not have the property anymore");
            Assert.IsTrue(AttachablePropertyServices.GetAttachedPropertyCount(a) == 0);
        }
Beispiel #3
0
        /// <summary>
        /// Gets or sets whether the target is an obstacle.
        /// </summary>
        public static bool GetIsObstacle(object target)
        {
            bool isObstacle = false;

            AttachablePropertyServices.TryGetProperty(target, IsObstacleProperty, out isObstacle);
            return(isObstacle);
        }
Beispiel #4
0
        public static object GetHintSize(object instance)
        {
            object viewState;

            AttachablePropertyServices.TryGetProperty(instance, HintSizeName, out viewState);
            return(viewState);
        }
        // Get the attached workflow symbol and remove it from the root.
        WorkflowSymbol GetAttachedWorkflowSymbol()
        {
            object         rootInstance = this.GetRootInstance();
            WorkflowSymbol wfSymbol     = null;

            if (rootInstance != null)
            {
                Activity documentRootElement = GetRootWorkflowElement(rootInstance);
                if (documentRootElement != null)
                {
                    string symbolString;
                    if (AttachablePropertyServices.TryGetProperty <string>(documentRootElement, DebugSymbol.SymbolName, out symbolString))
                    {
                        try
                        {
                            wfSymbol = WorkflowSymbol.Decode(symbolString);
                            // Change the name to the currently loaded file.
                            wfSymbol.FileName = this.Context.Items.GetValue <WorkflowFileItem>().LoadedFile;
                        }
                        catch (Exception ex)
                        {
                            if (Fx.IsFatal(ex))
                            {
                                throw;
                            }
                        }
                        finally
                        {
                            AttachablePropertyServices.RemoveProperty(documentRootElement, DebugSymbol.SymbolName);
                        }
                    }
                }
            }
            return(wfSymbol);
        }
Beispiel #6
0
        /// <summary>
        /// Gets or sets whether the target is a path.
        /// </summary>
        public static bool GetIsPath(object target)
        {
            bool isPath = false;

            AttachablePropertyServices.TryGetProperty(target, IsPathProperty, out isPath);
            return(isPath);
        }
Beispiel #7
0
        /// <summary>
        /// Gets the height of the heightmap.
        /// </summary>
        public static int GetHeight(Surface surface)
        {
            Vector3 value = Vector3.One;

            AttachablePropertyServices.TryGetProperty(surface, SizeProperty, out value);
            return((int)value.Y);
        }
Beispiel #8
0
        /// <summary>
        /// Gets the mask texture scale of the material group.
        /// </summary>
        public static Vector2 GetMaskTextureScale(MaterialGroup materialGroup)
        {
            Vector2 value = Vector2.One;

            AttachablePropertyServices.TryGetProperty(materialGroup, MaskTextureScaleProperty, out value);
            return(value);
        }
Beispiel #9
0
        public static object GetCachePeriod(object instance)
        {
            object viewState;

            AttachablePropertyServices.TryGetProperty(instance, CachePeriodName, out viewState);
            return(viewState);
        }
Beispiel #10
0
        public static object GetBehavior(object instance)
        {
            object viewState;

            AttachablePropertyServices.TryGetProperty(instance, BehaviorName, out viewState);
            return(viewState);
        }
        public void BasicWithNonIAPSType()
        {
            DoesntImplementIAPS a = new DoesntImplementIAPS();
            DoesntImplementIAPS b = new DoesntImplementIAPS();

            object value;

            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(a, propertyOne, out value), "We expect the store doesn't have propertyOne for 'a' yet");
            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(a, propertyTwo, out value), "We expect the store doesn't have propertyTwo for 'a' yet");
            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(b, propertyOne, out value), "We expect the store doesn't have propertyOne for 'b' yet");
            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(b, propertyTwo, out value), "We expect the store doesn't have propertyTwo for 'b' yet");

            AttachablePropertyServices.SetProperty(a, propertyOne, "Something");
            Assert.IsTrue(AttachablePropertyServices.GetAttachedPropertyCount(a) == 1);
            var props = new KeyValuePair <AttachableMemberIdentifier, object> [1];

            AttachablePropertyServices.CopyPropertiesTo(a, props, 0);
            Assert.IsTrue((string)props[0].Value == "Something");
            Assert.IsTrue(AttachablePropertyServices.GetAttachedPropertyCount(b) == 0);
            Assert.IsTrue(AttachablePropertyServices.TryGetProperty(a, propertyOne, out value) && (string)value == "Something", "We should now find the property");
            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(b, propertyOne, out value), "We should not see the attached property added to 'a' on 'b'");

            string valueAsString;

            Assert.IsTrue(AttachablePropertyServices.TryGetProperty(a, propertyOne, out valueAsString) && valueAsString == "Something");

            Assert.IsTrue(AttachablePropertyServices.RemoveProperty(a, propertyOne), "We should be able to remove the property");
            Assert.IsFalse(AttachablePropertyServices.TryGetProperty(a, propertyOne, out value), "We should not have the property anymore");
            Assert.IsTrue(AttachablePropertyServices.GetAttachedPropertyCount(a) == 0);
        }
Beispiel #12
0
        // Hook so partial-trust test code can access internals
        public static object PropertyAccessor(object target, string propertyName)
        {
            object value = null;

            AttachablePropertyServices.TryGetProperty(target,
                                                      new AttachableMemberIdentifier(typeof(APP), propertyName), out value);
            return(value);
        }
Beispiel #13
0
 internal static bool HasPropertyReferences(object target)
 {
     if (AttachablePropertyServices.TryGetProperty(target, propertyReferencesPropertyID, out PropertyReferenceCollection propertyReferences))
     {
         return(propertyReferences.Count > 0);
     }
     return(false);
 }
Beispiel #14
0
        /// <summary>
        /// Sets the step of the heightmap.
        /// </summary>
        public static void SetStep(Surface surface, float value)
        {
            Vector3 size = Vector3.One;

            AttachablePropertyServices.TryGetProperty(surface, SizeProperty, out size);
            size.Z = value;
            AttachablePropertyServices.SetProperty(surface, SizeProperty, size);
        }
Beispiel #15
0
 private static PropertyReferenceCollection GetPropertyReferenceCollection(object target)
 {
     if (!AttachablePropertyServices.TryGetProperty(target, propertyReferencesPropertyID, out PropertyReferenceCollection propertyReferences))
     {
         propertyReferences = new PropertyReferenceCollection(target);
         AttachablePropertyServices.SetProperty(target, propertyReferencesPropertyID, propertyReferences);
     }
     return(propertyReferences);
 }
Beispiel #16
0
 /// <summary>
 /// Gets a list of mask textures of the material group.
 /// </summary>
 public static System.Collections.IList GetMaskTextures(MaterialGroup materialGroup)
 {
     System.Collections.IList value;
     if (!AttachablePropertyServices.TryGetProperty(materialGroup, MaskTexturesProperty, out value))
     {
         AttachablePropertyServices.SetProperty(materialGroup, MaskTexturesProperty, value = new List <object>());
     }
     return(value);
 }
Beispiel #17
0
        // We need this explicit check because otherwise, an empty collection might get serialized
        // just because the getter was accessed
        private static bool ShouldSerializeCollection <T>(object target, AttachableMemberIdentifier property)
        {
            if (AttachablePropertyServices.TryGetProperty(target, property, out IList <T> result))
            {
                return(result.Count > 0);
            }

            return(false);
        }
Beispiel #18
0
        public static void RaiseTapEvent(object target)
        {
            Delegate handlers;

            if (AttachablePropertyServices.TryGetProperty(target, TapEvent, out handlers))
            {
                handlers.DynamicInvoke(target, new EventArgs());
            }
        }
Beispiel #19
0
        /// <summary>
        /// Gets the priority.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>
        /// The priority if the item has one; <c>null</c> otherwise.
        /// </returns>
        public static int?GetPriority(ServerItem item)
        {
            int?priority;

            return(AttachablePropertyServices.TryGetProperty(
                       item,
                       new AttachableMemberIdentifier(typeof(Queue), "Priority"),
                       out priority) ? priority : null);
        }
        private static int GetIntegerAttachedProperty(object instance, AttachableMemberIdentifier memberIdentifier)
        {
            int num;

            if (AttachablePropertyServices.TryGetProperty <int>(instance, memberIdentifier, out num))
            {
                return(num);
            }
            return(-1);
        }
        public static object GetFileName(object instance)
        {
            string str;

            if (AttachablePropertyServices.TryGetProperty <string>(instance, FileNameName, out str))
            {
                return(str);
            }
            return(string.Empty);
        }
Beispiel #22
0
        public static VisualBasicSettings GetSettings(object target)
        {
            VisualBasicSettings settings;

            if (!AttachablePropertyServices.TryGetProperty <VisualBasicSettings>(target, settingsPropertyID, out settings))
            {
                return(null);
            }
            return(settings);
        }
Beispiel #23
0
        internal static bool GetHasErrorActivities(object target)
        {
            object result;

            if (AttachablePropertyServices.TryGetProperty(target, HasErrorActivitiesProperty, out result))
            {
                return((bool)result);
            }
            return(false);
        }
        public void NonStoreGetSet()
        {
            var a = new object();

            AttachablePropertyServices.SetProperty(a, Attachable.FooIdentifier, "x");
            string v;

            Assert.IsTrue(AttachablePropertyServices.TryGetProperty <string> (a, Attachable.FooIdentifier, out v), "#1");
            Assert.AreEqual("x", v, "#2");
        }
Beispiel #25
0
        public static ActivityPropertyReference GetPropertyReference(object target)
        {
            ActivityPropertyReference reference;

            if (!AttachablePropertyServices.TryGetProperty <ActivityPropertyReference>(target, propertyReferencePropertyID, out reference))
            {
                return(null);
            }
            return(reference);
        }
Beispiel #26
0
        private static IList <T> GetCollection <T>(object target, AttachableMemberIdentifier property)
        {
            if (!AttachablePropertyServices.TryGetProperty(target, property, out IList <T> result))
            {
                result = new Collection <T>();
                AttachablePropertyServices.SetProperty(target, property, result);
            }

            return(result);
        }
        public static Dictionary <string, object> GetViewState(object instance)
        {
            if (instance == null)
            {
                throw FxTrace.Exception.AsError(new ArgumentNullException("instance"));
            }
            Dictionary <string, object> viewState;

            AttachablePropertyServices.TryGetProperty(instance, ViewStateName, out viewState);
            return(viewState);
        }
Beispiel #28
0
        public static IList <string> GetStringsList(object target)
        {
            IList <string> result;

            if (!AttachablePropertyServices.TryGetProperty(target, listPropertyID, out result))
            {
                result = new List <string>();
                AttachablePropertyServices.SetProperty(target, listPropertyID, result);
            }
            return(result);
        }
Beispiel #29
0
        public static IDictionary <string, string> GetStringsDict(object target)
        {
            IDictionary <string, string> result;

            if (!AttachablePropertyServices.TryGetProperty(target, dictPropertyID, out result))
            {
                result = new Dictionary <string, string>();
                AttachablePropertyServices.SetProperty(target, dictPropertyID, result);
            }
            return(result);
        }
Beispiel #30
0
        /// <summary>
        /// Sets the height of the heightmap.
        /// </summary>
        public static void SetHeight(Surface surface, int value)
        {
            Vector3 size;

            if (!AttachablePropertyServices.TryGetProperty(surface, SizeProperty, out size))
            {
                size = Vector3.UnitZ;
            }
            size.Y = value;
            AttachablePropertyServices.SetProperty(surface, SizeProperty, size);
        }