public SyncedValueProperty(int id, Value syncedValue, ActivationRule activationRule, int activationValue, int initialValue, string[] tags, object[] cookies) { this.id = id; if (syncedValue == null) { throw new NullReferenceException("Synced value cannot be null"); } this.syncedValue = syncedValue; if (activationRule == null) { throw new NullReferenceException("Activation rule cannot be null"); } this.activationRule = activationRule; this.activationValue = activationValue; this.initialValue = initialValue; if (tags == null) { throw new NullReferenceException("Tags cannot be null"); } this.tags = tags; if (cookies == null) { throw new NullReferenceException("Cookies cannot be null"); } this.cookies = cookies; }
/*public Property defineProperty(int id, int value, ActivationRule activationRule, int activationValue, * int initialValue, string[] tags, object[] cookies) { * Property property = new DefaultProperty(id, value, activationRule, activationValue, initialValue, tags, cookies); * properties[id] = property; * return property; * }*/ public Property defineSyncedValueProperty(int id, SyncedValueProperty.Value value, ActivationRule activationRule, int activationValue, int initialValue, string[] tags, object[] cookies) { Property property = new SyncedValueProperty(id, value, activationRule, activationValue, initialValue, tags, cookies); properties[id] = property; return(property); }
private bool TryCreateActivationRuleInternal(XmlNode node, out ActivationRule activationRule) { activationRule = null; if (node == null || node.Attributes == null) { return(false); } XmlAttribute xmlAttribute = node.Attributes["type", "http://www.w3.org/2001/XMLSchema-instance"]; string a; if (!ExtensionDataHelper.TryGetNameSpaceStrippedAttributeValue(xmlAttribute, out a)) { return(false); } if (!string.Equals(a, "ItemIs", StringComparison.Ordinal)) { if (string.Equals(a, "ItemHasKnownEntity", StringComparison.Ordinal)) { KnownEntityType entityType; if (EnumValidator.TryParse <KnownEntityType>(node.Attributes["EntityType"].Value, EnumParseOptions.Default, out entityType)) { XmlAttribute xmlAttribute2 = node.Attributes["FilterName"]; XmlAttribute xmlAttribute3 = node.Attributes["RegExFilter"]; bool ignoreCase = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IgnoreCase"]); activationRule = new ItemHasKnownEntityRule(entityType, (xmlAttribute2 != null) ? xmlAttribute2.Value : null, (xmlAttribute3 != null) ? xmlAttribute3.Value : null, ignoreCase); return(true); } } else if (string.Equals(a, "ItemHasRegularExpressionMatch", StringComparison.Ordinal)) { RegExPropertyName propertyName; if (EnumValidator.TryParse <RegExPropertyName>(node.Attributes["PropertyName"].Value, EnumParseOptions.Default, out propertyName)) { bool ignoreCase2 = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IgnoreCase"]); activationRule = new ItemHasRegularExpressionMatchRule(node.Attributes["RegExName"].Value, node.Attributes["RegExValue"].Value, propertyName, ignoreCase2); return(true); } } else { if (string.Equals(a, "ItemHasAttachment", StringComparison.Ordinal)) { activationRule = new ItemHasAttachmentRule(); return(true); } if (node.ChildNodes != null && 0 < node.ChildNodes.Count && string.Equals(a, "RuleCollection", StringComparison.Ordinal)) { ActivationRule[] array = new ActivationRule[node.ChildNodes.Count]; int num = 0; foreach (object obj in node.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; ActivationRule activationRule2; if (this.IsExpectedOweNamespace(xmlNode.NamespaceURI) && string.Equals(xmlNode.LocalName, "Rule", StringComparison.Ordinal) && this.TryCreateActivationRuleInternal(xmlNode, out activationRule2)) { array[num++] = activationRule2; } } xmlAttribute = node.Attributes["Mode"]; activationRule = new CollectionRule((xmlAttribute == null) ? "Or" : xmlAttribute.Value, array); return(true); } } return(false); } ItemIsRuleItemType itemType; if (EnumValidator.TryParse <ItemIsRuleItemType>(node.Attributes["ItemType"].Value, EnumParseOptions.Default, out itemType)) { XmlAttribute xmlAttribute4 = node.Attributes["FormType"]; ItemIsRuleFormType formType; if (xmlAttribute4 == null || !EnumValidator.TryParse <ItemIsRuleFormType>(xmlAttribute4.Value, EnumParseOptions.Default, out formType)) { formType = ItemIsRuleFormType.Read; } bool includeSubClasses = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IncludeSubClasses"]); XmlAttribute xmlAttribute5 = node.Attributes["ItemClass"]; activationRule = new ItemIsRule(itemType, (xmlAttribute5 != null) ? xmlAttribute5.Value : null, includeSubClasses, formType); return(true); } return(false); }
public bool TryCreateActivationRule(out ActivationRule activationRule) { return(this.TryCreateActivationRuleInternal(this.GetOweXmlNode("Rule"), out activationRule)); }