public ActionPropertySet MergeProperties(ActionPropertySet[] sets)
 {
     ActionPropertySet merged = new ActionPropertySet();
     merged["ThisWasMerged"] = new ActionProperty("yaya", "sisterhood");
     countMerged = sets.Length;
     return merged;
 }
Esempio n. 2
0
        public ActionData(IFile file, IActionPropertySet inputSet, OptionList options)
        {           
            m_file = file;
            m_actionProps = new ActionPropertySet(inputSet);

            IActionProperty actionPropertyName = new ActionProperty("FileName", typeof(System.String), PropertyDisplayType.Default, false, false, m_file.FileName, true);
            IActionProperty actionPropertyDisplay = new ActionProperty("DisplayName", typeof(System.String), PropertyDisplayType.Default, false, false, m_file.DisplayName, true);
            IActionProperty actionPropertyType = new ActionProperty("FileType", typeof(System.String), PropertyDisplayType.Default, false, false, FileTypeBridge.GetFileType(m_file.FileType), true);

            m_actionProps.SystemProperties["FileName"] = actionPropertyName;
            m_actionProps.SystemProperties["DisplayName"] = actionPropertyDisplay;
            m_actionProps.SystemProperties["FileType"] = actionPropertyType;

            m_properties["FileName"] = actionPropertyName.Value.ToString();
            m_properties["DisplayName"] = actionPropertyDisplay.Value.ToString();
            m_properties["FileType"] = actionPropertyType.Value.ToString();

			foreach (KeyValuePair<string, IActionProperty> prop in m_actionProps)
			{
				if (options.Contains(prop.Key))
					prop.Value.Value = options[prop.Key].Checked;
			}

			if (m_actionProps.ContainsKey("HandleFootnotesHiddenData") && options.Contains("Footnotes") && options["Footnotes"].Checked)
			{
				m_actionProps["HandleFootnotesHiddenData"].Value = true;
			}

            FileName = m_file.FileName;
        }
Esempio n. 3
0
    private void CheckInitialize(SerializedProperty property, GUIContent label)
    {
        if (_actionProperty == null)
        {
            var target = property.serializedObject.targetObject;
            _actionProperty = fieldInfo.GetValue(target) as ActionProperty;
            if (_actionProperty == null)
            {
                _actionProperty = new ActionProperty();
                fieldInfo.SetValue(target, _actionProperty);
            }
            _options = _actionProperty.options;
            _action  = _actionProperty.action;

            CheckOptions();

            _foldout = EditorPrefs.GetBool("Options");
        }

        if (_actionProperty.options != null)
        {
            foreach (var field in _actionProperty.options.GetType().GetFields(BindingFlags.Instance |
                                                                              BindingFlags.NonPublic |
                                                                              BindingFlags.Public))
            {
                _optionValues[field.Name] = field.GetValue(_actionProperty.options);
                //Console.WriteLine("{0} = {1}", field.Name, field.GetValue(structValue));
            }
        }
    }
 private void AddActionProperty(Action sction)
 {
     for (int i = 0; i < row; i++)
     {
         var actionProperty = ActionProperty.Create($"name{i}", $"value{i}");
         sction.AddActionProperty(actionProperty);
     }
 }
Esempio n. 5
0
 protected override void Initialize()
 {
     StoreNameProperty = new TextProperty(this, StoreName)
     {
     };
     PersonNameProperty = new TextProperty(this, PersonName)
     {
     };
     LookUpAction = new ActionProperty(this, "LookUp");
 }
Esempio n. 6
0
        public RenderSprite()
            : base(ExecutionPriority.Rendering)
        {
            base.Name = "Render Sprite";
            ActionProperty assetProperty = new ActionProperty();

            assetProperty.Name = "Foo";
            this.ActionProperties.Add(assetProperty);
            assetProperty.Value = 32;
        }
Esempio n. 7
0
 public CommandResult(uint targetId, BattleCommand command, byte param = 0, byte hitNum = 1)
 {
     this.targetId          = targetId;
     this.worldMasterTextId = command.worldMasterTextId;
     this.param             = param;
     this.hitNum            = hitNum;
     this.commandType       = command.commandType;
     this.actionProperty    = command.actionProperty;
     this.actionType        = command.actionType;
 }
