public static IEnumerable <U> Children <T, U>(this IEnumerable <T> source) where T : JToken { ValidationUtils.ArgumentNotNull(source, "source"); return(source.SelectMany((T c) => c.Children()).Convert <JToken, U>()); }
public static IJEnumerable <JToken> Descendants <T>(this IEnumerable <T> source) where T : JContainer { ValidationUtils.ArgumentNotNull(source, "source"); return(source.SelectMany((T j) => j.Descendants()).AsJEnumerable()); }
public string Encrypt(string data) { ValidationUtils.ArgumentNotNull(data, nameof(data)); return(data); }
public static IJEnumerable <JToken> Ancestors <T>(this IEnumerable <T> source) where T : JToken { ValidationUtils.ArgumentNotNull(source, "source"); return(source.SelectMany((T j) => j.Ancestors()).AsJEnumerable()); }
internal ValidationEventArgs(JsonSchemaException ex) { ValidationUtils.ArgumentNotNull(ex, "ex"); _ex = ex; }
protected override async Task <Contractor> BindUser(EditContractorRequest requestBody, DateTime creationDate) { return(await Task.Run(() => new Contractor() { StartDate = ValidationUtils.ValidateStartDate(requestBody.Inauguracao), Email = ValidationUtils.ValidateEmail(requestBody.Email), EmailConfirmed = false, Address = new Address() { City = requestBody.Cidade, State = EnumExtensions.FromShortDisplayName <BrazilState>(requestBody.Uf), Road = requestBody.Endereco, Numeration = requestBody.Numero, }, Phone = ValidationUtils.ValidatePhoneNumber(requestBody.Telefone), Ip = TrackedEntity <IPAddress> .From(HttpContext.Connection.RemoteIpAddress, creationDate), FullName = ValidationUtils.ValidateName(requestBody.NomeCompleto), Password = string.IsNullOrWhiteSpace(requestBody.Senha) ? null : Encryption.Encrypt(ValidationUtils.ValidatePassword(requestBody.Senha)), PremiumLevel = PremiumLevel.None, Avatar = null, About = requestBody.Sobre, })); }
// Token: 0x060000A7 RID: 167 RVA: 0x00004954 File Offset: 0x00002B54 protected override void ValidateProperties(OperatorStatus status, IList <Edge> inputEdges) { ValidationUtils.ValidateTypedInputFieldExistence(status, this.PropertyBagFieldName, BuiltInTypes.BucketType, inputEdges); ValidationUtils.ValidateTypedInputFieldExistence(status, this.SelectPropertiesFieldName, BuiltInTypes.ListType(BuiltInTypes.StringType), inputEdges); ValidationUtils.ValidateTypedInputFieldExistence(status, this.TenantIdFieldName, BuiltInTypes.GuidType, inputEdges); }
/// <summary> /// Initializes a new instance of the <see cref="DynamicValueProvider"/> class. /// </summary> /// <param name="memberInfo">The member info.</param> public DynamicValueProvider(MemberInfo memberInfo) { ValidationUtils.ArgumentNotNull(memberInfo, nameof(memberInfo)); _memberInfo = memberInfo; }
private ODataResourceCollectionInfo ReadCollectionElement() { ODataResourceCollectionInfo info = new ODataResourceCollectionInfo(); string attribute = base.XmlReader.GetAttribute(this.AtomHRefAttributeName, this.EmptyNamespace); ValidationUtils.ValidateResourceCollectionInfoUrl(attribute); info.Url = base.ProcessUriFromPayload(attribute, base.XmlReader.XmlBaseUri); bool enableAtomMetadataReading = base.MessageReaderSettings.EnableAtomMetadataReading; AtomResourceCollectionMetadata collectionMetadata = null; if (enableAtomMetadataReading) { collectionMetadata = new AtomResourceCollectionMetadata(); } if (!base.XmlReader.IsEmptyElement) { base.XmlReader.ReadStartElement(); do { switch (base.XmlReader.NodeType) { case XmlNodeType.Element: if (base.XmlReader.NamespaceEquals(this.AtomPublishingNamespace)) { if (base.XmlReader.LocalNameEquals(this.AtomPublishingCategoriesElementName)) { if (enableAtomMetadataReading) { this.ServiceDocumentMetadataDeserializer.ReadCategoriesElementInCollection(collectionMetadata); } else { base.XmlReader.Skip(); } } else { if (!base.XmlReader.LocalNameEquals(this.AtomPublishingAcceptElementName)) { throw new ODataException(Strings.ODataAtomServiceDocumentDeserializer_UnexpectedElementInResourceCollection(base.XmlReader.LocalName)); } if (enableAtomMetadataReading) { this.ServiceDocumentMetadataDeserializer.ReadAcceptElementInCollection(collectionMetadata); } else { base.XmlReader.Skip(); } } } else if (base.XmlReader.NamespaceEquals(this.AtomNamespace)) { if (enableAtomMetadataReading && base.XmlReader.LocalNameEquals(this.AtomTitleElementName)) { this.ServiceDocumentMetadataDeserializer.ReadTitleElementInCollection(collectionMetadata); } else { base.XmlReader.Skip(); } } else { base.XmlReader.Skip(); } break; case XmlNodeType.EndElement: break; default: base.XmlReader.Skip(); break; } }while (base.XmlReader.NodeType != XmlNodeType.EndElement); } base.XmlReader.Read(); if (enableAtomMetadataReading) { info.SetAnnotation <AtomResourceCollectionMetadata>(collectionMetadata); } return(info); }
public JsonFormatterConverter(JsonSerializer serializer) { ValidationUtils.ArgumentNotNull(serializer, "serializer"); _serializer = serializer; }
/// <summary> /// Initializes a new instance of the <see cref="JEnumerable{T}"/> struct. /// </summary> /// <param name="enumerable">The enumerable.</param> public JEnumerable(IEnumerable <T> enumerable) { ValidationUtils.ArgumentNotNull(enumerable, nameof(enumerable)); _enumerable = enumerable; }
public void ValidateLengthTestIvalidLength2() { Length invalidUnitLength = "180pt"; ValidationUtils.ValidateLength(invalidUnitLength, min, max); }
/// <summary> /// Initializes a new instance of the <see cref="JsonValidatingReader"/> class that /// validates the content returned from the given <see cref="JsonReader"/>. /// </summary> /// <param name="reader">The <see cref="JsonReader"/> to read from while validating.</param> public JsonValidatingReader(JsonReader reader) { ValidationUtils.ArgumentNotNull(reader, "reader"); _reader = reader; _stack = new Stack <SchemaScope>(); }
public static IJEnumerable <JProperty> Properties(this IEnumerable <JObject> source) { ValidationUtils.ArgumentNotNull(source, "source"); return(source.SelectMany((JObject d) => d.Properties()).AsJEnumerable <JProperty>()); }
public ReflectionValueProvider(MemberInfo memberInfo) { ValidationUtils.ArgumentNotNull(memberInfo, "memberInfo"); this._memberInfo = memberInfo; }
/// <inheritdoc /> public override void Validate() { ValidationUtils.ValidateNotNull("annotation", Annotation); }
internal void ReadContentFrom(JsonReader r, JsonLoadSettings settings) { JProperty property1; JValue value2; JProperty property; ValidationUtils.ArgumentNotNull(r, "r"); IJsonLineInfo lineInfo = r as IJsonLineInfo; JContainer parent = this; Label_0014: property1 = parent as JProperty; if (property1 == null) { } if (null.Value != null) { if (parent == this) { return; } parent = parent.Parent; } switch (r.TokenType) { case JsonToken.None: goto Label_0247; case JsonToken.StartObject: { JObject content = new JObject(); content.SetLineInfo(lineInfo, settings); parent.Add(content); parent = content; goto Label_0247; } case JsonToken.StartArray: { JArray content = new JArray(); content.SetLineInfo(lineInfo, settings); parent.Add(content); parent = content; goto Label_0247; } case JsonToken.StartConstructor: { JConstructor content = new JConstructor(r.Value.ToString()); content.SetLineInfo(lineInfo, settings); parent.Add(content); parent = content; goto Label_0247; } case JsonToken.PropertyName: { string name = r.Value.ToString(); property = new JProperty(name); property.SetLineInfo(lineInfo, settings); JProperty property2 = ((JObject)parent).Property(name); if (property2 != null) { property2.Replace(property); break; } parent.Add(property); break; } case JsonToken.Comment: if ((settings != null) && (settings.CommentHandling == CommentHandling.Load)) { value2 = JValue.CreateComment(r.Value.ToString()); value2.SetLineInfo(lineInfo, settings); parent.Add(value2); } goto Label_0247; case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Date: case JsonToken.Bytes: value2 = new JValue(r.Value); value2.SetLineInfo(lineInfo, settings); parent.Add(value2); goto Label_0247; case JsonToken.Null: value2 = JValue.CreateNull(); value2.SetLineInfo(lineInfo, settings); parent.Add(value2); goto Label_0247; case JsonToken.Undefined: value2 = JValue.CreateUndefined(); value2.SetLineInfo(lineInfo, settings); parent.Add(value2); goto Label_0247; case JsonToken.EndObject: if (parent != this) { parent = parent.Parent; goto Label_0247; } return; case JsonToken.EndArray: if (parent != this) { parent = parent.Parent; goto Label_0247; } return; case JsonToken.EndConstructor: if (parent != this) { parent = parent.Parent; goto Label_0247; } return; default: throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType)); } parent = property; Label_0247: if (r.Read()) { goto Label_0014; } }
/// <summary> /// Initializes a new instance of the <see cref="JConstructor"/> class with the specified name. /// </summary> /// <param name="name">The constructor name.</param> public JConstructor(string name) { ValidationUtils.ArgumentNotNullOrEmpty(name, "name"); _name = name; }
internal virtual void SerializeInternal([Nullable(1)] JsonWriter jsonWriter, object value, Type objectType) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); Formatting?formatting = null; if (this._formatting != null) { Formatting formatting2 = jsonWriter.Formatting; Formatting?formatting3 = this._formatting; if (!(formatting2 == formatting3.GetValueOrDefault() & formatting3 != null)) { formatting = new Formatting?(jsonWriter.Formatting); jsonWriter.Formatting = this._formatting.GetValueOrDefault(); } } DateFormatHandling?dateFormatHandling = null; if (this._dateFormatHandling != null) { DateFormatHandling dateFormatHandling2 = jsonWriter.DateFormatHandling; DateFormatHandling?dateFormatHandling3 = this._dateFormatHandling; if (!(dateFormatHandling2 == dateFormatHandling3.GetValueOrDefault() & dateFormatHandling3 != null)) { dateFormatHandling = new DateFormatHandling?(jsonWriter.DateFormatHandling); jsonWriter.DateFormatHandling = this._dateFormatHandling.GetValueOrDefault(); } } DateTimeZoneHandling?dateTimeZoneHandling = null; if (this._dateTimeZoneHandling != null) { DateTimeZoneHandling dateTimeZoneHandling2 = jsonWriter.DateTimeZoneHandling; DateTimeZoneHandling?dateTimeZoneHandling3 = this._dateTimeZoneHandling; if (!(dateTimeZoneHandling2 == dateTimeZoneHandling3.GetValueOrDefault() & dateTimeZoneHandling3 != null)) { dateTimeZoneHandling = new DateTimeZoneHandling?(jsonWriter.DateTimeZoneHandling); jsonWriter.DateTimeZoneHandling = this._dateTimeZoneHandling.GetValueOrDefault(); } } FloatFormatHandling?floatFormatHandling = null; if (this._floatFormatHandling != null) { FloatFormatHandling floatFormatHandling2 = jsonWriter.FloatFormatHandling; FloatFormatHandling?floatFormatHandling3 = this._floatFormatHandling; if (!(floatFormatHandling2 == floatFormatHandling3.GetValueOrDefault() & floatFormatHandling3 != null)) { floatFormatHandling = new FloatFormatHandling?(jsonWriter.FloatFormatHandling); jsonWriter.FloatFormatHandling = this._floatFormatHandling.GetValueOrDefault(); } } StringEscapeHandling?stringEscapeHandling = null; if (this._stringEscapeHandling != null) { StringEscapeHandling stringEscapeHandling2 = jsonWriter.StringEscapeHandling; StringEscapeHandling?stringEscapeHandling3 = this._stringEscapeHandling; if (!(stringEscapeHandling2 == stringEscapeHandling3.GetValueOrDefault() & stringEscapeHandling3 != null)) { stringEscapeHandling = new StringEscapeHandling?(jsonWriter.StringEscapeHandling); jsonWriter.StringEscapeHandling = this._stringEscapeHandling.GetValueOrDefault(); } } CultureInfo cultureInfo = null; if (this._culture != null && !this._culture.Equals(jsonWriter.Culture)) { cultureInfo = jsonWriter.Culture; jsonWriter.Culture = this._culture; } string dateFormatString = null; if (this._dateFormatStringSet && jsonWriter.DateFormatString != this._dateFormatString) { dateFormatString = jsonWriter.DateFormatString; jsonWriter.DateFormatString = this._dateFormatString; } TraceJsonWriter traceJsonWriter = (this.TraceWriter == null || this.TraceWriter.LevelFilter < TraceLevel.Verbose) ? null : new TraceJsonWriter(jsonWriter); new JsonSerializerInternalWriter(this).Serialize(traceJsonWriter ?? jsonWriter, value, objectType); if (traceJsonWriter != null) { this.TraceWriter.Trace(TraceLevel.Verbose, traceJsonWriter.GetSerializedJsonMessage(), null); } if (formatting != null) { jsonWriter.Formatting = formatting.GetValueOrDefault(); } if (dateFormatHandling != null) { jsonWriter.DateFormatHandling = dateFormatHandling.GetValueOrDefault(); } if (dateTimeZoneHandling != null) { jsonWriter.DateTimeZoneHandling = dateTimeZoneHandling.GetValueOrDefault(); } if (floatFormatHandling != null) { jsonWriter.FloatFormatHandling = floatFormatHandling.GetValueOrDefault(); } if (stringEscapeHandling != null) { jsonWriter.StringEscapeHandling = stringEscapeHandling.GetValueOrDefault(); } if (this._dateFormatStringSet) { jsonWriter.DateFormatString = dateFormatString; } if (cultureInfo != null) { jsonWriter.Culture = cultureInfo; } }
private static string EncryptData(string profileData) { return(PortalSecurity.Instance.Encrypt(ValidationUtils.GetDecryptionKey(), profileData)); }
private JsonSchema GenerateInternal(Type type, bool valueRequired) { ValidationUtils.ArgumentNotNull(type, "type"); string resolvedId = GetTypeId(type, false); string explicitId = GetTypeId(type, true); if (!string.IsNullOrEmpty(resolvedId)) { JsonSchema resolvedSchema = _resolver.GetSchema(resolvedId); if (resolvedSchema != null) { return(resolvedSchema); } } // test for unresolved circular reference if (_stack.Any(tc => tc.Type == type)) { throw new Exception("Unresolved circular reference for type '{0}'. Explicitly define an Id for the type using a JsonObject/JsonArray attribute or automatically generate a type Id using the UndefinedSchemaIdHandling property.".FormatWith(CultureInfo.InvariantCulture, type)); } Push(new TypeSchema(type, new JsonSchema())); if (explicitId != null) { CurrentSchema.Id = explicitId; } CurrentSchema.Title = GetTitle(type); CurrentSchema.Description = GetDescription(type); if (CollectionUtils.IsDictionaryType(type)) { CurrentSchema.Type = JsonSchemaType.Object; Type keyType; Type valueType; ReflectionUtils.GetDictionaryKeyValueTypes(type, out keyType, out valueType); if (keyType != null) { // can be converted to a string if (typeof(IConvertible).IsAssignableFrom(keyType)) { CurrentSchema.AdditionalProperties = GenerateInternal(valueType, false); } } } else if (CollectionUtils.IsCollectionType(type)) { CurrentSchema.Type = JsonSchemaType.Array; JsonArrayAttribute arrayAttribute = JsonTypeReflector.GetJsonContainerAttribute(type) as JsonArrayAttribute; bool allowNullItem = (arrayAttribute != null) ? arrayAttribute.AllowNullItems : false; Type collectionItemType = ReflectionUtils.GetCollectionItemType(type); if (collectionItemType != null) { CurrentSchema.Items = new List <JsonSchema>(); CurrentSchema.Items.Add(GenerateInternal(collectionItemType, !allowNullItem)); } } else { CurrentSchema.Type = GetJsonSchemaType(type, valueRequired); if (HasFlag(CurrentSchema.Type, JsonSchemaType.Object)) { CurrentSchema.Id = GetTypeId(type, false); JsonObjectContract contract = ContractResolver.ResolveContract(type) as JsonObjectContract; if (contract == null) { throw new Exception("Could not resolve contract for '{0}'.".FormatWith(CultureInfo.InvariantCulture, type)); } CurrentSchema.Properties = new Dictionary <string, JsonSchema>(); foreach (JsonProperty property in contract.Properties) { if (!property.Ignored) { Type propertyMemberType = ReflectionUtils.GetMemberUnderlyingType(property.Member); JsonSchema propertySchema = GenerateInternal(propertyMemberType, property.Required); if (property.DefaultValue != null) { propertySchema.Default = JToken.FromObject(property.DefaultValue); } CurrentSchema.Properties.Add(property.PropertyName, propertySchema); } } if (type.IsSealed) { CurrentSchema.AllowAdditionalProperties = false; } } else if (CurrentSchema.Type == JsonSchemaType.Integer && type.IsEnum && !type.IsDefined(typeof(FlagsAttribute), true)) { CurrentSchema.Enum = new List <JToken>(); CurrentSchema.Options = new Dictionary <JToken, string>(); EnumValues <ulong> enumValues = EnumUtils.GetNamesAndValues <ulong>(type); foreach (EnumValue <ulong> enumValue in enumValues) { JToken value = JToken.FromObject(enumValue.Value); CurrentSchema.Enum.Add(value); CurrentSchema.Options.Add(value, enumValue.Name); } } } return(Pop().Schema); }