private CloudEventsSpecVersion( string versionId, CloudEventAttribute idAttribute, CloudEventAttribute sourceAttribute, CloudEventAttribute typeAttribute, CloudEventAttribute dataContentTypeAttribute, CloudEventAttribute dataSchemaAttribute, CloudEventAttribute subjectAttribute, CloudEventAttribute timeAttribute) { VersionId = versionId; IdAttribute = idAttribute; SourceAttribute = sourceAttribute; TypeAttribute = typeAttribute; DataContentTypeAttribute = dataContentTypeAttribute; DataSchemaAttribute = dataSchemaAttribute; SubjectAttribute = subjectAttribute; TimeAttribute = timeAttribute; var allAttributes = new[] { idAttribute, sourceAttribute, typeAttribute, dataContentTypeAttribute, dataSchemaAttribute, subjectAttribute, timeAttribute }; RequiredAttributes = allAttributes.Where(a => a.IsRequired).ToList().AsReadOnly(); OptionalAttributes = allAttributes.Where(a => !a.IsRequired).ToList().AsReadOnly(); AllAttributes = RequiredAttributes.Concat(OptionalAttributes).ToList().AsReadOnly(); attributesByName = AllAttributes.ToDictionary(attr => attr.Name); allVersions.Add(this); }
private Dictionary <string, string> GetRequiredAttributes(XmlReader reader, RequiredAttributes attribs) { Dictionary <string, string> result = new Dictionary <string, string>(); foreach (RequiredAttribute attrib in attribs.Attributes) { string value; if (attrib.UseTemplate) { value = GetTemplateAttribute(reader, attrib.Name); } else { value = reader.GetAttribute(attrib.Name); } if (attrib.Required && (value == null || (!attrib.AllowBlank && value.Length == 0))) { throw new Exception(string.Format("Missing required attribute '{0}' in '{1}' tag", attrib.Name, reader.LocalName)); } result.Add(attrib.Name, value); } return(result); }
public WonkaRegistryItem(WonkaEth.Extensions.RuleTreeRegistryIndex poIndex, string psHostContractABI) { Init(); RuleTreeId = poIndex.RuleTreeId; Description = poIndex.RuleTreeDesc; HostContractAddress = poIndex.RuleTreeHostEngineAddr; HostContractABI = psHostContractABI; OwnerId = poIndex.RuleTreeOwner; MaxGasCost = poIndex.MaxGasCost; creationTime = poIndex.CreationEpochTime; RequiredAttributes.UnionWith(poIndex.RequiredAttributes); }
private bool IsAttributeValid(string attributeName, string value) { if (AllowedAttributes != null) { // No attributes are allowed if (!AllowedAttributes.Any()) { return(false); } if (!AllowedAttributes.Contains(attributeName)) { return(false); } } if (RequiredAttributes != null) { if (value == null && RequiredAttributes.Contains(attributeName)) { // Don't delete any required attributes return(false); } } if (AllowedValues != null) { if (AllowedValues.TryGetValue(attributeName, out var allowed) && !allowed.Contains(value.Trim())) { return(false); } } if (DisallowedValues != null) { if (DisallowedValues.TryGetValue(attributeName, out var disallowed) && disallowed.Contains(value.Trim())) { return(false); } } return(true); }
private Dictionary<string, string> GetRequiredAttributes(XmlReader reader, RequiredAttributes attribs) { Dictionary<string, string> result = new Dictionary<string, string>(); foreach (RequiredAttribute attrib in attribs.Attributes) { string value; if (attrib.UseTemplate) { value = GetTemplateAttribute(reader, attrib.Name); } else { value = reader.GetAttribute(attrib.Name); } if (attrib.Required && (value == null || (!attrib.AllowBlank && value.Length == 0))) { throw new Exception(string.Format("Missing required attribute '{0}' in '{1}' tag", attrib.Name, reader.LocalName)); } result.Add(attrib.Name, value); } return result; }