Esempio n. 8
0
        public static BComponent BuildComponent(XmlNode xmlDoc, BComponent parent, Behaviors behavior)
        {
            string name = xmlDoc.Name;

            if (ActionBool.NAME == name)
            {
                return(ActionBool.Build(xmlDoc, parent, behavior));
            }
            else if (ActionProperty.NAME == name)
            {
                return(ActionProperty.Build(xmlDoc, parent, behavior));
            }
            else if (ActionVoid.NAME == name)
            {
                return(ActionVoid.Build(xmlDoc, parent, behavior));
            }
            else if (ActionEnumerator.NAME == name)
            {
                return(ActionEnumerator.Build(xmlDoc, parent, behavior));
            }
            else if (RandomSelector.NAME == name)
            {
                return(RandomSelector.Build(xmlDoc, parent, behavior));
            }
            else if (RootSelector.NAME == name)
            {
                return(RootSelector.Build(xmlDoc, parent, behavior));
            }
            else if (Selector.NAME == name)
            {
                return(Selector.Build(xmlDoc, parent, behavior));
            }
            else if (Sequence.NAME == name)
            {
                return(Sequence.Build(xmlDoc, parent, behavior));
            }
            else if (Inverter.NAME == name)
            {
                return(Inverter.Build(xmlDoc, parent, behavior));
            }
            else if (UntilTrue.NAME == name)
            {
                return(UntilTrue.Build(xmlDoc, parent, behavior));
            }
            else if (UntilFalse.NAME == name)
            {
                return(UntilFalse.Build(xmlDoc, parent, behavior));
            }
            else
            {
                Debug.LogErrorFormat("I did not find the item: {0}", name);
                return(null);
            }
        }
Esempio n. 9
0
File: VAlarm.cs Progetto: ywscr/PDI
        /// <summary>
        /// The method can be called to clear all current property values from the alarm.  The version is left
        /// unchanged.
        /// </summary>
        public override void ClearProperties()
        {
            action   = null;
            trigger  = null;
            repeat   = null;
            duration = null;
            summary  = null;
            desc     = null;

            attendees   = null;
            attachments = null;
            customProps = null;
        }
 public override void Defend(ActionProperty property, ActionEffect totalEffect)
 {
     // we have resist magic !
     if (property.DamageKind == DamageKind.Magic)
     {
         log("resited magic!");
         double         dmg = property.DamageValue - MagicResistance;
         ActionProperty resistedProperty = new ActionProperty(property);
         resistedProperty.DamageValue = Math.Min(0, dmg);
         return;
     }
     base.Receive(property, totalEffect);
 }
Esempio n. 11
0
 protected override void Initialize()
 {
     SalesOrderDetailIdProperty = new IntegerKeyProperty(this, SalesOrderDetailId)
     {
         Required = true,
         Editable = false,
         IsKey    = true,
     };
     ProductIdProperty = new EnumIntProperty(this, ProductId)
     {
         Required = true,
         EnumType = "product",
         Editable = false,
     };
     OrderQtyProperty = new PositiveSmallIntProperty(this, OrderQty)
     {
         Required = true,
         Editable = false,
     };
     UnitPriceProperty = new MoneyProperty(this, UnitPrice)
     {
         Required = true,
         Editable = false,
     };
     UnitPriceDiscountProperty = new PercentFractionProperty(this, UnitPriceDiscount)
     {
         Required = true,
         Editable = false,
     };
     SpecialOfferIdProperty = new EnumIntProperty(this, SpecialOfferId)
     {
         Required = true,
         EnumType = "special offer",
         Editable = false,
     };
     LineTotalProperty = new MoneyProperty(this, LineTotal)
     {
         Required = true,
         Editable = false,
     };
     CarrierTrackingNumberProperty = new TextProperty(this, CarrierTrackingNumber)
     {
         Size     = 25,
         Editable = false,
     };
     DetailsAction = new ActionProperty(this, "Details");
     NewAction     = new ActionProperty(this, "New");
 }
        public IPolicyResponseAction MergePra()
        {
            if (m_propertiesList.Count > 1)
            {
                ActionPropertySet[] actionPropertySetArray = m_propertiesList.ToArray();

                m_enginePropertiesList = new List<ActionPropertySet>();

                ActionPropertySet mergedEngineProperties = MergeEngineProperties(actionPropertySetArray);

                // there is only ever one set of values for the SystemProperties so pick a
                // random one to save.
                SortedList<string, IActionProperty> systemProperties = new SortedList<string, IActionProperty>();
                foreach (string s in m_engineSystemProperties)
                {
                    if (actionPropertySetArray[0].SystemProperties.ContainsKey(s))
                        systemProperties[s] =
                            actionPropertySetArray[0].SystemProperties[s].Clone();
                    else
                        systemProperties[s] = new ActionProperty(s, "");
                }

                ActionPropertySet mergedProps = m_pra.Action.MergeProperties(actionPropertySetArray);
                if (mergedProps == null)
                {
                    mergedProps = new ActionPropertySet();
                }

                foreach (string key in mergedEngineProperties.Keys)
                {
                    if (!mergedProps.ContainsKey(key))
                        mergedProps[key] = new ActionProperty(key, "");

                    mergedProps[key] = mergedEngineProperties[key];
                }

                m_pra.InternalProperties = mergedProps;
                
                
                // enforce the values of the SystemProperties that were saved prior to merge
                foreach (string s in m_engineSystemProperties)
                {
                    m_pra.InternalProperties.SystemProperties[s] = systemProperties[s];
                }
            }
            return m_pra;
        }
