public void BuiltInToBuiltIn() { var source = new BuiltInTypes(); var ultraMapper = new Mapper(cfg => { cfg.MapTypes <BuiltInTypes, BuiltInTypes>() //map with custom converter .MapMember(a => a.Single, d => d.String, single => single.ToString()) //map same source property to many different targets .MapMember(a => a.Char, d => d.Single) .MapMember(a => a.Char, d => d.Int32) .MapMember(a => 123, d => d.Single) //same source and destination members: last mapping overrides and adds the converter .MapMember(a => a.String, d => d.Single) .MapMember(a => a.String, d => d.Single, @string => Single.Parse(@string)) //same sourceproperty/destinationProperty: second mapping overrides and removes (set to null) the converter .MapMember(a => a.Single, y => y.Double, a => a + 254) .MapMember(a => a.Single, y => y.Double); }); var target = ultraMapper.Map(source); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public override JavaScriptObject Evaluate(Scope scope, BuiltInTypes.JavaScriptObject thisObject) { List<Parameter> resultParameters = ProcessParameters(scope, thisObject); UserFunction function = new UserFunction(resultParameters, body, this.Name); if (function.Name.Length > 0) scope.SetFunction(function); return function; }
public void BuiltInToBuiltIn() { var source = new BuiltInTypes() { Boolean = true, Byte = 0x1, Char = (char)2, Decimal = 3, Double = 4.0, Int16 = 5, Int32 = 6, Int64 = 7, SByte = 0x8, Single = 9.0f, UInt16 = 10, UInt32 = 11, UInt64 = 12, String = "13" }; var ultraMapper = new Mapper(cfg => { cfg.MapTypes <BuiltInTypes, BuiltInTypes>() //map with custom converter .MapMember(a => a.Single, d => d.String, single => single.ToString()) //map same source property to many different targets .MapMember(a => a.Char, d => d.Int32) //same source and destination members: last mapping overrides and adds the converter .MapMember(a => a.Char, d => d.Single) .MapMember(a => 123, d => d.Single) .MapMember(a => a.String, d => d.Single) .MapMember(a => a.String, d => d.Single, @string => Single.Parse(@string)) //same sourceproperty/destinationProperty: second mapping overrides and removes (set to null) the converter .MapMember(a => a.Single, y => y.Double, a => a + 254) .MapMember(a => a.Single, y => y.Double); }); var target = ultraMapper.Map(source); Assert.IsTrue(target.Boolean); Assert.IsTrue(target.Byte == 0x1); Assert.IsTrue(target.Char == (char)2); Assert.IsTrue(target.Decimal == 3); Assert.IsTrue(target.Double == 9.0); Assert.IsTrue(target.Int16 == 5); Assert.IsTrue(target.Int32 == 2); Assert.IsTrue(target.Int64 == 7); Assert.IsTrue(target.SByte == 0x8); Assert.IsTrue(target.Single == 13); Assert.IsTrue(target.UInt16 == 10); Assert.IsTrue(target.UInt32 == 11); Assert.IsTrue(target.UInt64 == 12); }
public static void TerminalProgram(List <string> option) { if (!option.Any()) { Console.WriteLine("please write a command!! or use --help for more informations!"); return; } var FirstCommand = option[0]; if (FirstCommand.Contains("-a") || FirstCommand.Contains("--all")) { BuiltInTypes.ShowBuiltInValuesTypes(); BuiltInTypes.ShowBuiltInReferenceTypes(); } if (FirstCommand.Contains("-r") || FirstCommand.Contains("--reference")) { BuiltInTypes.ShowBuiltInReferenceTypes(); } if (FirstCommand.Contains("-v") || FirstCommand.Contains("--values")) { BuiltInTypes.ShowBuiltInValuesTypes(); } if (FirstCommand.Contains("-m") || FirstCommand.Contains("--more")) { try { var SecondCommand = option[1]; BuiltInTypes.ShowMoreInfoTypes(SecondCommand); } catch (Exception e) { Console.Error.WriteLine(e); Console.WriteLine("especify the Type to show more info"); return; } } if (FirstCommand.Contains("--version")) { BuiltInTypes.ShowVersion(); } if (FirstCommand.Contains("--help")) { BuiltInTypes.ShowVersion(); } }
public void BuiltInToNullable() { var source = new BuiltInTypes(); var target = new NullableBuiltInTypes(); var ultraMapper = new Mapper(); ultraMapper.Map(source, target); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
internal static string BuiltInTypeToString(BuiltInTypes type) { if (type == BuiltInTypes.string_yang) { return("string"); } else if (type == BuiltInTypes.instance_identifier) { return("instance-identifier"); } else { return(type.ToString()); } }
public static DocumentNode SerializeSchema( ISchema schema, bool includeSpecScalars = false, bool printResolverKind = false) { if (schema is null) { throw new ArgumentNullException(nameof(schema)); } var typeDefinitions = GetNonScalarTypes(schema) .Select(t => SerializeNonScalarTypeDefinition(t, printResolverKind)) .OfType <IDefinitionNode>() .ToList(); if (schema.QueryType is not null || schema.MutationType is not null || schema.SubscriptionType is not null) { typeDefinitions.Insert(0, SerializeSchemaTypeDefinition(schema)); } var builtInDirectives = new HashSet <NameString> { Skip, Include, Deprecated }; IEnumerable <DirectiveDefinitionNode> directiveTypeDefinitions = schema.DirectiveTypes .Where(directive => !builtInDirectives.Contains(directive.Name)) .OrderBy(t => t.Name.ToString(), StringComparer.Ordinal) .Select(SerializeDirectiveTypeDefinition); typeDefinitions.AddRange(directiveTypeDefinitions); IEnumerable <ScalarTypeDefinitionNode> scalarTypeDefinitions = schema.Types .OfType <ScalarType>() .Where(t => includeSpecScalars || !BuiltInTypes.IsBuiltInType(t.Name)) .OrderBy(t => t.Name.ToString(), StringComparer.Ordinal) .Select(SerializeScalarType); typeDefinitions.AddRange(scalarTypeDefinitions); return(new DocumentNode(null, typeDefinitions)); }
public override INode Visit(IReturnType type, object data) { IReturnType rt = (IReturnType)base.Visit(type, data); if (BuiltInTypes.Contains(rt.FullName)) { return(rt); } DomReturnType returnType = new DomReturnType(rt); string longest = ""; string lastAlias = null; if (callingType != null && returnType.DecoratedFullName.StartsWith(callingType.FullName)) { int p1 = System.Math.Min(callingType.FullName.Count(ch => ch == '.') + 1, returnType.Parts.Count - 1); returnType.Parts.RemoveRange(0, p1); returnType.Namespace = ""; return(returnType); } foreach (IUsing u in unit.Usings.Where(u => u.ValidRegion.Contains(location))) { foreach (string ns in u.Namespaces.Where(ns => returnType.Namespace == ns || returnType.Namespace != null && returnType.Namespace.StartsWith(ns + "."))) { if (longest.Length < ns.Length) { longest = ns; } } foreach (KeyValuePair <string, IReturnType> alias in u.Aliases) { if (alias.Value.ToInvariantString() == type.ToInvariantString()) { lastAlias = alias.Key; } } } if (lastAlias != null) { return(new DomReturnType(lastAlias)); } if (longest.Length > 0 && returnType.Namespace == longest) { returnType.Namespace = ""; } return(returnType); }
private static void CrossEntities(IEnumerable <EntityRecommendation> entities) { // Cross match entities to copy resolution values for custom entities from pairs foreach (var group in entities.GroupBy(e => e.Entity)) { if (group.Count() > 1) { var entityToUpdate = group.FirstOrDefault(e => !BuiltInTypes.IsBuiltInType(e.Type)); var entityWithValue = group.FirstOrDefault(e => e.Resolution != null); if (entityToUpdate != null && entityWithValue != null) { entityToUpdate.Resolution = entityWithValue.Resolution; } } } }
public void NullableToBuiltIn() { var source = new NullableBuiltInTypes() { Boolean = true, Byte = 0x1, Char = '2', Decimal = 3, Double = 4.0, Int16 = 5, Int32 = 6, Int64 = 7, SByte = 0x9, Single = 10, String = "11", UInt16 = 12, UInt32 = 13, UInt64 = 14 }; var target = new BuiltInTypes() { Boolean = false, Byte = 15, Char = (char)16, Decimal = 17, Double = 18, Int16 = 19, Int32 = 20, Int64 = 21, SByte = 0x23, Single = 24, String = "25", UInt16 = 26, UInt32 = 27, UInt64 = 28 }; var ultraMapper = new Mapper(); ultraMapper.Map(source, target); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public void PrimitiveTypeToADifferentNullablePrimitiveType() { var source = new BuiltInTypes(); var target = new NullablePrimitiveTypes(); var ultraMapper = new Mapper ( cfg => { cfg.MapTypes <BuiltInTypes, NullablePrimitiveTypes>(tmc => tmc.IgnoreMemberMappingResolvedByConvention = true) .MapMember(s => s.Int32, t => t.Char); } ); ultraMapper.Map(source, target); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public void BuiltInToNullable() { var source = new BuiltInTypes(); var target = new NullableBuiltInTypes(); var ultraMapper = new Mapper ( cfg => { cfg.MapTypes <BuiltInTypes, NullablePrimitiveTypes>() .MapMember(s => s.Int32, s => s.Char); } ); ultraMapper.Map(source, target); bool isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public override string ConvertTypeName(string type) { type = TypeNameExpr.Replace( type, delegate(Match match) { string basetype = match.Groups["basetype"].Value; string result; if (BuiltInTypes.TryGetValue(basetype, out result)) { return(result); } else { return(basetype); } }); return(type.Replace('{', '<').Replace('}', '>')); }
public void NullNullablesToDefaultPrimitives() { var source = new NullableBuiltInTypes(); var target = new BuiltInTypes() { Boolean = true, Byte = 0x1, Char = (char)2, Decimal = 3, Double = 4.0, Int16 = 5, Int32 = 6, Int64 = 7, SByte = 0x9, Single = 10f, String = "11", UInt16 = 12, UInt32 = 13, UInt64 = 14, }; //each property must be set to null Assert.IsTrue(source.GetType().GetProperties() .All(p => p.GetValue(source) == null)); //each property must be set to a non-default value Assert.IsTrue(target.GetType().GetProperties() .All(p => { object defaultValue = p.PropertyType.GetDefaultValueViaActivator(); return(!p.GetValue(target).Equals(defaultValue)); })); var ultraMapper = new Mapper(); ultraMapper.Map(source, target); var isResultOk = ultraMapper.VerifyMapperResult(source, target); Assert.IsTrue(isResultOk); }
public static DocumentNode SerializeSchema( ISchema schema, bool includeSpecScalars = false) { if (schema is null) { throw new ArgumentNullException(nameof(schema)); } var typeDefinitions = GetNonScalarTypes(schema) .Select(SerializeNonScalarTypeDefinition) .OfType <IDefinitionNode>() .ToList(); if (schema.QueryType != null || schema.MutationType != null || schema.SubscriptionType != null) { typeDefinitions.Insert(0, SerializeSchemaTypeDefinition(schema)); } IEnumerable <DirectiveDefinitionNode> directiveTypeDefinitions = schema.DirectiveTypes .OrderBy(t => t.Name.ToString(), StringComparer.Ordinal) .Select(SerializeDirectiveTypeDefinition); typeDefinitions.AddRange(directiveTypeDefinitions); IEnumerable <ScalarTypeDefinitionNode> scalarTypeDefinitions = schema.Types .OfType <ScalarType>() .Where(t => includeSpecScalars || !BuiltInTypes.IsBuiltInType(t.Name)) .OrderBy(t => t.Name.ToString(), StringComparer.Ordinal) .Select(SerializeScalarType); typeDefinitions.AddRange(scalarTypeDefinitions); return(new DocumentNode(null, typeDefinitions)); }
internal DeserializerTypes(BuiltInTypes builtIn, FrameworkTypes framework, CesilTypes ourTypes) { BuiltIn = builtIn; Framework = framework; OurTypes = ourTypes; }
// Token: 0x06000017 RID: 23 RVA: 0x000027A4 File Offset: 0x000009A4 public void SetClassificationResults(ICAClassificationResultCollection results) { if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100)) { ULS.SendTraceTag(4850008U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "FASTClassificationItem.SetClassificationResults :: saving results for [{0}]", new object[] { this.ItemId }); } IUpdateableBucketField updateableBucketField = this.record[this.managedPropertiesPosition] as IUpdateableBucketField; if (updateableBucketField != null) { if (this.persistClassificationData) { updateableBucketField.AddField(this.lastScanPropertyName, StandardFields.GetStandardDateTimeField(new DateTime?(DateTime.UtcNow)), BuiltInTypes.DateTimeType); } ICollection <long?> collection = new List <long?>(); ICollection <long?> collection2 = new List <long?>(); ICollection <string> collection3 = new List <string>(); HashSet <long> hashSet = new HashSet <long>(); if (results != null && results.Count > 0) { this.resultCount = results.Count; for (int i = 0; i < this.resultCount; i++) { ICAClassificationResult icaclassificationResult = results[i + 1]; if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100)) { ULS.SendTraceTag(4850009U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "FASTClassificationItem.SetClassificationResults :: Results Found :: package={0} ruleId={1}", new object[] { icaclassificationResult.RulePackageID, icaclassificationResult.ID }); } long?resultBase = this.ruleStore.GetResultBase(icaclassificationResult.RulePackageID, icaclassificationResult.ID); if (resultBase == null) { ULS.SendTraceTag(6038295U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 50, "FASTClassificationItem.SetClassificationResults :: Unkwown rule ID in result (should not happen). :: package={0} ruleId={1}", new object[] { icaclassificationResult.RulePackageID, icaclassificationResult.ID }); } else { long value = resultBase.Value; if (!hashSet.Add(value)) { ULS.SendTraceTag(5833436U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 50, "FASTClassificationItem.SetClassificationResults :: Duplicate rule entry is being ignored. Duplicate rule entries should not happen. :: package={0} ruleId={1}", new object[] { icaclassificationResult.RulePackageID, icaclassificationResult.ID }); } else { long value2 = value + (long)((int)icaclassificationResult.GetAttributeValue("BD770258-EA9C-4162-B79C-7AD408EC7CD5")); long value3 = value + (long)((int)icaclassificationResult.GetAttributeValue("AFF85B32-1BA9-4EDE-9286-F08A7EE5A421")); collection.Add(new long?(value2)); collection2.Add(new long?(value3)); collection3.Add(icaclassificationResult.ID); } } } if (this.persistClassificationData && this.resultCount > 0) { if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100)) { ULS.SendTraceTag(4850010U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "FASTClassificationItem.SetClassificationResults :: Updating managed properties"); } IUpdateableListField <long?> updateableListField = (IUpdateableListField <long?>)StandardFields.ListDescriptor <long?>(BuiltInTypes.Int64Type).CreateField(); updateableListField.Value = collection; updateableBucketField.AddField(this.countPropertyName, updateableListField, BuiltInTypes.ListType(BuiltInTypes.Int64Type)); updateableListField = (IUpdateableListField <long?>)StandardFields.ListDescriptor <long?>(BuiltInTypes.Int64Type).CreateField(); updateableListField.Value = collection2; updateableBucketField.AddField(this.confidencePropertyName, updateableListField, BuiltInTypes.ListType(BuiltInTypes.Int64Type)); IUpdateableListField <string> updateableListField2 = (IUpdateableListField <string>)StandardFields.ListDescriptor <string>(BuiltInTypes.StringType).CreateField(); updateableListField2.Value = collection3; updateableBucketField.AddField(this.typePropertyName, updateableListField2, BuiltInTypes.ListType(BuiltInTypes.StringType)); } } } }
// Token: 0x060000C6 RID: 198 RVA: 0x00005317 File Offset: 0x00003517 protected override void ValidateProperties(OperatorStatus status, IList <Edge> inputEdges) { ValidationUtils.ValidateTypedInputFieldExistence(status, this.SelectPropertiesFieldName, BuiltInTypes.ListType(BuiltInTypes.StringType), inputEdges); ValidationUtils.ValidateTypedInputFieldExistence(status, this.TenantIdFieldName, BuiltInTypes.GuidType, inputEdges); }
public TypeStatement(BuiltInTypes BaseType) : base("type", BuiltInTypeToString(BaseType)) { BuiltInTypeOfNode = BaseType; }