Esempio n. 13
0
File: VAlarm.cs Progetto: ywscr/PDI
        /// <summary>
        /// This is overridden to allow copying of the additional properties
        /// </summary>
        /// <param name="p">The PDI object from which the settings are to be copied</param>
        protected override void Clone(PDIObject p)
        {
            VAlarm o = (VAlarm)p;

            this.ClearProperties();

            action   = (ActionProperty)o.Action.Clone();
            trigger  = (TriggerProperty)o.Trigger.Clone();
            repeat   = (RepeatProperty)o.Repeat.Clone();
            duration = (DurationProperty)o.Duration.Clone();
            summary  = (SummaryProperty)o.Summary.Clone();
            desc     = (DescriptionProperty)o.Description.Clone();

            this.Attendees.CloneRange(o.Attendees);
            this.Attachments.CloneRange(o.Attachments);
            this.CustomProperties.CloneRange(o.CustomProperties);
        }
Esempio n. 14
0
        /// <summary>
        /// Base view constructor
        /// </summary>
        /// <param name="svcProvider">Base service provider for the model</param>
        public ViewModel(IServiceProvider svcProvider)
        {
            if (svcProvider == null)
            {
                throw new ArgumentNullException("svcProvider");
            }

            // create a separate scope for each view to avoid memory leaks
            var scope = svcProvider.CreateScope();

            ServiceProvider = (scope != null) ? scope.ServiceProvider : svcProvider;

            Params = new NameValueCollection();

            ErrorParser = svcProvider.GetRequiredService <ErrorParser>();
            CloseAction = new ActionProperty(svcProvider, Messages.Action_Close);

            Initialize();
        }
        public void GuessWhatDeepCopyDoes()
        {
            //setup
            PolicyResponseAction src = new PolicyResponseAction();
            src.Assembly = "helloworld";
            src.ActionSetId = "action set id";
            src.AllowOverride = true;
            src.ClassName = "classname";
            ActionPropertySet srcPropertySet = new ActionPropertySet();
            srcPropertySet["Execute"] = new ActionProperty("Execute", "1");
            srcPropertySet["Foobar"] = new ActionProperty("Foobar", "2");
            foreach(string s in m_engineSystemProperties)
            {
                srcPropertySet.SystemProperties[s] = new ActionProperty(s, s);
            }
            src.InternalProperties = srcPropertySet;

            //execute
            PolicyResponseAction copy = src.DeepCopy();

            //verify
            FieldInfo[] fields = src.GetType().GetFields();
            foreach (FieldInfo f in fields)
            {
                Assert.AreEqual(f.GetValue(src), f.GetValue(copy), "Field {0} differs", f.Name);
            }

            PropertyInfo[] properties = src.GetType().GetProperties();
            foreach (PropertyInfo p in properties)
            {
                if (p.PropertyType.BaseType != typeof(string).BaseType)
                    continue;
                if (p.PropertyType.IsGenericType)
                    continue;
                Assert.AreEqual(p.GetValue(src, null), p.GetValue(copy, null), "Property {0} differs", p.Name);
            }
        }
 public virtual void Defend(ActionProperty property, ActionEffect totalEffect)
 {
     // no defence
 }
Esempio n. 17
0
        /// <summary>
        /// This method retrieves the properties for a given action, provided with a PolicyResponse, and IFile
        /// </summary>
        /// <param name="upi"></param>
        /// <param name="file"></param>
        /// <param name="thisAction"></param>
        /// <returns></returns>
        public static IActionPropertySet GetPropertySetForCorrespondingAction(PolicyResponseObject upi, IFile file, PolicyResponseAction thisAction)
        {
            foreach (IResolvedAction resolvedAction in upi.ResolvedActionCollection)
            {
                if (thisAction.Type == resolvedAction.ResponseAction.Type)
                {
                    Collection<IContentItem> fileCollection = resolvedAction.ContentCollection;
                    foreach (ContentItem filePolicyInfo in fileCollection)
                    {
                        IFile currentFile = filePolicyInfo.File;
                        if (file.UniqueIdentifier == currentFile.UniqueIdentifier)
                        {
                            if (filePolicyInfo.PolicySetCollection == null)
                                continue;

                            foreach (IPolicySetResponse policySet in filePolicyInfo.PolicySetCollection)
                            {
                                PolicySetResponse policySetInfo = policySet as PolicySetResponse;
                                if (policySetInfo.PolicyReportCollection == null)
                                    continue;

                                foreach (IPolicyResponse policyInfo in policySetInfo.PolicyReportCollection)
                                {
                                    if (policyInfo.ActionCollection == null)
                                        continue;

                                    foreach (IPolicyResponseAction ai in policyInfo.ActionCollection)
                                    {
                                        PolicyResponseAction actionInfo = ai as PolicyResponseAction;
                                        if (actionInfo.Action == null)
                                            continue;

                                        if (actionInfo.SupersededByAction == null &&
                                            actionInfo.Type == thisAction.Type &&
                                            actionInfo.ExceptionAction == thisAction.ExceptionAction)
                                        {
                                            foreach (IActionPropertyResponse apr in actionInfo.SystemPropertyCollection)
                                            {
                                                if (actionInfo.Action.PropertySet.SystemProperties.ContainsKey(apr.Name))
                                                {
                                                    actionInfo.Action.PropertySet.SystemProperties[apr.Name].Value = apr.Value;
                                                }
                                                else
                                                {
                                                    ActionProperty prop = new ActionProperty(apr.Name, apr.Value);
                                                    actionInfo.Action.PropertySet.SystemProperties.Add(apr.Name, prop);
                                                }
                                            }
                                            return actionInfo.Action.PropertySet;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return null;
        }
Esempio n. 18
0
        private void InitSystemPropertiesForStream(IActionPropertySet propertySet, Dictionary<string, string> props)
        {
            System.IO.FileInfo fi = new System.IO.FileInfo(props["FileName"]);

            IActionProperty actionProperty = new ActionProperty("FileType", typeof(string), PropertyDisplayType.Default, false, false, fi.Extension, true);
            propertySet.SystemProperties.Add("FileType", actionProperty);

            actionProperty = new ActionProperty("CurrentUser", typeof(string), PropertyDisplayType.Default, false, false, "test\\user", true);
            propertySet.SystemProperties.Add("CurrentUser", actionProperty);

            actionProperty = new ActionProperty("Date", typeof(string), PropertyDisplayType.Default, false, false, System.DateTime.Now.ToUniversalTime().ToString(), true);
            propertySet.SystemProperties.Add("Date", actionProperty);

            actionProperty = new ActionProperty("RecipientList", typeof(string[]), PropertyDisplayType.Default, false, false, new string[] { "*****@*****.**", "*****@*****.**" }, true);
            propertySet.SystemProperties.Add("RecipientList", actionProperty);

            actionProperty = new ActionProperty("RunAt", typeof(RunAt), PropertyDisplayType.Default, false, false, RunAt.Client, true);
            propertySet.SystemProperties.Add("RunAt", actionProperty);
        }
Esempio n. 19
0
		private void AddProperty(string key, CleanPropertiesDisplayTranslator displayer, Type dataType, PropertyDisplayType displayType, bool visible, bool allowOverride, object value, bool readOnly)
		{
			string name = (displayer == null ? key : displayer.GetDisplayType(key));
			ActionProperty property = new ActionProperty(name, dataType, displayType, visible, allowOverride, value, readOnly);
			Add(key, property);
		}
        public void CorrectlyMergedUIProperties()
        {
            string[] props = { "EXECUTE", "transparent", "autoexpand" };
            #region setup

            BasicAction basic = new BasicAction();
            PolicyResponseAction pra = new PolicyResponseAction();
            pra.Action = basic;

            PolicyResponseActionMerger merger = new PolicyResponseActionMerger(pra);

            bool propValue = true;
            for (int i = 0; i < 3; i++)
            {
                //set the property sets up such that the properties have different values
                ActionPropertySet newSet = new ActionPropertySet();
                foreach (string s in props)
                {
                    newSet[s] = new ActionProperty(s, typeof(bool), PropertyDisplayType.Checkbox, propValue, propValue, propValue, false);
                }
                merger.AddActionPropertySet(newSet);
                propValue = !propValue;
            }

            #endregion

            PolicyResponseAction resultPra = merger.MergePra() as PolicyResponseAction;

            // if at least one user override is false then the override is false
            // if at least one visible is true the it should be what ?
            foreach (string s in props)
            {
                Assert.IsFalse((bool)resultPra.InternalProperties[s].Override, "Override should be disallowed for {0}", s);
                Assert.IsTrue((bool)resultPra.InternalProperties[s].Visible, "props should be visible for {0}", s);
            }
            Assert.IsTrue((bool)(resultPra.InternalProperties["EXECUTE"].Value), "EXECUTE property should be true if at least one set specifies true");
            Assert.IsFalse((bool)(resultPra.InternalProperties["transparent"].Value), "transparent property should be false if at least one set specifies false");
            Assert.IsTrue((bool)resultPra.InternalProperties["autoexpand"].Value, "autoexpand property value should be true");
        }
Esempio n. 21
0
 set => SetValue(ActionProperty, value);
Esempio n. 22
0
		public IActionPropertySet MergeProperties(IActionPropertySet[] sets)
		{
			ActionPropertySet merged = new ActionPropertySet();
			merged["ThisWasMerged"] = new ActionProperty("yaya", "sisterhood");
			return merged;
		}
Esempio n. 23
0
 protected override void Initialize()
 {
     SalesOrderIdProperty = new IntegerKeyProperty(this, SalesOrderId)
     {
         Required = true,
         Editable = false,
         IsKey    = true,
     };
     SalesOrderNumberProperty = new TextProperty(this, SalesOrderNumber)
     {
         Required = true,
         Size     = 25,
         Editable = false,
     };
     StatusProperty = new EnumByteProperty(this, Status)
     {
         Required = true,
         EnumType = "sales order status",
         Editable = false,
     };
     OrderDateProperty = new DateProperty(this, OrderDate)
     {
         Required = true,
         Editable = false,
     };
     ShipDateProperty = new DateProperty(this, ShipDate)
     {
         Editable = false,
     };
     DueDateProperty = new DateProperty(this, DueDate)
     {
         Required = true,
         Editable = false,
     };
     TotalDueProperty = new MoneyProperty(this, TotalDue)
     {
         Required = true,
         Editable = false,
     };
     OnlineOrderFlagProperty = new EnumBoolProperty(this, OnlineOrderFlag)
     {
         Required         = true,
         EnumType         = "yesno",
         LookupValidation = LookupValidationType.None,
         Editable         = false,
     };
     CustomerStoreProperty = new TextProperty(this, CustomerStore)
     {
         Size     = 50,
         Editable = false,
     };
     CustomerNameProperty = new TextProperty(this, CustomerName)
     {
         Size     = 50,
         Editable = false,
     };
     SalesPersonIdProperty = new EnumIntProperty(this, SalesPersonId)
     {
         EnumType = "sales person",
         Editable = false,
     };
     TerritoryIdProperty = new EnumIntProperty(this, TerritoryId)
     {
         EnumType = "sales territory",
         Editable = false,
     };
     DetailsAction = new ActionProperty(this, "Details");
     NewAction     = new ActionProperty(this, "New");
 }
Esempio n. 24
0
		internal CachedAction LoadActionObject(string objectRef, string ActionName, out string assembly, out string actionClass)
		{
			assembly = string.Empty;
			actionClass = string.Empty;

			object actionPropertiesObject = null;
			if (m_CachedActions.ContainsKey(objectRef))
				return m_CachedActions[objectRef];

			string xpath = string.Format(CultureInfo.InvariantCulture, "*[@ref='{0}']", objectRef);
			XmlNode objectNode = m_ActionNode.SelectSingleNode(xpath);

			assembly = objectNode.Attributes.GetNamedItem("assembly").Value;
			string className = objectNode.Attributes.GetNamedItem("class").Value;
			string objectReference = objectNode.Attributes.GetNamedItem("ref").Value;
			string precedence = objectNode.Attributes.GetNamedItem("precedence").Value;

			actionClass = className;

			// Old policies dont have runat in the objects.xml
			string runat = objectNode.Attributes["runat"] == null ? string.Empty : objectNode.Attributes["runat"].Value;

			if (!ShouldLoadAction(runat))
				return null;

			// Construct the actionobject and its associated property set
			object actionObject = null;
			lock (m_lock)
			{
				string path = AssemblyLocation.GetPathForActionAssembly(assembly);

				actionObject = LoadObject(path, className);
				actionPropertiesObject = LoadActionPropertySet(path);
			}

			// Set all the properties to their default values, as provided
			// by the action property set. This means that, even if the xml 
			// for the action does not contain entries for properties that need to
			// be supported in the action they will be there. Also set system
			// properties at this point
			CachedAction cachedAction = new CachedAction(actionObject, actionPropertiesObject);

			if (objectNode.Attributes["type"] != null)
				cachedAction.Type = objectNode.Attributes["type"].Value;

			// Populate the system properties - just do in here for now
			// FileType
			// CurrentUser
			// Date
			// RecipientList
			// RunAt
			IActionProperty actionProperty = new ActionProperty("FileType", FileType.GetType(), PropertyDisplayType.Default, false, false, FileType, true);
			cachedAction.Properties.SystemProperties.Add("FileType", actionProperty);
			actionProperty = new ActionProperty("CurrentUser", CurrentUser.GetType(), PropertyDisplayType.Default, false, false, CurrentUser, true);
			cachedAction.Properties.SystemProperties.Add("CurrentUser", actionProperty);
			actionProperty = new ActionProperty("Date", CurrentDate.GetType(), PropertyDisplayType.Default, false, false, CurrentDate, true);
			cachedAction.Properties.SystemProperties.Add("Date", actionProperty);
			actionProperty = new ActionProperty("RecipientList", RecipientList.GetType(), PropertyDisplayType.Default, false, false, RecipientList, true);
			cachedAction.Properties.SystemProperties.Add("RecipientList", actionProperty);
			actionProperty = new ActionProperty("RunAt", CurrentRunAtMode.GetType(), PropertyDisplayType.Default, false, false, CurrentRunAtMode, true);
			cachedAction.Properties.SystemProperties.Add("RunAt", actionProperty);

			XmlNodeList dataElements = objectNode.ChildNodes;

			cachedAction.Precedence = Workshare.Policy.Actions.CertifiedActions.ActionPrecedence.GetPrecedence(assembly);
			cachedAction.AllowOverride = GetAllowOverride(objectNode);

			foreach (XmlNode dataElement in dataElements)
			{
				string deName = GetNameAttribute(dataElement);
				string deType = dataElement.Attributes.GetNamedItem("type").Value.ToLower(CultureInfo.InvariantCulture);

				bool allowOverride = GetAllowOverride(dataElement);
				bool isVisible = GetIsVisible(dataElement);
				bool isCustomProperty = GetIsCustomProperty(dataElement);

				foreach (XmlNode childNode in dataElement)
				{
					string name = childNode.Name.ToLower(CultureInfo.InvariantCulture);

					switch (name)
					{
					case "dataitem":
						{
							switch (deType)
							{
							case "boolean":
								cachedAction.SetProperty(deName, childNode.InnerText.ToLower(CultureInfo.InvariantCulture) == "true", allowOverride, isVisible, null);
								break;
							case "string":
								cachedAction.SetProperty(deName, childNode.InnerText, allowOverride, isVisible, null);
								break;
							case "long":
								cachedAction.SetProperty(deName, Convert.ToInt32(childNode.InnerText, CultureInfo.InvariantCulture), allowOverride, isVisible, null);
								break;
							case "double":
								cachedAction.SetProperty(deName, Convert.ToDouble(childNode.InnerText, CultureInfo.InvariantCulture), allowOverride, isVisible, null);
								break;
							case "datetime":
							case "date":
								cachedAction.SetProperty(deName, Convert.ToDateTime(childNode.InnerText, CultureInfo.InvariantCulture), allowOverride, isVisible, null);
								break;
							case "empty":
								cachedAction.SetProperty(deName, null, allowOverride, isVisible, null);
								break;
							case "stringarray":
								cachedAction.SetStringArrayProperty(deName, childNode.InnerText, allowOverride, isVisible, null);
								break;
							}

							break; //dataitem
						}
					case "datasource":
						{
							string asmName = childNode.Attributes.GetNamedItem("assembly").Value;
							string clsName = childNode.Attributes.GetNamedItem("class").Value;
							object datasourceObj = LoadObject(asmName, clsName);

							foreach (XmlNode dataMethod in childNode.ChildNodes)
							{
								string methodName = GetNameAttribute(dataMethod);
								MethodInfo methodInfo = datasourceObj.GetType().GetMethod(methodName);
								if (methodInfo != null)
									cachedAction.SetProperty(deName, methodInfo.Invoke(datasourceObj, null), allowOverride, isVisible, null);
								else
								{
									PropertyInfo propInfo = datasourceObj.GetType().GetProperty(methodName);
									if (propInfo != null)
									{
										if (isCustomProperty)
										{
											// If this is a custom property that has been mapped to a system property, then the value needs
											// to be converted into an appropriate string. For all type of system property currently supported
											// this is satisfied by a ToString(), EXCEPT for a string array, which needs to be converted into
											// a single string delimited by semi-colons
											if (propInfo.PropertyType == typeof(string[]))
											{
												cachedAction.SetProperty(deName, Utils.StringArrayToDelimitedString(propInfo.GetValue(datasourceObj, null) as string[], ';'), allowOverride, isVisible, null);
											}
											else
											{
												cachedAction.SetProperty(deName, propInfo.GetValue(datasourceObj, null).ToString(), allowOverride, isVisible, null);
											}
										}
										else
										{
											// It's not a custom property, so populate the property with the object value
											cachedAction.SetProperty(deName, propInfo.GetValue(datasourceObj, null), allowOverride, isVisible, null);
										}
									}
								}
							}
							break;
						}
					default:
						break;
					}
				}
			}
			return cachedAction;
		}
Esempio n. 25
0
 protected virtual void OnDestroy()
 {
     actionProperty = null;
 }
        public void EnsureSystemPropertiesArePreserved()
        {
            #region setup
            string[] systemProperties = { "CurrentUser", "Date", "RecipientList", "RunAt", "FileType" };

            BasicAction basic = new BasicAction();
            ActionPropertySet set = new ActionPropertySet();
            set["Add"] = new ActionProperty("TEST", "test");
            basic.PropertySet = set;
            PolicyResponseAction pra = new PolicyResponseAction();
            pra.Action = basic;
            pra.InternalProperties = set;

            set["Add"].Value = "test2";
            foreach (string s in systemProperties)
            {
                set.SystemProperties[s] = new ActionProperty(s, s);
            }

            PolicyResponseActionMerger merger = new PolicyResponseActionMerger(pra);

            merger.AddActionPropertySet(set);
            #endregion

            //execute
            pra = merger.MergePra() as PolicyResponseAction;

            //verify
            foreach (string s in systemProperties)
            {
                SortedList<string, IActionProperty> aps = pra.InternalProperties.SystemProperties;
                Assert.IsTrue(aps.ContainsKey(s) && aps[s].Value.ToString() == s, "System property {0} has been modified after merge", s);
            }
        }